/*
	JavaScript Code File
	
	Written by Webmaster
		- Brian Hill [hillb@yosemite.cc.ca.us]
	
	Copyright © Modesto Junior College
	Reuse authorized for academic purposes only. Commercial redistribution prohibited without permission.
	Created: January 28, 2005 for template version 3.00.012805
	Update Log:
------------------------------------------------------------*/

//############################################
//	COOKIE CODE
//############################################

function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

//############################################
//	PAGE STYLE UPDATE CODE
//############################################
//FUNCTION 1, UPDATE COOKIE

function changeSize() {
	var curSize = readCookie("mjcsize");
	if(curSize != null) {curSize = parseInt(curSize);} else {curSize = 2;}
	var newSize = curSize+1;
	if(newSize == 5) { newSize = 1;}
	createCookie( "mjcsize", newSize, 300);
	window.location.reload();
}

function changeStyle() {
	var curStyle = readCookie("mjcstyle");
	if(curStyle != null)
		{curStyle = parseInt(curStyle);}
		else {curStyle = 1;}
	var newStyle = curStyle+1;
	if(newStyle == 5) { newStyle = 1;}
	createCookie( "mjcstyle", newStyle, 300);
	window.location.reload();
}

function applyPrinter() {
	var curPrint = readCookie("mjcprint");
	if(curPrint != 1) {
		createCookie( "mjcprint", 1, 1)
	} else {
		createCookie( "mjcprint", 0, 300)
	}		
		
	window.location.reload();
}

function applyTextOnly() {
	createCookie( "mjcstyle", 4, 300);
	window.location.reload();
	
}
//#############################################
//    OTHER FUNCTIONS
//#############################################

function start() //Anything that needs to autoexecute on pageload.
{
	

		if(readCookie("mjcstyle")!=4||readCookie("mjcstyle")==null) {fixH();}
		
		fixOffset();

}

function resize() {}

function fixH() 
{ 
if (document.all || document.getElementById) {
	var rh=document.getElementById('pagecontent').offsetHeight; //get height of main body div
	var lh=document.getElementById('pagemenu').offsetHeight; //get height of menu div
		//alert("menu:" + lh);
		//alert("body:" + rh);
	if(rh>lh) {
		var newheight=rh-75; //offset height to account for nav menu

		if(document.all){// For IE, Opera, and most other browsers
			var e=document.getElementById("pagemenu");
			e.style.height = newheight + 'px'; //set menu length
			}
		if(!document.all && document.getElementById){ //for Firefox/Mozilla
			var rh=document.getElementById('pagecontent').offsetHeight;
			document.getElementById('pagemenu').style.height=newheight + "px";
			}
	}
	
	
	
}
} 

function fixOffset() {
if (document.all || document.getElementById) {			
	var curMenuWidth = document.getElementById('pagemenu').offsetWidth;
	var newContentOffset = curMenuWidth+10;
	if(readCookie("mjcstyle") == 2 || readCookie("mjcstyle") == 3 || readCookie("mjcstyle") == 1) {
	if(document.all){// For IE, Opera, and most other browsers
		var e=document.getElementById("pagecontent"); //adjust offset for main page content
			e.style.paddingLeft = newContentOffset + 'px'; 
		var f=document.getElementById("navmenu"); //adjust offset for navigational menu
			f.style.paddingLeft = curMenuWidth + 'px'; 
		}
		
	if(!document.all && document.getElementById){ //for Firefox/Mozilla
		document.getElementById('pagecontent').style.paddingLeft=newContentOffset + "px";
		document.getElementById('navmenu').style.paddingLeft=curMenuWidth + "px";
	}
	
	}
}
}


//tooltip functions
//show tooltip
function showtip(whichtip){
	eval("document.getElementById(\"" + whichtip + "\").style.visibility = 'visible'")
}

//hide tooltip
function hidetip(whichtip){
		eval("document.getElementById(\"" + whichtip + "\").style.visibility = 'hidden'")
}


