// This obviously won't work if JavaScript is disabled.
// So - the page must detect Script enableing - user must enable it - then deal with popups.
function detectPopupBlocker(){
	var blockTest = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
 	if(blockTest){ 
		var popupsBlocked = true;
		blockTest.close();
	}else{
		var popusBlocked = false;
		blockTest.close();
  		window.location = "http://www.montgomerycollege.edu/departments/cpod/js_disable_popup_blocker.htm";
	}	
	
}

var menuWin = null;
var level3 = null;
var trwWin = null;
var lastRollOverId = "none";
// PDS DEMO WINDOW - HIDE URL FROM USER
function popDemo(){
	menuWin = window.open("http://appserv.montgomerycollege.edu/pds/user/", 'all',"toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=950,height=625");	
	menuWin.moveTo(0, 0);
}

function openWin(pageURL, type) {
	switch(type){
		case "full":
			level3 = window.open(pageURL, 'all',"toolbar=1,location=1,status=1,menubar=1,scrollbars=1,resizable=1,width=950,height=580");
			break;
		case "full_nomenu":
			level3 = window.open(pageURL, 'all',"toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=1,width=885,height=635");
			break;
		case "menutools":
			level3 = window.open(pageURL, 'all',"toolbar=1,location=0,status=0,menubar=1,scrollbars=1,resizable=1,width=800,height=580");
			level3.moveTo(130, 15);
			break;
		case "homepopup":
			level3 = window.open(pageURL, 'homepop', "toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=820,height=500");
			level3.moveTo(115, 15);
			break;
		case "classesBlurb":
			menuWin = window.open(pageURL, 'classespop', "toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=1,width=387,height=230");
			// Only works in netscape.
			menuWin.moveTo(180, 180);
			break;
		case "directions":
			highlightToggle("nav3");
			level3 = window.open(pageURL, 'homepop', "toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=820,height=600");
			break;
		case "leaderMenu":
			highlightToggle("nav7");
			menuWin = window.open(pageURL, 'leaderpop', "toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=320,height=200");
			// Only works in netscape.
			menuWin.moveTo(180, 300);
			break;
		case "partnerMenu":
			menuWin = window.open(pageURL, 'partnerpop', "toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=390,height=260");
			// Only works in netscape.
			menuWin.moveTo(380, 210);
			break;
		case "leaveMenu":
			highlightToggle("nav8");
			menuWin = window.open(pageURL, 'leavepop', "toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=300,height=160");
			// Only works in netscape.
			menuWin.moveTo(180, 330);
			break;		
		case "managementMenu":
			highlightToggle("nav9");
			menuWin = window.open(pageURL, 'managepop', "toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=300,height=185");
			// Only works in netscape.
			menuWin.moveTo(180, 360);
			break;
		case "multiculturalMenu":
			highlightToggle("nav10");
			menuWin = window.open(pageURL, 'multipop', "toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=300,height=220");
			// Only works in netscape.
			menuWin.moveTo(180, 400);
			break;
		case "orientationMenu":
			highlightToggle("nav11");
			menuWin = window.open(pageURL, 'orientationpop', "toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=290,height=175");
			// Only works in netscape.
			menuWin.moveTo(180, 400);
			break;	
		case "medium":
			med = window.open(pageURL, 'medium', "toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=750,height=600");
			med.moveTo(50, 30);
			break;
		case "whats-new":
			tootWin = window.open(pageURL, 'all', "toolbar=1,location=1,status=1,menubar=1,scrollbars=1,resizable=1,width=900,height=500");
			tootWin.moveTo(25, 25);
			break;
		case "bannerTutorial":
			toot = window.open(pageURL, 'bannertoot', "toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=1,width=995,height=640");
			toot.moveTo(10,15);
			break;		
		case "800x500movies":
			window.open(pageURL, 'movies', "toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=840,height=530");
			break;
		case "troHelp":
			troWin = window.open(pageURL, 'tro', "toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=420,height=400");
			troWin.moveTo(20, 20);
			break;
		
	}
}
// ----------------------- MENU HIGHLIGHTING FUNCTIONS ---------
var g_menuid = "none";
// highlightToggle() only called just before menu-windows open. This function temporarily toggles off the actual page button and temporarily treats the menu navbutton (newid) as the page button.  overOutNav() looks up g_menuid to determine how to treat any nav button while a menu is open.  When homefocus returns, restoreHighlight() is called and g_menuid is reset to "none."
function highlightToggle(newid){
	unlightPageItem('pagenav');
	g_menuid = newid;
}
function unlightMenuNavBtn(){	
	var pageNavDiv = document.getElementById('pagenav');//g_menuid);
	pageNavDiv.className = "navButton";
	unlightMenuButton(g_menuid); 	
}
function unlightMenuButton(id){
	var pageNavDiv = document.getElementById(id);//g_menuid);
	pageNavDiv.className = "navButton";
	g_menuid = "none";
}
function unlightPageItem(id){		
	var pageNavDiv = document.getElementById(id);	
	var pageHiLite = document.getElementById(pageNavDiv.value);
	pageHiLite.className = "navButton"; 		
}
function lightPageItem(id){		
	var pageNavDiv = document.getElementById(id);	
	var pageHiLite = document.getElementById(pageNavDiv.value);
	pageHiLite.className = "navButtonPageUp"; 		
}
function overOutPageButton(id, state){
	var pageNavDiv = document.getElementById(id);	
	//var pageHiLite = document.getElementById(pageNavDiv.value);
	if(state){ 
		pageNavDiv.className = "navButtonPageOver";  
		
	}
	else{ 
		if(g_menuid!="none"){ pageNavDiv.className = "navButton";   }
		else{ pageNavDiv.className = "navButtonPageUp"; }
	}
}
function overOutNav(id, state){
	var pageNavDiv = document.getElementById(id);
	lastRollOverId = pageNavDiv.id;
	//var pageHiLite = document.getElementById(pageNavDiv.value);
	if(state){ 
		pageNavDiv.className = "navButtonOver";  
	}
	else{ 		 
		 if(id != g_menuid) { pageNavDiv.className = "navButton"; }
		 else{ pageNavDiv.className = "navButtonPageUp"; }
	}
}
function overOutHorzNav(id, state){
	var pageNavDiv = document.getElementById(id);	
	//var pageHiLite = document.getElementById(pageNavDiv.value);
	if(state){ pageNavDiv.className = "overOutHorzNav";  }
	else{ 		 
		 pageNavDiv.className = "horzNavBtn"; 
	}
}
function overOutPrintBtn(id, state){
	var pageNavDiv = document.getElementById(id);	
	//var pageHiLite = document.getElementById(pageNavDiv.value);
	if(state){ pageNavDiv.className = "overOutPrintBtn";  }
	else{ 		 
		 pageNavDiv.className = "printBtn"; 
	}
}
// --------- PAGE CLOSING FUNCTIONS
function loadPage_MenuStay(url){	
	window.opener.location = url;
}
function loadPage_MenuClose(url){
	window.opener.location = url;
	self.close();
}
function homeFocus(){
	if(menuWin != null){	menuWin.close();		}
	if(level3 != null){			level3.close();			}
	unlightMenuNavBtn();
	restoreHighlight();
}
function tutorialClosingAlert(){
	self.focus();
	if(confirm("If you want to close the tutorial press 'OK.' To stay in the tutorial press 'Cancel.'"))
	{
		self.close();
	}
}
// GENERAL FUNCTIONS
function changeLocation(str){
	location.href = str;
}
// PRINT A DIV
function printDiv(divid)
{
var printWindow = window.open('','','scrollbars=yes,width=900,height=600');

printWindow.document.open("text/html");
printWindow.document.write('<html><head><link rel="stylesheet" href="http://www.montgomerycollege.edu/departments/cpod/cpod.css" /></head><!--[if IE]><style>div.featureText{font-size: 80%;}span.featureText{font-size: 80%;}td.featureText{font-size: 80%;}</style><![endif]--><body>');
printWindow.document.write(document.getElementById(divid).innerHTML);
printWindow.document.write('</body></html>');
printWindow.document.close(); 
printWindow.print();
}
