/*
<!---
// ****************************************************************************************** //

CREATED BY: David Wilf
MODULE:
DESCRIPTION: Contains functionality that controls dynamic displays in the gui

INCLUDED TEMPLATES:

COPYRIGHT: 

$Workfile$
$Archive$
$Revision$
$Modtime$

$Log$

// ****************************************************************************************** //
--->  
*/ 
   
   
   
   
// Precondition:
//	toggleObj = object to have display status changed

// Postcondition:
//	if toggleObj is visible it will become invisible else it will become visible		

function toggleDisplay(toggleObj)
{ 
																																	
	var displayStatus = toggleObj.style.display;
	
		if(displayStatus == "none")
		toggleObj.style.display = '';
			else
			toggleObj.style.display = 'none';	  

}	   



//**********************************************************************************************************************

// Precondition:
// pkVal = Primary key value used at the end of the new row to be displayed or 
// hidden and at the end of the link to toggle between plus and minus symbols.

// Postcondition:
// A function is called to display or hide the lower level rows depending on the clicked objects class name.
 
function activateLevel(pkVal)
{
	// Get the class name of the object clicked
	var className = "pK" + pkVal + ".className;";
	var className = eval(className);	
		
					
		// Open of close levels depending on if open or not
		if(className=='minus')
		closeNextLevel(pkVal);
			else
			openNextLevel(pkVal);	
									
}

// *********************************************************************************************

// Precondition:
// pkVal = Primary key value used at the end of the new row to be displayed or 
// hidden and at the end of the link to toggle between plus and minus symbols.

// Postcondition:
// The lower level rows are displayed and the plus sign of the object clicked is changed to minus with it's class.

function openNextLevel(pkVal)
{

		
		// Open next level
		var displayNextLevel = "newLevel" + pkVal + ".style.display='';";
		eval(displayNextLevel)
			
		// Change plus signs on lowest level to minus signs
		var changeToMinusSignStr = "pK" + pkVal + ".innerHTML='<img src=OrgDisplay/Graphics/minus.gif border=0>'";		
		eval(changeToMinusSignStr);		
			
		// Change class name to minus		
		var changeToMinusSignClass = "pK" + pkVal + ".className='minus';";
		eval(changeToMinusSignClass);		

}


// *********************************************************************************************

// Precondition:
// pkVal = Primary key value used at the end of the new row to be displayed or 
// hidden and at the end of the link to toggle between plus and minus symbols.

// Postcondition:
// The lower level rows are hidden and the minus sign of the object clicked is changed to plus with it's class.

function closeNextLevel(pkVal)
{

		// Open next level
		var displayNextLevel = "newLevel" + pkVal + ".style.display='none';";
		eval(displayNextLevel);				
			
		// Change plus signs on lowest level to minus signs
		var changeToMinusSignStr = "pK" + pkVal + ".innerHTML='<img src=OrgDisplay/Graphics/plus.gif border=0>'";		
		eval(changeToMinusSignStr);		
				
		// Change class name to plus
		var changeToMinusSignClass = "pK" + pkVal + ".className='plus';";
		eval(changeToMinusSignClass);				

}

//**********************************************************************************************************************

// Precondition:
// pkVal = Primary key value used at the end of the new row to be displayed or 
// hidden and at the end of the link to toggle between plus and minus symbols.

// Postcondition:
// A function is called to display or hide the lower level rows depending on the clicked objects class name.

function sumActivateLevel(pkVal)
{
//alert(pkVal);
	// Get the class name of the object clicked
	var className = "sumpK" + pkVal + ".className;";
	var className = eval(className);	
		
					
		// Open of close levels depending on if open or not
		if(className=='minus')
		sumCloseNextLevel(pkVal);
			else
		sumOpenNextLevel(pkVal);	
									
}

// *********************************************************************************************

// Precondition:
// pkVal = Primary key value used at the end of the new row to be displayed or 
// hidden and at the end of the link to toggle between plus and minus symbols.

// Postcondition:
// The lower level rows are displayed and the plus sign of the object clicked is changed to minus with it's class.

