//Turning the resolution change menu on and off
function ResVisible(){
	//check to see if the resolution menu is on, if it is turn it off, otherwise turn it on
	if (document.getElementById("menuRes").style.visibility=="visible"){
		document.getElementById("menuRes").style.visibility="hidden";		
	}
	else {
		document.getElementById("menuRes").style.visibility="visible";		
	}
}

//changing the resolution size of all the 
function ChangeRes(resolution,pagename){
	//find out if the screen is set to power save mode
	var powerSave = PowerSaveCheck();
	
	var pageOn = new Array();
	pageOn[0] = "admissions";
	pageOn[1] = "basicinfo";
	pageOn[2] = "aboutuat";
	pageOn[3] = "careers";
	pageOn[4] = "program";
	pageOn[5] = "resources";
	
	var lowImage = new Array();
	lowImage[0] = "/Img/background_5.jpg";
	lowImage[1] = "/Img/background_6.jpg";
	lowImage[2] = "/Img/background_6.jpg";
	lowImage[3] = "/Img/background_2.jpg";
	lowImage[4] = "/Img/background_4.jpg";
	lowImage[5] = "/Img/background_10.jpg";
	lowImage[6] = "/Img/background_1.jpg";
	
	var medImage = new Array();
	medImage[0] = "/Img/back_med_5.jpg";
	medImage[1] = "/Img/back_med_6.jpg";
	medImage[2] = "/Img/back_med_6.jpg";
	medImage[3] = "/Img/back_med_2.jpg";
	medImage[4] = "/Img/back_med_4.jpg";
	medImage[5] = "/Img/back_med_10.jpg";
	medImage[6] = "/Img/back_med_1.jpg";
	
	var highImage = new Array();
	highImage[0] = "/Img/back_large_5.jpg";
	highImage[1] = "/Img/back_large_6.jpg";
	highImage[2] = "/Img/back_large_6.jpg";
	highImage[3] = "/Img/back_large_2.jpg";
	highImage[4] = "/Img/back_large_4.jpg";
	highImage[5] = "/Img/back_large_10.jpg";
	highImage[6] = "/Img/back_large_1.jpg";
	
	//a lot of the menu elements share the same top value, this helps editing that value
	var menuTop;
	//the test to see if the background image was assigned something
	var imageFlag = 0;
		
	if (resolution=="highres"){
		//setting the menu top
		menuTop = "679";
		
		//hide the menu again
		document.getElementById("menuRes").style.visibility="hidden";
		//replace the main background image
		document.getElementById("back_image").src="/Img/NetSec1280.jpg";
		//moving the menu items
		changeTop("menuResIcon",menuTop);
		changeTop("menuNav",menuTop);
		changeTop("menuMain",menuTop);
		changeTop("menuShell",menuTop);
		changeTop("menuApply",menuTop);
		changeTop("menuRequest",menuTop);
		changeTop("menuRes","577");
		changeTop("menuTime","680");
		changeLeft("menuTime","905");
		changeTop("uatLogo","712");
		changeLeft("uatLogo","570");
		changeTop("powerButton","727");
		changeLeft("powerButton","985");
		
		//stretches the current image to temporarily hide the background til the new image loads
		document.getElementById("setme").style.width="990";
		document.getElementById("setme").style.height="630";
		
		//check to see if the power save mode is on
		if (powerSave == "power_save.gif" || powerSave == "power_save_med.gif"){
			document.getElementById("setme").src="/Img/power_save_large.gif";
		}
		//otherwise run through the arrays to put the right image in place
		else {
			for (counter = 0; counter < pageOn.length; counter++){
				if (pageOn[counter] == pagename){
					document.getElementById("setme").src = highImage[counter];
					//turn on flag that image has been set
					imageFlag = 1;
				}
				//if it's the last time through the array and the image flag hasn't been set, put it to the default background
				if ((counter + 1) == pageOn.length && imageFlag != 1){				
					document.getElementById("setme").src = highImage[counter + 1];
				}
			}
		}
		
		//set the cookie for the res size and return the res size
		setCookie("resolution",resolution,30,"/",LocationBreak());
		return resolution;
	}
	else if(resolution=="lowres") {
		//setting the menu top
		menuTop = "472";
		
		//hide the menu again
		document.getElementById("menuRes").style.visibility="hidden";
		//replace the main background image
		document.getElementById("back_image").src="/Img/NetSecBackground_1.jpg";
		//moving the menu items
		changeTop("menuResIcon",menuTop);
		changeTop("menuNav",menuTop);
		changeTop("menuMain",menuTop);
		changeTop("menuShell",menuTop);
		changeTop("menuApply",menuTop);
		changeTop("menuRequest",menuTop);
		changeTop("menuRes","370");
		changeTop("menuTime","473");
		changeLeft("menuTime","590");
		changeTop("uatLogo","495");
		changeLeft("uatLogo","400");
		changeTop("powerButton","510");
		changeLeft("powerButton","660");
		
		//stretches the current image to temporarily hide the background til the new image loads
		document.getElementById("setme").style.width="671";
		document.getElementById("setme").style.height="424";
		
		//restore the positions, but not visibility, of the windows
		RestoreMain("TableContent","MainContent");
		RestoreShell("Shell");
		RestorePopUp("w_test","w_test_frame");
		
		//check to see if the location is the main page and if not restore the subnav window
		if(pagename != "default"){
			RestoreNav("SubNavWindow","SubNav");
		}
		if(pagename == "default"){
			//if the page is the main page and the popup is enabled, restore the subnav
			if(popupTest == "1"){
			RestoreNav("SubNavWindow","SubNav");
			}
		}
		
		//check to see if the power save mode is on
		if (powerSave == "power_save_med.gif" || powerSave == "power_save_large.gif"){
			document.getElementById("setme").src="/Img/power_save.gif";
		}
		//otherwise run through the arrays to put the right image in place
		else {
			for (counter = 0; counter < pageOn.length; counter++){
				if (pageOn[counter] == pagename){
					document.getElementById("setme").src = lowImage[counter];
					//turn on flag that image has been set
					imageFlag = 1;
				}
				//if it's the last time through the array and the image flag hasn't been set, put it to the default background
				if ((counter + 1) == pageOn.length && imageFlag != 1){				
					document.getElementById("setme").src = lowImage[counter + 1];
				}
			}
		}
		
		//set the cookie for the res size and return the res size
		setCookie("resolution",resolution,30,"/",LocationBreak());
		return resolution;
	}
	else{
		//setting the menu top
		menuTop = "565";
		
		//hide the menu again
		document.getElementById("menuRes").style.visibility="hidden";
		//replace the main background image
		document.getElementById("back_image").src="/Img/NetSec1024.jpg";
		//moving the menu items
		changeTop("menuResIcon",menuTop);
		changeTop("menuNav",menuTop);
		changeTop("menuMain",menuTop);
		changeTop("menuShell",menuTop);
		changeTop("menuApply",menuTop);
		changeTop("menuRequest",menuTop);
		changeTop("menuRes","463");
		changeTop("menuTime","566");
		changeLeft("menuTime","730");
		changeTop("uatLogo","588");
		changeLeft("uatLogo","470");
		changeTop("powerButton","603");
		changeLeft("powerButton","810");
		
		//stretches the current image to temporarily hide the background til the new image loads
		document.getElementById("setme").style.width="813";
		document.getElementById("setme").style.height="517";
		
		//check to see if the power save mode is on
		if (powerSave == "power_save.gif" || powerSave == "power_save_large.gif"){
			document.getElementById("setme").src="/Img/power_save_med.gif";
		}
		//otherwise run through the arrays to put the right image in place
		else {
			for (counter = 0; counter < pageOn.length; counter++){
				if (pageOn[counter] == pagename){
					document.getElementById("setme").src = medImage[counter];
					//turn on flag that image has been set
					imageFlag = 1;
				}
				//if it's the last time through the array and the image flag hasn't been set, put it to the default background
				if ((counter + 1) == pageOn.length && imageFlag != 1){				
					document.getElementById("setme").src = medImage[counter + 1];
				}
			}
		}
		
		//set the cookie for the res size and return the res size
		setCookie("resolution",resolution,30,"/",LocationBreak());
		return resolution;
	}
}

