// Updated by Accenture
// modified date : 30 june 2010
// Version 1.2
// Bugs from the FT environment has been fixed
// CR : Hide the Extra close all and Expand All button 

var PLUS_IMAGE = "/Style Library/Images/Agilent/plus.gif";
var MINUS_IMAGE = "/Style Library/Images/Agilent/minus.gif";

// Register the Div Tag
function RegisterSectionNew( listId, bOpen )
{
	var openFlag = 1;
	var imageName = listId + "Image";

	if( bOpen == null || bOpen == false || bOpen == 'false')
	{
		openFlag = 0;
		document.getElementById( listId ).style.display = "none";
		ChangeImage(imageName,  PLUS_IMAGE );
	}
	else
	{
		ChangeImage( imageName, MINUS_IMAGE );
	}
	navMenu[ navMenu.length ] = new Array(listId, openFlag);
}

// Hide expand and close all button when page contains the Content editor webpart with default groups and its childs
function HideExpandandCloseAll()
{
   var objExpandAll=null;
   var objCloseAll=null;
    if(expclsBtnExists==true)
    {
        objExpandAll=document.getElementById('imgExpandAll');
        objCloseAll=document.getElementById('imgCloseAll');
        if(objExpandAll!=null && objCloseAll!=null)
        {
          objExpandAll.style.display='none';
          objCloseAll.style.display ='none';
        }
    }
}

//Opens the First group
function FirstItemOpenNew( listId, bOpen )
{
	var openFlag = 1;
	var imageName = listId + "Image";	
	if(expclsBtnExists==false)
	 {
		if(imageName=="listProdx501Image")
	    {
    		ChangeImage( imageName, MINUS_IMAGE );
		}	
        openMenuNew('listProdx501');
	    navMenu[ navMenu.length ] = new Array(listId, openFlag);
	}
	else
	{
	  if (openFirstTime==false)
        {   
            closeAllNew();
            openMenuNew('listProdx0');
            openFirstTime = true;
        }
	}
}
// Chagne the Image when user clicks on + or - symbol 
function ChangeImage (ImageName,FileName) {
document[ImageName].src = FileName;
}

function openMenuNew(strOpen)
{
	var ImageElement
	ImageElement = strOpen + "Image";
	 
	for (i=0; i<navMenu.length; i++)
	{ 
		if ((navMenu[i][0]==strOpen)&&(navMenu[i][1]==0))
		{
			// check the menu's state
			show(navMenu[i][0]);
			// show the menu, because it's not visible
		
			navMenu[i][1]=1;
			// set the flag indicating the menu state is now visible
			
			ChangeImage (ImageElement,MINUS_IMAGE); 
			// toggle image to minus sign
			
			break;
			// break out of the function, we've found our menu
		}
		else if ((navMenu[i][0]==strOpen)&&(navMenu[i][1]==1))
		{
			//check the menu's state
		
			hide(navMenu[i][0]);
			//hide the menu, because it's already open
		
			navMenu[i][1]=0;
			//set the flag indicating the menu state is hidden
			
			ChangeImage (ImageElement,PLUS_IMAGE); 
			// toggle image to plus sign
		
			break;
			// break out of the function, we've found our menu
		}
	}
}

// Open all groups
function openAllNew()
{
	for (i=0; i<navMenu.length; i++)
	{ 
		strOpen = navMenu[i][0]
		var ImageElement
		ImageElement = strOpen + "Image";
		if (navMenu[i][1]==0)
		{
			show(navMenu[i][0]);
			// show the menu, because it's not visible
			navMenu[i][1]=1;
			// set the flag indicating the menu state is now visible
			ChangeImage (ImageElement,MINUS_IMAGE); 
			// toggle image to minus sign
		}
	}
}

// Close al Groups
function closeAllNew()
{
	for (i=0; i<navMenu.length; i++)
	{ 
		strOpen = navMenu[i][0]
		
		var ImageElement
		ImageElement = strOpen + "Image";
		
		if (navMenu[i][1]==1)
		{
			hide(navMenu[i][0]);
			// hide the menu
			navMenu[i][1]=0;
			// set the flag indicating the menu state is now hidden
			
			ChangeImage (ImageElement,PLUS_IMAGE); 
			// toggle image to plus sign
		}
	}
}

function hide(str) {
x = document.getElementById(str);
x.style.display = 'none'; // hide the element
flagState = 0; // now it's off, keeping track of its state
}
function show(str) {
x = document.getElementById(str);
x.style.display = 'block'; // show the element
flagState = 1; // now it's on, keeping track of its state
}

/* not used */

function showHide(element) {
	if (document.getElementById) {
		// W3C standard
		var style2 = document.getElementById(element).style;
		style2.display = style2.display ? "" : "block";
	}
	else if (document.all) {
		// old MSIE versions
		var style2 = document.all[element].style;
		style2.display = style2.display ? "" : "block";
	}
	else if (document.layers) {
		// Netscape 4
		var style2 = document.layers[element].style;
		style2.display = style2.display ? "" : "block";
	}
}

