// JavaScript Document


//arrays to make the submenus

var postdocsSubMenu= new Array();
postdocsSubMenu[1]=new Array("postdocs_applying.html","Applying"); 
postdocsSubMenu[2]=new Array("postdocs_arriving.html","Arriving at Yale");
postdocsSubMenu[3]=new Array("postdocs_orientation.html","Orientation");
postdocsSubMenu[4]=new Array("postdocs_benefits.html","Benefits");
postdocsSubMenu[5]=new Array("postdocs_salary.html","Salary Guidelines and Taxes");
postdocsSubMenu[6]=new Array("postdocs_career.html","Career Development");
postdocsSubMenu[7]=new Array("postdocs_advisory.html","Postdoc Advisory Committee");
postdocsSubMenu[8]=new Array("postdocs_leaving.html","Leaving Yale");
postdocsSubMenu[9]=new Array("postdocs_blog.html","Online Discussions");
postdocsSubMenu[10]=new Array("postdocs_handbook.html","Handbook");
postdocsSubMenu[11]=new Array("postdocs_events.html","Current Events");

var facultySubMenu= new Array();
//facultySubMenu[1]=new Array("faculty.html","Faculty");

var administratorsSubMenu= new Array();
administratorsSubMenu[1]=new Array("administrators_ysm.html","YSM"); 
administratorsSubMenu[2]=new Array("administrators_central.html","Central"); 

var policiesSubMenu= new Array();
//policiesSubMenu[1]=new Array("policies.html","Policies");

var handbookSubMenu= new Array();
//handbookSubMenu[1]=new Array("handbook.html","Handbook");

var homeSubMenu= new Array();
//homeSubMenu[1]=new Array("home.html","Home");






//----------------------------------------------------------------------------------------------
//------------------DON"T CHANGE ANYTHING BELOW THIS LINE!! ------------------------------------
//----------------------------------------------------------------------------------------------


menulength = 6;

//array to make the main menu
var MenuItems= new Array(menulength+1);
MenuItems[1]=new Array("postdocs","Postdocs","y","postdocs.html"); 
MenuItems[2]=new Array("faculty","Faculty","","faculty.html"); 
MenuItems[3]=new Array("administrators","Administrators","y","administrators.html"); 
MenuItems[4]=new Array("policies","Policies","","policies.html");
MenuItems[5]=new Array("handbook","Handbook","","postdocs_handbook.html");  
MenuItems[6]=new Array("home","Home Page","","index.html");



//calculate offsets for menus
postdocsOffset = (21 * (postdocsSubMenu.length-1))+4;
facultyOffset = (21 * (facultySubMenu.length-1))+4;
administratorsOffset = (21 * (administratorsSubMenu.length-1))+4;
policiesOffset = (21 * (policiesSubMenu.length-1))+4;
handbookOffset = (21 * (handbookSubMenu.length-1))+4;
homeOffset = (21 * (homeSubMenu.length-1))+4;