//changing the top location of an element, so you don't have to keep writing the same code over and over
function changeTop(element,top){
	document.getElementById(element).style.top = top;
}

//changing the left location of an element, so you don't have to keep writing the same code over and over
function changeLeft(element,left){
	document.getElementById(element).style.left = left;
}

function Restore(location){
//popupTest is located on the default.asp page and controls whether the nav window is being displayed there or not
if (location != "default" || popupTest==1){
	document.getElementById("SubNavWindow").style.visibility = "visible";
	document.getElementById("SubNav").style.visibility = "visible";
	document.getElementById("menuNavImg").src = "/Img/MenuBarNavigationActive.gif"; 
	document.getElementById("menuNav").style.visibility = "visible";
	RestoreNav("SubNavWindow","SubNav");
	}
document.getElementById("TableContent").style.visibility = "visible";
document.getElementById("MainContent").style.visibility = "visible";
document.getElementById("Shell").style.visibility = "visible";
document.getElementById("menuMainImg").src = "/Img/MenuBarMainActive.gif"; 
document.getElementById("menuShellImg").src = "/Img/MenuBarShellActive.gif";
document.getElementById("menuMain").style.visibility = "visible";
document.getElementById("menuShell").style.visibility = "visible";
document.getElementById("overlay_icons").style.visibility = "visible";
document.getElementById("menuRequest").style.visibility = "visible";
document.getElementById("menuApply").style.visibility = "visible";
RestoreMain("TableContent","MainContent");
RestoreShell("Shell");
wcontrolarr_set("w_test","hidden",1);
PopUp("none");
//these global variables are located in the minimize.js file
minShell=0;
minMain=0;
minNav=0;
minTest=1;
}

