/*
	Usage:
		Control the div layer to show or hidden when click the button
	parameters:
		textDivId:			text of div
		showTextContent:	text of button's show text
							eg. 'See verified information'
		hiddenTextContent:  text of button's hidden text					
							eg. 'Hide verified information'
		collapseMenuId:  	id of the div layer	
		innerHTMLDivValue:  innerHTML of the div layer
	Modified Date:	2007-11-28 by Tiger Guo
*/
function expandCollapsePanelChangeText(textDivId, showTextContent,hiddenTextContent,collapseMenuId,innerHTMLDivValue) {	
    var textDivObj = document.getElementById(textDivId);  
    if (textDivObj.innerHTML.indexOf(showTextContent) != -1) {        
        textDivObj.innerHTML = hiddenTextContent;
        document.getElementById(collapseMenuId).innerHTML=innerHTMLDivValue;
    } else {       
        textDivObj.innerHTML = showTextContent;
        document.getElementById(collapseMenuId).innerHTML="";       
    }
}

/*
	Usage:
		Initialize the div layer when the page loaded
	Parameters:
		collapseMenuId:  	id of the div layer		
	Return value:
		innerHTML of the div layer	
	Modified Date:	2007-11-28 by Tiger Guo
*/
function getInnerHTML(collapseMenuId) {		
   var innerHTMLDIV = document.getElementById(collapseMenuId).innerHTML;
   document.getElementById(collapseMenuId).innerHTML="";
   return innerHTMLDIV;
}

/*
	Usage:
		Control the div layer to show or hidden when click the button
	parameters:
		btnObj	:			image button
		contextPath:		contextPath of current page
		collapseMenuId:  	id of the div layer	
		collapseMenuIdParent: hidden div
		innerHTMLDivValue:  innerHTML of the div layer
	Modified Date:	2007-12-07 by Tiger Guo
*/
function expandCollapsePanel(btnObj,collapseMenuIdParent,collapseMenuId,contextPath,innerHTMLDivValue) {           
   if (btnObj.src.indexOf("icon_expand.gif") != -1) {      
        btnObj.src = contextPath+"/images/sourcing/icon_collapse.gif";
        document.getElementById(collapseMenuId).innerHTML=innerHTMLDivValue;
        document.getElementById(collapseMenuIdParent).style.visibility = 'hidden';
    } else {    
        btnObj.src = contextPath+"/images/sourcing/icon_expand.gif";
        document.getElementById(collapseMenuId).innerHTML="";    
        document.getElementById(collapseMenuIdParent).style.visibility = 'visible';   
    }
}

/*
	Usage:
		get the innerHTML by code
	parameters:
		code	:			code
							eg.Category Code
		innerHTMLDIVArrayItem:		innerHTML Array	
	Return value:
		innerHTML accroding to the code		
	Modified Date:	2007-12-07 by Tiger Guo
*/
function getInnerHTMLByCode(code,innerHTMLDIVArrayParm){
	var innerHTML="";
	var length = innerHTMLDIVArrayParm.length;	
	for(var i=0;i<length;i++){		
		if(code==innerHTMLDIVArrayParm[i][0]) {	
			innerHTML = innerHTMLDIVArrayParm[i][1];
			return innerHTML;	
		}	
	}	
	return innerHTML;
}
	

/*
	Usage:
		hide&show div by code
	parameters:
		btnObj	:			button		
		code	:
		contextPath:	application path					
		innerHTMLDIVArrayItem:		innerHTML Array	
	Return value:
		innerHTML accroding to the code		
	Modified Date:	2007-12-07 by Tiger Guo
*/

function expandCollapsePanelByCode(btnObj,code,contextPath,innerHTMLDIVArrayItem){
	var innerHTMLDIV = getInnerHTMLByCode(code,innerHTMLDIVArrayItem);	
	expandCollapsePanel(btnObj, 'collapsePanelParent_'+code, 'collapsePanelByCode_'+code,contextPath,innerHTMLDIV)
}


//
/*
	Usage:
		init the div innerHTML Array when page first load
	parameters:						
		innerHTMLDIVArrayTemp:		innerHTML Array		
	Modified Date:	2007-12-07 by Tiger Guo
*/
function initInnerHTMLArray(innerHTMLDIVArrayTemp){
	var divs = document.getElementsByTagName("DIV");  
	var j=0; 
	for(var i=0;i<divs.length;i++)   
	  {   
	  	  var id=divs[i].id;			  	  	  	
	      if(id.indexOf("collapsePanelByCode_")!=-1){		
		      innerHTMLDIVArrayTemp[j] = new Array();
			  innerHTMLDIVArrayTemp[j][0] = id.substring("collapsePanelByCode_".length,id.length);	
			  var innerHTML = getInnerHTML(id);
			  innerHTMLDIVArrayTemp[j][1] = innerHTML; 
			  j++;
	      }else{
	      	continue;
	      }
	  }
}	