function MakeMainMenu(thepage) {
	
	//alert(thepage);
	
	document.write('<table id="Table_01" width="193" border="0" cellpadding="0" cellspacing="0">');
	
	for (x=1; x<=menulength; x++) {
			
			//get spacer row heights
			if (thepage=="postdocs") {
				SpacerHeight = postdocsOffset;
			}
			if (thepage=="faculty") {
				SpacerHeight = facultyOffset;
			}
			if (thepage=="administrators") {
				SpacerHeight = administratorsOffset;
			}
			if (thepage=="policies") {
				SpacerHeight = policiesOffset;
			}
			if (thepage=="handbook") {
				SpacerHeight = handbookOffset;
			}
			if (thepage=="home") {
				SpacerHeight = homeOffset;
			}
		
			//set mouseimages
			mouseimage = "over";			
			//if (MenuItems[x][0]=="postdocs"&&postdocsOffset<0) {
				//mouseimage = "fixed";
			//}			
			//if (MenuItems[x][0]=="faculty"&facultyOffset<0) {
				//mouseimage = "fixed";
			//}			
			//if (MenuItems[x][0]=="administrators"&&administratorsOffset<0) {
				//mouseimage = "fixed";
			//}			
			//if (MenuItems[x][0]=="policies"&&policiesOffset<0) {
				//mouseimage = "fixed";
			//}
			//if (MenuItems[x][0]=="handbook"&&handbookOffset<0) {
				//mouseimage = "fixed";
			//}			
			//if (MenuItems[x][0]=="home"&&homeOffset<0) {
				//mouseimage = "fixed";
			//}
			
			if ((thepage!="home")||(MenuItems[x][0]!="home")) {
			
				document.write('<tr><td>');
				if ((MenuItems[x][2]!="y")) {
					mouseimage = "right";
				} else {
					if (thepage==MenuItems[x][0]) {
						mouseimage = "right";
					}
				}
				//if (thepage==MenuItems[x][0]) {
					//document.write('<a href="' + MenuItems[x][3] + '" onmouseover="hideAll3();return true;"><img name="' + MenuItems[x][0] + '" src="images/menu/' + MenuItems[x][0] + '-fixed.gif" width="193" height="26" border="0" alt="' + MenuItems[x][1] + '"></a>');
				//} else {				
					document.write('<a href="' + MenuItems[x][3] + '" onmouseover="changeImages(\'' + MenuItems[x][0] + '\', \'images/menu/' + MenuItems[x][0] + '-' + mouseimage + '.gif\');hideAll3();');
					if ((MenuItems[x][2]=="y")&&(thepage!=MenuItems[x][0])) {
						document.write('showObject(\'sub_' + MenuItems[x][0] + '\');');
					}
					document.write(' return true;" onmouseout="changeImages(\'' + MenuItems[x][0] + '\', \'images/menu/' + MenuItems[x][0] + '.gif\');hideAll(); return true;"><img name="' + MenuItems[x][0] + '" src="images/menu/' + MenuItems[x][0] + '.gif" width="193" height="26" border="0" alt="' + MenuItems[x][1] + '"></a>');
				//}
				
				document.write('</td></tr>');
				
				//add spacer row if thepage
				if (thepage==MenuItems[x][0]&&SpacerHeight>0) {
					document.write('<tr><td height="' + SpacerHeight + '">&nbsp;</td></tr>');
				}	
				
			}
	
	}
	
	//document.write('<tr><td height="1" bgcolor="#505050"></td></tr>');
	document.write('<tr><td><a href="#" onmouseover="hideAll3();return true;"><img src="images/spacer.gif" width="193" height="26" border="0" /></a></td></tr>');
	document.write('</table>');
	
}




