/* globals */
menuTimer = 0;
menuIds = new Array('lrnMn', 'mvMn', 'fndMn', 'whtNew', 'joinMn');
initMn();



/* Purpose: sets up 'learn more' menu
 * Returns: obj
 */
function lrnMore()
{
	return obj = new Array( new Array('Who We Are', 'content.php?sect=whoweare'), new Array('Board of Directors', 'content.php?sect=leadteam'), new Array('FAQ', 'content.php?sect=faq'), new Array('Contact Us', 'content.php?sect=contact') );
}

/* Purpose: sets up 'make your move' menu
 * Returns: obj
 */
function makeMove()
{
	return obj = new Array(new Array('How to Post a Message','content.php?sect=howtopost'),'What to Study', 'Talk to',new Array('Start New Discussion','/forum/viewforum.php?f=65'));
}

/* Purpose: sets up 'find mentor' menu
 * Returns: obj
 */
function findMentor()
{
	return obj = new Array( new Array('Business', 'mentor.php?sect=mentorbus'), new Array('Engineering', 'mentor.php?sect=mentoreng'), new Array('Social Sciences', 'mentor.php?sect=mentorsoc'), new Array('Technology', 'mentor.php?sect=mentortech') );
}

/* Purpose: sets up 'whats new' menu
 * Returns: obj
 */
function whatsNew()
{
	return obj = new Array(new Array('News', 'whatsnew.php?sect=news'), new Array('Media', 'whatsnew.php?sect=media'));
}

/* Purpose: sets up 'join us' menu
 * Returns: obj
 */
function joinUs()
{
	return obj = new Array(new Array('Our Friends', 'content.php?sect=ourfriends'),new Array('Bouge', 'content.php?sect=join'));
}




/* Purpose: shows the selected menu
 * Arguements: obj
 * 		obj - refers to this from the calling prog.
 *          sets the DIV to visible
 */
function showMn(obj)
{
	hideAll(menuIds);
	document.getElementById(obj).style.visibility='visible';
}

function hideAll(mn)
{
	for(var i=0; i<mn.length; i++){
		document.getElementById(mn[i]).style.visibility='hidden';
	}
}

/*
 * Purpose: Routine that closes the menu
 */
function closeMn(obj)
{
	box = document.getElementById(obj);
	menuTimer = setTimeout("hideMenu(box, 'subm')", 400);
}

/*
 * Purpose: Called by closeMenu function, sets the div obj
 *          to hidden
 * Arguements: m, subm
 * 		m:	main menu
 *		s:  sub menu
 */
function hideMenu(m, s)
{
	
	m.style.visibility = "hidden";
	sobj = document.getElementById(s);
	sobj.style.visibility = "hidden";    
}


/*
 * Purpose: Clears the timer so that the hideMenu function
 *          will not take into affect
 */
function clrT() 
{
	clearTimeout(menuTimer);
}

function openPage(pg)
{
	window.open(pg, '_self');
}


/* Purpose: creats the drop down menus
 */