//these are all the default settings for the main content frame
function RestoreMain(main,iframe){
	document.getElementById(main).style.top = "260";
	document.getElementById(main).style.left = "210";
	document.getElementById(main).style.width = "500";
	document.getElementById(main).style.height = "170";
	document.getElementById(iframe).width = "500";
	document.getElementById(iframe).height = "154";
	//these variables are located in the jim_control.js file and control the draggable 
	window_position_x[1] = 210; 
	window_position_y[1] = 260;
	window_position_width[1] = 500; 
	window_position_height[1] = 170;
}

//these are all the default settings for the sub nav frame
function RestoreNav(nav,iframe){
	document.getElementById(nav).style.top = "80";
	document.getElementById(nav).style.left = "210";
	document.getElementById(nav).style.width = "190";
	document.getElementById(nav).style.height = "170";
	document.getElementById(iframe).width = "190";
	document.getElementById(iframe).height = "154";
	//these variables are located in the jim_control.js file and control the draggable 
	window_position_x[3] = 210; 
	window_position_y[3] = 80;
	window_position_width[3] = 190; 
	window_position_height[3] = 170;
}

//these are all the default settings for the shell frame
function RestoreShell(shell){
	document.getElementById(shell).style.top = "80";
	document.getElementById(shell).style.left = "520";
	document.getElementById(shell).style.width = "190";
	document.getElementById(shell).style.height = "170";
	//these variables are located in the jim_control.js file and control the draggable 
	window_position_x[2] = 520; 
	window_position_y[2] = 80;
	window_position_width[2] = 190; 
	window_position_height[2] = 170;
}

//these are all the default settings for the pop up menu that is hidden by default
function RestorePopUp(pop,popframe){
	document.getElementById(pop).style.top = "55";
	document.getElementById(pop).style.left = "125";
	document.getElementById(pop).style.width = "450";
	document.getElementById(pop).style.height = "400";
	document.getElementById(popframe).width = "450";
	document.getElementById(popframe).height = "384";
	//these variables are located in the jim_control.js file and control the draggable 
	window_position_x[4] = 125; 
	window_position_y[4] = 55;
	window_position_width[4] = 450; 
	window_position_height[4] = 400;
}

//this is used to find where the x location of the right side of the screen
function ScreenWidth(min,backdrop){
	//find the width of the backdrop covering the screen, add the x padding on left and give it an additional padding of 5
	var width = document.getElementById(backdrop).width;
	var newwidth = width + 5 + min;
	return newwidth;
}

//this is used to find where the y location of the bottom side of the screen
function ScreenHeight(min,backdrop){
	//find the top of the backdrop covering the screen, add the y padding on top and give it an additional padding of 5
	var height = document.getElementById(backdrop).height;
	var newheight = height + 5 + min;
	return newheight;
}

//find the new draggable area for the windows
function NewBounds(backdrop){
	//all the bound_region variables are located in the jim_control file and control the windows draggable area
	bound_region_x_max = ScreenWidth(bound_region_x_min,backdrop);
	bound_region_y_max = ScreenHeight(bound_region_y_min,backdrop);
}

//this checks to see if the power save mode is activated and returns the file name if it is
function PowerSaveCheck(){
	//grab the background image source
	var backimage = document.getElementById("setme").src;
	//split the source path name
	var backimageholder = backimage.split('/');
	
	//loop through the array and see if the image name is one of the power save modes
	for (i=0;i<backimageholder.length;i++){
		//if the image is one of the power save modes, return the image name
		if (backimageholder[i] == "power_save.gif" || backimageholder[i] == "power_save_med.gif" || backimageholder[i] == "power_save_large.gif"){
			return backimageholder[i];
		}
	}
	//otherwise return nothing
	return "nothing";
}

//this is for the cookie function to return the actual url, since there are so many domain names for the page
function LocationBreak(){
	currentLocation = location.toString();
	currentHolder = currentLocation.split('/');
	
	for (i=0;i<currentHolder.length;i++){
		//when the url is split with '/' there is a blank spot in the array after the http://
		if (currentHolder[i] == ""){
			//the next spot is the domain name
			return(currentHolder[i+1]);
		}
	}
}