// Drop Down Menu JavaScript Document

//rewrite content and reposition margin-left value

var subMenu;
var childMenu;
var timer;
//var secs;

// Sets up the initialization parameters of the menu system
function Init_Menu()
{
	//alert("init");
	// the amount of seconds to wait til the menus are hidden
	//secs = pSECS;
	// clear the timer
	resetTimer();
	// assign 
	subMenu = document.getElementById('subNav');
	//childMenu = document.getElementById('childNav');
	// clear any data
	subMenu.innerHTML = '';
	//childMenu.innerHTML = '';
	// hide the sub menu layers
	hideAllMenus();
}

// HANDLES SUBMENUS
function ME_Over(pTYPE, pXPOS, pYPOS)
{
	//alert("ME_Over");
	// first hide all
	hideAllMenus();
	// detemine what menu we are supposed to display
	switch(pTYPE)
	{
	case 'program':
			positionMenu(subMenu,pXPOS,pYPOS);
			subMenu.innerHTML = ''
				+ '<a href="about.php" onmouseover="ME_SubOver();" onmouseout="ME_Out();">About HSWC</a>'
				+ '<a href="mission.php" onmouseover="ME_SubOver();" onmouseout="ME_Out();">Mission</a>'
				+ '<a href="locations.php" onmouseover="ME_SubOver();" onmouseout="ME_Out();">Locations</a>';
			showMenu(subMenu);
		break;
				
		case 'services':
			positionMenu(subMenu,pXPOS,pYPOS);
			subMenu.innerHTML = ''
				+ '<a href="education.php" onmouseover="ME_SubOver();" onmouseout="ME_Out();">Education</a>'
				+ '<a href="family.php" onmouseover="ME_SubOver();" onmouseout="ME_Out();">Family Services</a>'
				+ '<a href="developmental.php" onmouseover="ME_SubOver();" onmouseout="ME_Out();">Developmental Services</a>'
				+ '<a href="health.php" onmouseover="ME_SubOver();" onmouseout="ME_Out();">Health &amp; Nutrition</a>'
				+ '<a href="transportation.php" onmouseover="ME_SubOver();" onmouseout="ME_Out();">Transportation</a>';
			showMenu(subMenu);
		break;
		
		case 'hr':
			positionMenu(subMenu,pXPOS,pYPOS);
			subMenu.innerHTML = ''
				+ '<a href="jobs.php" onmouseover="ME_SubOver();" onmouseout="ME_Out();">Job Openings</a>'
				+ '<a href="internships.php" onmouseover="ME_SubOver();" onmouseout="ME_Out();">Internships</a>'
				+ '<a href="benefits.php" onmouseover="ME_SubOver();" onmouseout="ME_Out();">HSWC Benefits</a>';
			showMenu(subMenu);
		break;
		
		case 'community':
			positionMenu(subMenu,pXPOS,pYPOS);
			subMenu.innerHTML = ''
				+ '<a href="resources.php" onmouseover="ME_SubOver();" onmouseout="ME_Out();">Resources</a>'
				+ '<a href="partnerships.php" onmouseover="ME_SubOver();" onmouseout="ME_Out();">Partnerships</a>'
				+ '<a href="news.php" onmouseover="ME_SubOver();" onmouseout="ME_Out();">News</a>'
				+ '<a href="volunteer.php" onmouseover="ME_SubOver();" onmouseout="ME_Out();">Volunteer</a>';
			showMenu(subMenu);
		break;
		
		default:
			// if the menu has no children then hide any that are displayed
			//hideChildMenus();
		break;
	}
	resetTimer();
}

// HANDLES CHILD MENUS
function ME_SubOver(pTYPE, pXPOS, pYPOS)
{
	resetTimer();
	// detemine what menu we are supposed to display
	/*switch(pTYPE)
	{
		case 'child_menu':
			positionMenu(childMenu,pXPOS,pYPOS);
			//childMenu.innerHTML = ''
			//showMenu(childMenu);
		break;

		default:
			// if the menu has no children then hide any that are currently displayed
			//hideChildMenus();
		break;
	}*/
}

function ME_Out()
{
	//alert('ME_Out');
	timer = self.setTimeout('hideAllMenus()', 1000);
}

function showMenu(pID)
{
	// reset the timer
	resetTimer();
	pID.style.visibility = 'visible';
}

function hideAllMenus()
{
	// check the menus visible property and set accordingly
	//alert('hide');
	subMenu.style.visibility = 'hidden';
	//if(childMenu.style.visibility == 'visible') childMenu.style.visibility = 'hidden';
}
/*
function hideChildMenus()
{
	if(childMenu.style.visibility == 'visible') childMenu.style.visibility = 'hidden';
	resetTimer();
}
*/
function resetTimer()
{
	// clear timer
	window.clearTimeout(timer);
	timer=0;
}

function positionMenu(pID, pXPOS, pYPOS)
{
	pID.style.marginLeft = pXPOS+"px";
	pID.style.marginTop = pYPOS+"px";
}