/* dependancy: manage_dhtml_layer.js */

//constants match the enumerations in fsWebControls
var collapsePanelContentState_Opened = 1;
var collapsePanelContentState_Closed = 2;

/*
Expand & collapse a DIV block, switch the appropriate indicator image & update the form element that allows the 
  Panel to rememeber it's CollapseState on postback
*/
function ToggleCollapsePanel(elementRootName,collapsedImage,expandedImage,collapsedAltText,expandedAltText) {
  //gather elements into working variables
  var collapseState =  getElementObject(elementRootName + '_ContentState'); 
  //alert(collapseState.value );
  if(collapseState.value == collapsePanelContentState_Opened){
    CloseCollapsePanel(elementRootName,collapsedImage,collapsedAltText);
  }else{
    OpenCollapsePanel(elementRootName,expandedImage,expandedAltText);
  }
}

function CloseCollapsePanel(elementRootName,collapsedImage,collapsedAltText){
  var elm = getElementObject(elementRootName + '_Tog');
  var img = getElementObject(elementRootName + '_IMG'); 
  var collapseState =  getElementObject(elementRootName + '_ContentState'); 
	
	//check to make sure we have a valid element 
	if(!elm){return};
	
  //If image exists then set proper image state and alt text
	if(img){
	  img.src = collapsedImage;
	  if(collapsedAltText.length > 0){
	    var alt = collapsedAltText;
	    img.setAttribute("alt",alt);
	  }
	}
	
	//set the display 
	//elm.style.display = 'none'
	//hideDIV(elm.id);
	collapseDIV(elm.id);
	
	//set the state value for postback
	collapseState.value = collapsePanelContentState_Closed;
}

function OpenCollapsePanel(elementRootName,expandedImage,expandedAltText){
  var elm = getElementObject(elementRootName + '_Tog');
  var img = getElementObject(elementRootName + '_IMG'); 
  var collapseState =  getElementObject(elementRootName + '_ContentState'); 
	
	//check to make sure we have a valid element 
	if(!elm){return};
	
  //If image exists then set proper image state and alt text
	if(img){
	  img.src = expandedImage;
	  if(expandedAltText.length > 0){
	    var alt = expandedAltText;
	    img.setAttribute("alt",alt);
	  }
	}

	//set the display 
	//elm.style.display = 'block';
	//showDIV(elm.id);
  expandDIV(elm.id);

	//alert(elm.style.display);
	
	//set the state value for postback
	collapseState.value = collapsePanelContentState_Opened;
}


/*
original code
function ToggleCollapsePanel(elementRootName,collapsedImage,expandedImage,collapsedAltText,expandedAltText) {
  //gather elements into working variables
  var elm = getElementObject(elementRootName + '_Tog'); 
  var img = getElementObject(elementRootName + '_IMG'); 
  var collapseState =  getElementObject(elementRootName + '_ContentState'); 
	
	//check to make sure we have a valid element 
	if(!elm){return};
	
  //If image exists then set proper image state and alt text
	if(img){
	  img.src = (img.src.indexOf(collapsedImage)!=-1) ? expandedImage : collapsedImage;
	  if(collapsedAltText.length > 0 && expandedAltText.length > 0){
	    var alt = (img.src.indexOf(collapsedImage)!=-1) ? collapsedAltText : expandedAltText;
	    img.setAttribute("alt",alt);
	  }
	}
	
	//set the display 
	elm.style.display = (elm.style.display == 'block') ? 'none' : 'block';
	
	//set the state value for postback
	collapseState.value = (elm.style.display == 'block') ? collapsePanelContentState_Opened : collapsePanelContentState_Closed;
}
*/