function MakeSubMenus(thepage) {
	
	var TopOffset = 120;
		
	//make postdocs submenu
	document.write("<DIV ID='sub_postdocs' style='position:absolute; left:193px; top:" + TopOffset + "px; z-index:12; visibility:hidden;' onmouseover=\"changeImages('postdocs', 'images/menu/postdocs-over.gif');return true;\" onmouseout=\"changeImages('postdocs', 'images/menu/postdocs.gif');return true;\">");
	document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td bgcolor="#e5eff8" class="submenu">');
	for (i=1; i<postdocsSubMenu.length; ++i) {
  		document.write("<a href='" + postdocsSubMenu[i][0] + "'>" + postdocsSubMenu[i][1] + "</a><BR>")
	}
	document.write("</td></tr></table></DIV>");	
	
	//add additional offset for leftsub
	if (thepage=="postdocs"&&postdocsOffset>0) {
		TopOffset = TopOffset + postdocsOffset;
	}

	//make faculty submenu
	TopOffset = TopOffset + 26;
	document.write("<DIV ID='sub_faculty' style='position:absolute; left:193px; top:" + TopOffset + "px; z-index:12; visibility:hidden;' onmouseover=\"changeImages('faculty', 'images/menu/faculty-over.gif');return true;\" onmouseout=\"changeImages('faculty', 'images/menu/faculty.gif');return true;\">");
	document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td bgcolor="#e5eff8" class="submenu">');
	for (i=1; i<facultySubMenu.length; ++i) {
  		document.write("<a href='" + facultySubMenu[i][0] + "'>" + facultySubMenu[i][1] + "</a><BR>")
	}
	document.write("</td></tr></table></DIV>");
	
	//add additional offset for leftsub
	if (thepage=="faculty"&&facultyOffset>0) {
		TopOffset = TopOffset + facultyOffset;
	}

	//make administrators submenu
	TopOffset = TopOffset + 26;
	document.write("<DIV ID='sub_administrators' style='position:absolute; left:193px; top:" + TopOffset + "px; z-index:12; visibility:hidden;' onmouseover=\"changeImages('administrators', 'images/menu/administrators-over.gif');return true;\" onmouseout=\"changeImages('administrators', 'images/menu/administrators.gif');return true;\">");
	document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td bgcolor="#e5eff8" class="submenu">');
	for (i=1; i<administratorsSubMenu.length; ++i) {
  		document.write("<a href='" + administratorsSubMenu[i][0] + "'>" + administratorsSubMenu[i][1] + "</a><BR>")
	}
	document.write("</td></tr></table></DIV>");
	
	//add additional offset for leftsub
	if (thepage=="administrators"&&administratorsOffset>0) {
		TopOffset = TopOffset + administratorsOffset;
	}

	//make policies submenu
	TopOffset = TopOffset + 26;
	document.write("<DIV ID='sub_policies' style='position:absolute; left:193px; top:" + TopOffset + "px; z-index:12; visibility:hidden;' onmouseover=\"changeImages('policies', 'images/menu/policies-over.gif');return true;\" onmouseout=\"changeImages('policies', 'images/menu/policies.gif');return true;\">");
	document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td bgcolor="#e5eff8" class="submenu">');
	for (i=1; i<policiesSubMenu.length; ++i) {
  		document.write("<a href='" + policiesSubMenu[i][0] + "'>" + policiesSubMenu[i][1] + "</a><BR>")
	}
	document.write("</td></tr></table></DIV>");
	
	//add additional offset for leftsub
	if (thepage=="policies"&&policiesOffset>0) {
		TopOffset = TopOffset + policiesOffset;
	}

	//make handbook submenu
	TopOffset = TopOffset + 26;
	document.write("<DIV ID='sub_handbook' style='position:absolute; left:193px; top:" + TopOffset + "px; z-index:12; visibility:hidden;' onmouseover=\"changeImages('handbook', 'images/menu/handbook-over.gif');return true;\" onmouseout=\"changeImages('handbook', 'images/menu/handbook.gif');return true;\">");
	document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td bgcolor="#e5eff8" class="submenu">');
	for (i=1; i<handbookSubMenu.length; ++i) {
  		document.write("<a href='" + handbookSubMenu[i][0] + "'>" + handbookSubMenu[i][1] + "</a><BR>")
	}
	document.write("</td></tr></table></DIV>");
	
	//add additional offset for leftsub
	if (thepage=="handbook"&&handbookOffset>0) {
		TopOffset = TopOffset + handbookOffset;
	}

	//make home submenu
	TopOffset = TopOffset + 26;
	document.write("<DIV ID='sub_home' style='position:absolute; left:193px; top:" + TopOffset + "px; z-index:12; visibility:hidden;' onmouseover=\"changeImages('home', 'images/menu/home-over.gif');return true;\" onmouseout=\"changeImages('home', 'images/menu/home.gif');return true;\">");
	document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td bgcolor="#e5eff8" class="submenu">');
	for (i=1; i<homeSubMenu.length; ++i) {
  		document.write("<a href='" + homeSubMenu[i][0] + "'>" + homeSubMenu[i][1] + "</a><BR>")
	}
	document.write("</td></tr></table></DIV>");
	
	//add additional offset for leftsub
	if (thepage=="home"&&homeOffset>0) {
		TopOffset = TopOffset + homeOffset;
	}
	
}


