var MainMenus = new Array();

//if the menuLink starts with a / it will be treated as content, otherwise, a section
function showMainMenu(divName, pushRight, dropDownWidth, menuItems, menuLinks, menuTitles){
var width = dropDownWidth;
var newMenu = true;

var leftMargin = pushRight;
	
for (var i = 0; i < MainMenus.length; i++)
{	
	if (MainMenus[i] == divName)
		newMenu = false;
	else
		hideMainMenu(MainMenus[i]);
}
if (newMenu)
	MainMenus[MainMenus.length] = divName;

var obj = document.getElementById("main" + divName);

//obj.style.marginLeft = leftMargin;

if (obj.style.display != "")
{
	
	var browser=navigator.appName
	var b_version=navigator.appVersion
	var version=parseFloat(b_version)
	var topMargin = 10;
	if(browser == "Microsoft Internet Explorer" && version < 7)
		topMargin = 14;
		
	//is ie 7?
	if(window.XMLHttpRequest)
		var topMargin = 10;
	
	var dropDownHTML = "<div style=\"padding-left:" + leftMargin + "px\"><table style=\"background-color:white;margin-top:" + topMargin + "px;width:" + width + "px\"><tr><td align=left style=\"width:" + width + "\"><table align=left cellpadding=\"0\" cellspacing=\"0\" class=\"menuLinks\" style=\"width:100%\">";


	obj.style.position = "absolute";	
	obj.style.top = "145px";
	obj.style.display = "";
	obj.style.zIndex ="10";
	
	if (menuItems == null)
	{
		dropDownHTML = dropDownHTML + "<tr><td class=\"menuLinks\"><p class=\"menuLinks\">no menu items</p></td></tr>";	
	}
	else
	{
		for (var j = 0; j < menuItems.length; j++)
		{
			if (menuItems[j] != "__NULL_ITEM")
			{
				//var linkTo = "/" + menuLinks[j] + "/";
				// if (menuLinks[j].substring(0,1) == "/")
				//	linkTo = menuLinks[j] +".html";
				
				var linkTo = menuLinks[j] + ".html";
				
				dropDownHTML += '<tr style="cursor:pointer" onclick="window.location=\'' + linkTo + '\'" onmouseover="this.title=unescape(&quot;' + escape(menuTitles[j]) + '&quot;); this.style.backgroundColor=\'#ece7ca\'" onmouseout="this.style.backgroundColor=\'#FFFFFF\'">' +
				'<td class="menuLinks"><p class="menuLinks">' +
				'<a class="menuLinks" href="' + linkTo + '" >' + menuItems[j] + '</a>' +	
				'</p><td></tr>';
	
			if (j != menuItems.length - 1 && (menuLinks[j + 1] != "__NULL_ITEM"))
				dropDownHTML = dropDownHTML + "<tr><td class=\"menuLinks\" style=\"height:1px;background-image:url(images/w_images/westminstersem/dots.gif);background-repeat:repeat-x;background-position:0px 0px\"></td></tr>";
		
			}
		}
		
	}
	
	
	dropDownHTML = dropDownHTML + "</table></td></tr></table></div>";
	
	obj.innerHTML = dropDownHTML;

}

}
function removeAllDropdowns(){
	
	    hideMainMenu('home');
		hideMainMenu('becoming');
		hideMainMenu('students');
		hideMainMenu('alumni');
		hideMainMenu('lifelong');
	
}
function hideMainMenu(divName){
	var obj = document.getElementById("main" + divName);
	
	if (obj)
		obj.style.display = "none";
}
function hideRightMenu(divName){
	var obj = document.getElementById("rightMenu" + divName);
	var pic = document.getElementById("rightPic" + divName);
	var border = document.getElementById("rightBorder" + divName);
	//border.style.left = "0px"
	obj.style.display = "none";
	pic.src = "images/w_images/westminstersem/plus.gif";
}
function rightMenuSwitch(menuNum){
	var obj = document.getElementById("rightMenu" + menuNum);
	var border = document.getElementById("rightBorder" + menuNum);
	setCookie( 'rightMenuSelected', menuNum );
	//border.style.left = "5px";
	if (obj.style.display == "none")
	{	
		obj.style.display = "";
		for( var i = 1; i <= 5; i++ )
		{
			if( i != menuNum )
			{
				hideRightMenu( i );
			}
		}
	/*switch(menuNum)
	{
		
		case 1:
		hideRightMenu(2);hideRightMenu(3);hideRightMenu(4);
		break;
		case 2:
		hideRightMenu(1);hideRightMenu(3);hideRightMenu(4);
		break;
		case 3:
		hideRightMenu(1);hideRightMenu(2);hideRightMenu(4);
		break;
		case 4:
		hideRightMenu(1);hideRightMenu(2);hideRightMenu(3);
		break;
	}*/
	
		var pic = document.getElementById("rightPic" + menuNum);
		pic.src = "images/w_images/westminstersem/minus.gif";
	}
	else
	{
		//spacing goes haywire if this is enabled?
		//hideRightMenu(menuNum);
	}
	
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
	  c_start=document.cookie.indexOf(c_name + "=")
	  if (c_start!=-1)
	    { 
		    c_start=c_start + c_name.length+1 
		    c_end=document.cookie.indexOf(";",c_start)
		    if (c_end==-1) c_end=document.cookie.length
		    return unescape(document.cookie.substring(c_start,c_end))
	    } 
	}
	return ""
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}


 var popupsOnPage = 0;
 function extraContent(divId, title, content)
 {
  closeContent();

  var d=document.getElementById("popup");
  var d1=document.getElementById("popup" + divId);
  
  d1.style.display='';
  d1.innerHTML = d.innerHTML;
  d.innerHTML = "";
  //alert("innerhtml " + d1.innerHTML);
  document.getElementById("extraContent").innerHTML = content;
  document.getElementById("popupTitle").innerHTML = "<h3>" + title + "</h3>"; 
 }

 function closeContent()
 {
	  document.getElementById('popup').style.display='none';
  for (var i = 1; i <= popupsOnPage; i++)
  {
  	var d = document.getElementById('popup' + i);
  	if (d.innerHTML != "")
  	{
  		document.getElementById("popup").innerHTML = d.innerHTML;
  		d.innerHTML = "";
  		d.style.display = "none";
  	}
  }
 }
