/*page_nav_meth.js contains the variables and functions that control the twisty menus and behaviors. This is where new sub 
categories must be included. This must be kept up to date for the twisty functionality to work properly. This file also 
contains the last_update() function that can be used to alert users of the history of maintenance on a page.*/

/*These array elements correspond to the divisions and ids in the html page. Because this page is so large, place a line 
break between different pages on the methodology site.*/
var subs_array = new Array(
	'definition_startup','definition_startup_sub1','project_execution', 
	'project_execution_sub1', 'post_project', 'post_project_sub1', 'current_projects', 'deliverables', 'tips',

	'infra_meth','env_templates', 'env_examples', 'env_tools', 'estimate', 'est_templates',
	'estimate_ex', 'est_tools',  'FG_meth', 'RA_templates', 'RA_examples', 'RA_tools', 
	'design_meth', 'design_templates', 'design_examples', 'design_tools', 'dev_test', 'dev_templates', 
	'dev_examples', 'dev_tools', 'sys_test','sys_templates','sys_examples', 'sys_tools', 'release_meth', 
	'release_templates','release_examples', 'release_tools'
	);

var level_control = new Array(subs_array.length);

if (document.images)
{
 	plus = new Image();
	plus.src = "Images/plus.gif";
	minus = new Image(); 
	minus.src ="Images/minus.gif";
}//end if(document.images)


//updates the twisty marker and displays the submenus
function displaysubs(the_sub)
{
	if (document.getElementById(the_sub).style.display == "")
	{
		document.getElementById(the_sub).style.display = "none"
	}//end if()
	else
	{
		document.getElementById(the_sub).style.display = "";
	}//end else

	// Update the control index for this segment
	var index = update_control(the_sub);
		
  //  document.getElementById(the_sub).style.backgroundColor = "EEEEEE";

	// Exit if not found
	if (index == -1)
		return;

	// if 0, then make it 1 and change to minus
	if (level_control[index] == 0)
	{
		document.getElementById(the_sub+"_pic").src = minus.src;
		level_control[index] = 1;
		return;
	}//end if (level_control)
		
	// if 1, make it 0 and change to plus
	else if(level_control[index] == 1)
	{
		document.getElementById(the_sub+"_pic").src = plus.src;
		level_control[index] = 0;
		return;
	}//end else if
	else
	{
		document.getElementById(the_sub+"_pic").src = plus.src;
		level_control[index] = 0;
		return;
	}//end else
		
	return;
}//end function displaysubs()

//resets teh twisty markers on the page
function initialize()
{
	//when the page loads, set the level_control array entry for each id to 0, to indicate that the corresponding id
	//displays the + icon
	for (var i=0; i<subs_array.length; i++)
	{
		level_control[i] = 0;
	}//end for (var i=0)

	return;
}//end function initialize()

// searches for the correct index of the sign controller
function update_control(section_name)
{
	var counter = 0;

	// Loops through the array to find the correct index
	while ((counter < level_control.length) && (subs_array[counter] != section_name))
	{
		counter++;
	}//end while(())
	
	// Set to -1 if the header is not found;
	if (counter >= level_control.length)
		counter = -1;
	return counter;
}//end function update_control()
	
//displays all divisions on a page