function sumOpenNextLevel(pkVal)
{

	var TotalChildren=eval(pkVal+"Children");	
		// Open next level
		for(i=0;i<=TotalChildren;i++)
		{
		var displayNextLevel = "sum" +pkVal+ i + ".style.display='';";
		eval(displayNextLevel);
		}
			
		// Change plus signs on lowest level to minus signs
		var changeToMinusSignStr = "sumpK" + pkVal + ".innerHTML='(hide)'";		
		eval(changeToMinusSignStr);		
			
		// Change class name to minus		
		var changeToMinusSignClass = "sumpK" + pkVal + ".className='minus';";
		eval(changeToMinusSignClass);		

}


// *********************************************************************************************

// Precondition:
// pkVal = Primary key value used at the end of the new row to be displayed or 
// hidden and at the end of the link to toggle between plus and minus symbols.

// Postcondition:
// The lower level rows are hidden and the minus sign of the object clicked is changed to plus with it's class.

function sumCloseNextLevel(pkVal)
{

		// Open next level
		var TotalChildren=eval(pkVal+"Children");	
		for(i=0;i<=TotalChildren;i++)
		{
		var displayNextLevel = "sum" + pkVal+i + ".style.display='none';";
		eval(displayNextLevel);	
		}			
			
		// Change plus signs on lowest level to minus signs
		var changeToMinusSignStr = "sumpK" + pkVal + ".innerHTML='(View)'";		
		eval(changeToMinusSignStr);		
				
		// Change class name to plus
		var changeToMinusSignClass = "sumpK" + pkVal + ".className='plus';";
		eval(changeToMinusSignClass);				

}


//**********************************************************************************************************************

// Precondition:
// pkVal = Primary key value used at the end of the new row to be displayed or 
// hidden and at the end of the link to toggle between plus and minus symbols.

// Postcondition:
// A function is called to display or hide the lower level rows depending on the clicked objects class name.

function orgDetailActivateLevel(pkVal,orgDetail)
{
//alert(pkVal);
	// Get the class name of the object clicked
	var className = orgDetail+"pK" + pkVal + ".className;";
	var className = eval(className);	
		
					
		// Open of close levels depending on if open or not
		if(className=='minus')
		orgDetailCloseNextLevel(pkVal,orgDetail);
			else
		orgDetailOpenNextLevel(pkVal,orgDetail);	
									
}

// *********************************************************************************************

// Precondition:
// pkVal = Primary key value used at the end of the new row to be displayed or 
// hidden and at the end of the link to toggle between plus and minus symbols.

// Postcondition:
// The lower level rows are displayed and the plus sign of the object clicked is changed to minus with it's class.

function orgDetailOpenNextLevel(pkVal,orgDetail)
{

	var TotalChildren=eval(pkVal+"Children");	
		// Open next level
		for(i=0;i<=TotalChildren;i++)
		{
		var displayNextLevel = orgDetail +pkVal+ i + ".style.display='';";
		eval(displayNextLevel);
		}
			
		// Change plus signs on lowest level to minus signs
		var changeToMinusSignStr = orgDetail+"pK" + pkVal + ".innerHTML='(hide)'";		
		eval(changeToMinusSignStr);		
			
		// Change class name to minus		
		var changeToMinusSignClass = orgDetail+"pK" + pkVal + ".className='minus';";
		eval(changeToMinusSignClass);		

}


// *********************************************************************************************

// Precondition:
// pkVal = Primary key value used at the end of the new row to be displayed or 
// hidden and at the end of the link to toggle between plus and minus symbols.

// Postcondition:
// The lower level rows are hidden and the minus sign of the object clicked is changed to plus with it's class.

function orgDetailCloseNextLevel(pkVal,orgDetail)
{

		// Open next level
		var TotalChildren=eval(pkVal+"Children");	
		for(i=0;i<=TotalChildren;i++)
		{
		var displayNextLevel = orgDetail + pkVal+i + ".style.display='none';";
		eval(displayNextLevel);	
		}			
			
		// Change plus signs on lowest level to minus signs
		var changeToMinusSignStr = orgDetail+"pK" + pkVal + ".innerHTML='(View)'";		
		eval(changeToMinusSignStr);		
				
		// Change class name to plus
		var changeToMinusSignClass = orgDetail+"pK" + pkVal + ".className='plus';";
		eval(changeToMinusSignClass);				

}



// *********************************************************************************************

// Precondition:
// selectedTab = help tab selected

// Postcondition:
// Sets the correct active or inactive classes for when the mouse is over object	