function initMn()
{
	var mnStr = "";
	var tmpArr = lrnMore();
	for(i=0; i<tmpArr.length; i++){
		mnStr += "<DIV CLASS='mnShdw'><DIV CLASS='mnItems' onMouseOver='swapBGCol(this, \"CCCCCC\"); clrT(); return false' onMouseOut='swapBGCol(this, \"D4E4FF\"); closeMn(\"lrnMn\"); return false;' onClick='openPage(\""+tmpArr[i][1]+"\")'>"+tmpArr[i][0]+"</DIV></DIV>";
	}
	box = document.getElementById('lrnMn');
	box.innerHTML = mnStr;
	box.style.visibility = "hidden";
	
	mnStr = "";
	var tmpArr = makeMove();
	for(i=0; i<tmpArr.length; i++){
		
		if(tmpArr[i].length == 2){
			
			mnStr += "<DIV CLASS='mnShdw'><DIV CLASS='mnItems' onMouseOver='swapBGCol(this, \"CCCCCC\"); clrT(); return false' onMouseOut='swapBGCol(this, \"D4E4FF\"); closeMn(\"lrnMn\"); return false;' onClick='openPage(\""+tmpArr[i][1]+"\")'>"+tmpArr[i][0]+"</DIV></DIV>";
		}else{
			mnStr += "<DIV CLASS='mnShdw'><DIV ID='mkMove"+i+"' CLASS='mnItems' onMouseOver='swapBGCol(this, \"CCCCCC\"); clrT(); smenu(this, "+i+"); return false' onMouseOut='swapBGCol(this, \"D4E4FF\"); closeMn(\"mvMn\"); return false;'><IMG SRC='img/arrow.gif' ALIGN='right'>"+tmpArr[i]+"</DIV></DIV>";
		}
	}
	box = document.getElementById('mvMn');
	box.innerHTML = mnStr;
	box.style.visibility = "hidden";
	
	mnStr = "";
	var tmpArr = findMentor();
	for(i=0; i<tmpArr.length; i++){
		mnStr += "<DIV CLASS='mnShdw'><DIV CLASS='mnItems' onMouseOver='swapBGCol(this, \"CCCCCC\"); clrT(); return false' onMouseOut='swapBGCol(this, \"D4E4FF\"); closeMn(\"fndMn\"); return false;' onClick='openPage(\""+tmpArr[i][1]+"\")'>"+tmpArr[i][0]+"</DIV></DIV>";
	}
	box = document.getElementById('fndMn');
	box.innerHTML = mnStr;
	box.style.visibility = "hidden";
	
	mnStr = "";
	var tmpArr = whatsNew();
	for(i=0; i<tmpArr.length; i++){
		mnStr += "<DIV CLASS='mnShdw'><DIV CLASS='mnItems' onMouseOver='swapBGCol(this, \"CCCCCC\"); clrT(); return false' onMouseOut='swapBGCol(this, \"D4E4FF\"); closeMn(\"whtNew\"); return false;' onClick='openPage(\""+tmpArr[i][1]+"\")'>"+tmpArr[i][0]+"</DIV></DIV>";
	}
	box = document.getElementById('whtNew');
	box.innerHTML = mnStr;
	box.style.visibility = "hidden";
	
	mnStr = "";
	var tmpArr = joinUs();
	for(i=0; i<tmpArr.length; i++){
		mnStr += "<DIV CLASS='mnShdw'><DIV CLASS='mnItems' onMouseOver='swapBGCol(this, \"CCCCCC\"); clrT(); return false' onMouseOut='swapBGCol(this, \"D4E4FF\"); closeMn(\"joinMn\"); return false;' onClick='openPage(\""+tmpArr[i][1]+"\")'>"+tmpArr[i][0]+"</DIV></DIV>";
	}
	box = document.getElementById('joinMn');
	box.innerHTML = mnStr;
	box.style.visibility = "hidden";
}


/* Purpose: sets up the submenu
 * Arguments: obj, s
 * 		obj: refers to this from the calling obj
 *		s: the id of the div that the submenu will be contained
 */
function smenu(obj, sect){
	var smStr = "";
	
	if( sect == 0 )
		var smArr = new Array( new Array('Business', 'whattostudy.php?sect=bus'), new Array('Engineering', 'whattostudy.php?sect=eng'), new Array('Governance', 'whattostudy.php?sect=gov'), new Array('Technology', 'whattostudy.php?sect=tech') );
	else
		var smArr = new Array( new Array('Business', 'mentor.php?sect=mentorbus'), new Array('Engineering', 'mentor.php?sect=mentoreng'), new Array('Social Sciences', 'mentor.php?sect=mentorsoc'), new Array('Technology', 'mentor.php?sect=mentortech') );
	
	for(var i=0; i<smArr.length; i++){
		smStr += "<DIV CLASS='mnShdw'><DIV CLASS='smnItems' onMouseOver='swapBGCol(this, \"CCCCCC\"); clrT(); return false' onMouseOut='swapBGCol(this, \"D4E4FF\"); closeMn(\"mvMn\"); return false;' onClick='openPage(\""+smArr[i][1]+"\")'>"+smArr[i][0]+"</DIV></DIV>";
	}
	
	var sbox = document.getElementById('subm');
			sbox.innerHTML = smStr;
	
	if(obj.id == 'mkMove0')
		sbox.style.top = document.getElementById('mvMn').offsetTop;
	else
		sbox.style.top = document.getElementById('mvMn').offsetTop + document.getElementById('mkMove1').offsetTop;
		
	sbox.style.left = document.getElementById('mvMn').offsetLeft + document.getElementById('mvMn').offsetWidth;
	sbox.style.visibility = "visible";
}