function MakeLeftSubs(thepage) {
	
	var TopOffset = 146;

	//make postdocs leftsub
	if (thepage=="postdocs") {
		document.write("<DIV ID='leftsub_postdocs' style='position:absolute; left:9px; top:" + TopOffset + "px; z-index:14;'>");
		document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td class="leftsub" onmouseover="hideAll3();return true;">');
		for (i=1; i<postdocsSubMenu.length; ++i) {
			document.write("<a href='" + postdocsSubMenu[i][0] + "' onmouseover='hideAll3();return true;'>" + postdocsSubMenu[i][1] + "</a><BR>")
		}
		document.write("</td></tr></table></DIV>");	
	}

	//make faculty leftsub
	TopOffset = TopOffset + 26;
	if (thepage=="faculty") {
		document.write("<DIV ID='leftsub_faculty' style='position:absolute; left:9px; top:" + TopOffset + "px; z-index:14;'>");
		document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td class="leftsub" onmouseover="hideAll3();return true;">');
		for (i=1; i<facultySubMenu.length; ++i) {
			document.write("<a href='" + facultySubMenu[i][0] + "' onmouseover='hideAll3();return true;'>" + facultySubMenu[i][1] + "</a><BR>")
		}
		document.write("</td></tr></table></DIV>");	
	}

	//make administrators leftsub
	TopOffset = TopOffset + 26;
	if (thepage=="administrators") {
		document.write("<DIV ID='leftsub_administrators' style='position:absolute; left:9px; top:" + TopOffset + "px; z-index:14;'>");
		document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td class="leftsub" onmouseover="hideAll3();return true;">');
		for (i=1; i<administratorsSubMenu.length; ++i) {
			document.write("<a href='" + administratorsSubMenu[i][0] + "' onmouseover='hideAll3();return true;'>" + administratorsSubMenu[i][1] + "</a><BR>")
		}
		document.write("</td></tr></table></DIV>");	
	}

	//make policies leftsub
	TopOffset = TopOffset + 26;
	if (thepage=="policies") {
		document.write("<DIV ID='leftsub_policies' style='position:absolute; left:9px; top:" + TopOffset + "px; z-index:14;'>");
		document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td class="leftsub" onmouseover="hideAll3();return true;">');
		for (i=1; i<policiesSubMenu.length; ++i) {
			document.write("<a href='" + policiesSubMenu[i][0] + "' onmouseover='hideAll3();return true;'>" + policiesSubMenu[i][1] + "</a><BR>")
		}
		document.write("</td></tr></table></DIV>");	
	}

	//make handbook leftsub
	TopOffset = TopOffset + 26;
	if (thepage=="handbook") {
		document.write("<DIV ID='leftsub_handbook' style='position:absolute; left:9px; top:" + TopOffset + "px; z-index:14;'>");
		document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td class="leftsub" onmouseover="hideAll3();return true;">');
		for (i=1; i<handbookSubMenu.length; ++i) {
			document.write("<a href='" + handbookSubMenu[i][0] + "' onmouseover='hideAll3();return true;'>" + handbookSubMenu[i][1] + "</a><BR>")
		}
		document.write("</td></tr></table></DIV>");	
	}

	//make home leftsub
	TopOffset = TopOffset + 26;
	if (thepage=="home") {
		document.write("<DIV ID='leftsub_home' style='position:absolute; left:9px; top:" + TopOffset + "px; z-index:14;'>");
		document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td class="leftsub" onmouseover="hideAll3();return true;">');
		for (i=1; i<homeSubMenu.length; ++i) {
			document.write("<a href='" + homeSubMenu[i][0] + "' onmouseover='hideAll3();return true;'>" + homeSubMenu[i][1] + "</a><BR>")
		}
		document.write("</td></tr></table></DIV>");	
	}
	
}




function makeSubPageLinks(thepage) {
	document.write('<ul class="menuList">');
	theLinkArray = eval(thepage+'SubMenu');
	for (x=1; x<=theLinkArray.length; x++) {
		document.write('<li><a href="' + theLinkArray[x][0] + '">' + theLinkArray[x][1] + '</a></li>');
	}
	document.write('</ul>');
}


//GENERAL SUBMENU STUFF

var currentdiv = null;
var timerID = null;
ns4 = (document.layers)? true:false;
ie4 = (document.all)? true:false;
W3C = document.getElementById ? 1 : 0;


function hideAll(){
 timerID = setTimeout('hideAll2()',3000)
} 

function hideAll4(){
 timerID = setTimeout('hideAll2()',10)
} 

function clearAll(){
 clearTimeout(timerID)
} 

function hideAll2(){
	 if (ns4) {
		eval("document."+currentdiv+".visibility = 'hide'");
	} else if (ie4) {
		eval("document.all."+currentdiv+".style.visibility = 'hidden'");
	} else if (W3C) {
		eval("document.getElementById('"+currentdiv+"').style.visibility = 'hidden'");
	}
} 

function hideAll3(){
clearTimeout(timerID);
  if (currentdiv != null){
	 if (ns4) {
		eval("document."+currentdiv+".visibility = 'hide'");
	} else if (ie4) {
		eval("document.all."+currentdiv+".style.visibility = 'hidden'");
	} else if (W3C) {
		eval("document.getElementById('"+currentdiv+"').style.visibility = 'hidden'");
	}
  }
} 

function showObject(div) {
clearTimeout(timerID);
	 if (ns4) {
		eval("document."+div+".visibility = 'show'");
	} else if (ie4) {
		eval("document.all."+div+".style.visibility = 'visible'");
	} else if (W3C) {
		eval("document.getElementById('"+div+"').style.visibility = 'visible'");
	}
currentdiv = div;
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		postdocs_over = newImage("images/menu/postdocs-over.gif");
		faculty_over = newImage("images/menu/faculty-over.gif");
		administrators_over = newImage("images/menu/administrators-over.gif");
		policies_over = newImage("images/menu/policies-over.gif");
		handbook_over = newImage("images/menu/handbook-over.gif");
		home_over = newImage("images/menu/home-over.gif");
		preloadFlag = true;
	}
}