function displayHelpTabRollover(selectedTab)
{
	switch(selectedTab)
	{
		case "contentHelp" 	: 
		contentHelp.className="activeTabLink";
		indexHelp.className="inactiveTabLink";
		searchHelp.className="inactiveTabLink";
		glossHelp.className="inactiveTabLink";
		break;
		
		case "indexHelp"	:
		contentHelp.className="inactiveTabLink";
		indexHelp.className="activeTabLink";
		searchHelp.className="inactiveTabLink";
		glossHelp.className="inactiveTabLink";
		break;
		
		case "searchHelp"	:
		contentHelp.className="inactiveTabLink";
		indexHelp.className="inactiveTabLink";
		searchHelp.className="activeTabLink";
		glossHelp.className="inactiveTabLink";
		break;		
		
		case "glossHelp"	:
		contentHelp.className="inactiveTabLink";
		indexHelp.className="inactiveTabLink";
		searchHelp.className="inactiveTabLink";
		glossHelp.className="activeTabLink";
		break;		
		
		default	:
		contentHelp.className="inactiveTabLink";
		indexHelp.className="inactiveTabLink";
		searchHelp.className="inactiveTabLink";
		glossHelp.className="inactiveTabLink";
		break;		
	}
}


// *********************************************************************************************

// Precondition:
// selectedTab = help tab selected

// Postcondition:
// Sets the correct active or inactive classes, hides all help screens then display help screen requested	

function displayActiveHelpTab(selectedTab)
{

 // Hide all help screens
 contentHelpInfo.style.display="none";
 indexData.style.display="none";
 glossData.style.display="none";
 searchData.style.display="none";


	switch(selectedTab)
	{
		case "contentHelp" 	: 
		// display help screen requested
		contentHelpInfo.style.display="";
		// Set active/deactive classes
		contentHelpTab.className="panelTopActiveTabs";
		indexHelpTab.className="panelTopInactiveTabs";
		searchHelpTab.className="panelTopInactiveTabs";
		glossHelpTab.className="panelTopInactiveTabs";
		break;
		
		case "indexHelp"	:
		// display help screen requested
		indexData.style.display="";
		// Set active/deactive classes
		contentHelpTab.className="panelTopInactiveTabs";
		indexHelpTab.className="panelTopActiveTabs";
		searchHelpTab.className="panelTopInactiveTabs";
		glossHelpTab.className="panelTopInactiveTabs";
		break;
		
		case "searchHelp"	:
		// display help screen requested
		searchData.style.display="";
		// Set active/deactive classes
		contentHelpTab.className="panelTopInactiveTabs";
		indexHelpTab.className="panelTopInactiveTabs";
		searchHelpTab.className="panelTopActiveTabs";
		glossHelpTab.className="panelTopInactiveTabs";
		break;		
		
		case "glossHelp"	:
		// display help screen requested
		glossData.style.display="";
		// Set active/deactive classes
		contentHelpTab.className="panelTopInactiveTabs";
		indexHelpTab.className="panelTopInactiveTabs";
		searchHelpTab.className="panelTopInactiveTabs";
		glossHelpTab.className="panelTopActiveTabs";
		break;		
	}
}

// *********************************************************************************************

// Precondition:
	// selectedObj = object user clicked

// Postcondition:
	// Selects all values in object if not already selected

var allPrevSelectedFlag = 0; // True if "All" was selected previously.

function selectAll(selectedObj)
{
                
        // Check if all values are already selected
        if(!allPrevSelectedFlag)   
        {              
        // Get amount of options
    	var Childer = selectedObj.children.length;  
        
        // Reduce amount by 1
    	Childer--;          
            
            // Loop through options and select
        	if (selectedObj.children.length >= 0)
        	{
        		for(i=0; i<=Childer; i++)
        		{
        			selectedObj.children[i].selected=true;
        		}
        	}        	
        // Mark previously selected
        allPrevSelectedFlag = 1;
    	}               
            else
            {    
            // Unselect first "All" option                    
            selectedObj.children[0].selected=false;      
            
            // Mark not previously selected
            allPrevSelectedFlag = 0;
            }
    	
	
}


//**********************************************************************************************************************

// Precondition:
	//	selectedRow = object to have display status changed
	//	otherRow = Other object not changing except for height
	// 	clickedObj = plus/minus image clicked

// Postcondition:
	//	if toggleObj is visible it will become invisible else it will become visible and the otherRow obj's height is adjusted		

function toggleDisplayFormat(selectedRow,otherRow,clickedObj)
	{ 
					
	var selectedDisplayStatus = selectedRow.style.display;																				
	var otherDisplayStatus = otherRow.style.display;
	
		// If both are to be visible
		if(selectedDisplayStatus == "none" && otherDisplayStatus == "")
		{
		selectedRow.style.display = '';	
		clickedObj.src='Graphics/minus.gif'
		selectedRow.style.height = '200px';
		otherRow.style.height = '200px';
		}
			// If only selected to be visible
			else if(selectedDisplayStatus == "none" && otherDisplayStatus == "none")
			{
			selectedRow.style.display = '';		 
			clickedObj.src='Graphics/minus.gif'
			selectedRow.style.height = '400px';		 
			}
				// If selected to be hidden and other to be visible
				else if(selectedDisplayStatus == "" && otherDisplayStatus == "") 
				{ 
				selectedRow.style.display = 'none';	
				clickedObj.src='Graphics/plus.gif' 
				otherRow.style.height = '400px';
				}
		
					// If both to be hidden
					else if(selectedDisplayStatus == "" && otherDisplayStatus == "none")
					{
					selectedRow.style.display = 'none';
					clickedObj.src='Graphics/plus.gif'
					}
				  

	}	   


//**********************************************************************************************************************

// Precondition:
	//	commentRow = object to have display status changed
	//	bugLayer = object to be set at max height
	// 	changeRequestsLayer = object to be hidden
	//  otherImageLink = plus/minus image from other category

// Postcondition:
	//	if toggleObj is visible it will become invisible else it will become visible and the otherRow obj's height is adjusted		

function toggleCommentDisplay(commentRow,selectedLayer,otherLayer,otherImageLink)
	{ 


		var displayStatus = commentRow.style.display;
	
		if(displayStatus == "none") 
		{
		// Adjust height
		selectedLayer.style.height = '400px';
		otherLayer.style.display='none';
		otherImageLink.src='Graphics/plus.gif';
		commentRow.style.display = '';
		}
			else
			commentRow.style.display = 'none';	
					  
	}	   

	
// ****************************************************************************************** //


// Precondition
	// User requested a different view/form on main page
	
// Postcondition
	// The requested view/form is displayed
	
function changeDisplay(displayObj,displayFieldObj)
	{
		// If user requests to update information
		if(displayObj == "updateInfo")
		{
		document.updateInfo.submit();
		return 1;		
		}
	
	
	// Hide all
	postedDisplay.style.display="none";
	bugForm.style.display="none";
	changeForm.style.display="none";
	knownIssuesForm.style.display="none";
	bugFixesForm.style.display="none";
	newUpdatedForm.style.display="none";
	sysAdmin.style.display="none";
			
	// Display selected
	displayObj.style.display="";
	
	// Focus on selected first field if applicaable
	displayFieldObj.focus();	
	
	
	
	}


// ****************************************************************************************** //

// Precondition
	// Admin function has been selected
	// adminfunction = Selected Admin function
	
// Postcondition
	// The requested view/form is displayed
	
 	
var adminFieldSelected = "";	
	
function displayAdminFields(adminfunction)
{
	
	// Hide all rows
	projectSelectRow.style.display='none';
	enterVersionRow.style.display='none';
	deactivateProjectRow.style.display='none';
	newProjectRow.style.display='none';
	userRow.style.display='none';
	userRowAdmin.style.display='none';
	saveRow.style.display='none';
	prevVersionInfoRow.style.display='none';
	
	
		switch(adminfunction)
		{
		case "1" : // Add Project
		newProjectRow.style.display='';
		enterVersionRow.style.display='';
		saveRow.style.display='';
		break;
			
		case "2" : // Add Version to Project
		projectSelectRow.style.display='';
		enterVersionRow.style.display='';	
		prevVersionInfoRow.style.display='';
		saveRow.style.display='';
		break;
		
		case "3" : //Deactivate Project
		projectSelectRow.style.display='';
		deactivateProjectRow.style.display='';
		break;
		
		case "4" : // Set User Permissions
		userRow.style.display='';
		userRowAdmin.style.display='';
		break;				
		}
	
}
 

/*
<cfselect name="adminFunction" class="selectField" onChange="displayAdminFields(this.value);">
<option value="-1" selected="selected">- Select One -</option>
<option value="1">Add Project</option>
<option value="2">Add Version to Project</option>
<option value="3">Deactivate Project</option>
<option value="4">Set User Permissions</option>*/







