var sizeType = "px";
var incrementValue = 2;
var lowerLimit = 10;
var defaultValue = 14;
var upperLimit = 24;
//var sizeType = "em";
//var incrementValue = .1;
//var lowerLimit = .5;
//var defaultValue = .75;
//var upperLimit = 1.30;
var newSize;
var expdate = new Date ();				  							// Declare a date object for the cookie	
expdate.setTime (expdate.getTime() + (365 * 24 * 60 * 60 * 1000)); 	// Set the expiry date to be applied to the cookie

// Array member declared as (<normal_img_name>,<grey_img_name>,<anchor_tag_id>)
var cstArrySizerImgs = new Object(); 	
cstArrySizerImgs["plus"] = new Array("header_resizer_grey_plus.gif","header_resizer_blue_plus.gif","sizer_plus");
cstArrySizerImgs["minus"] = new Array("header_resizer_grey_minus.gif","header_resizer_blue_minus.gif","sizer_minus");

function raiseText(){
	if(checkUpper()){
	}else{
		doGreyOut("minus",1);		
		setCookie("textSize",(parseFloat(getCookie("textSize")) + incrementValue),expdate);	
		if(document.getElementById("main-col")){	
			document.getElementById("main-col").style.fontSize=parseFloat(getCookie("textSize")) + sizeType;		
		} else if(document.getElementById("two-col")){
			document.getElementById("two-col").style.fontSize=parseFloat(getCookie("textSize")) + sizeType;				
		}			
	}
	
	if(checkUpper()){doGreyOut("plus",0);}
}

function lowerText(){
	if(checkLower()){
	}else{	
		doGreyOut("plus",1);	
		setCookie("textSize",(parseFloat(getCookie("textSize")) - incrementValue),expdate);	
		if(document.getElementById("main-col")){
			document.getElementById("main-col").style.fontSize=parseFloat(getCookie("textSize")) + sizeType;	
		} else if(document.getElementById("two-col")){			
			document.getElementById("two-col").style.fontSize=parseFloat(getCookie("textSize")) + sizeType;			
		}			
	}
	
	if(checkLower()){doGreyOut("minus",0);}
}

function resetText(){
	doGreyOut("minus",1);	
	doGreyOut("plus",1);	

	if(document.getElementById("main-col")){
		document.getElementById("main-col").style.fontSize=defaultValue + sizeType;	
	} else if(document.getElementById("two-col")){			
		document.getElementById("two-col").style.fontSize=defaultValue + sizeType;		
	}		
	setCookie("textSize",(defaultValue),expdate); 	
}

function loadPage(){
	if(getCookie("textSize")==null){	
		resetText();
	}
	if(document.getElementById("main-col")){	
		document.getElementById("main-col").style.fontSize=parseFloat(getCookie("textSize")) + sizeType;	
	} else if(document.getElementById("two-col")){	
		document.getElementById("two-col").style.fontSize=parseFloat(getCookie("textSize")) + sizeType;		
	}		
	if(checkUpper()){doGreyOut("plus",0);}	
	if(checkLower()){doGreyOut("minus",0);}
}

function checkUpper(){
	return parseFloat(getCookie("textSize")) >= upperLimit;
}

function checkLower(){
	return parseFloat(getCookie("textSize")) <= lowerLimit;
}

// Set the cookie value and expiry date
function setCookie(name, value, expires, path){
	document.cookie= name + "=" + escape(value) +
  	((expires) ? "; expires=" + expires.toGMTString() : "") +
    ("; path=/" );
}

// Return the value of the text size cookie
function getCookie(name){
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1){
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}else{
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1){
		end = dc.length;
	}
  return unescape(dc.substring(begin + prefix.length, end));
}

// This function greys out the either the plus or minus image
function doGreyOut(PlusOrMinus, isReset){
    var sizerEle = document.getElementById(cstArrySizerImgs[PlusOrMinus][2]);
    sizerEle.style.cursor = (isReset)?"":"default";
    var strSrc = sizerEle.getElementsByTagName("IMG")[0].src;
    strSrc = strSrc.substring(0,strSrc.lastIndexOf("/")+1)+cstArrySizerImgs[PlusOrMinus][isReset];
    sizerEle.getElementsByTagName("IMG")[0].src = strSrc;
}

// Script to help run the Toggle Script for collapsing menus
// Author - Geoff MCDonald
function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

// Toggle Script for collapsing menus
// Author - Geoff MCDonald
    function toggle() {
        for (var i = 0; i < arguments.length; i++ ) {
            $(arguments[i]).style.display = ($(arguments[i]).style.display != 'none' ? 'none' : '' );
        }
    }


// Horizontal Menu script
// Author - Patrick Griffiths and Dan Webb
    sfHover = function() {
    	var sfEls = document.getElementById("menuDropList").getElementsByTagName("LI");
    	for (var i=0; i<sfEls.length; i++) {
    		sfEls[i].onmouseover=function() {
    			this.className+=" sfhover";
    		}
    		sfEls[i].onmouseout=function() {
    			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
    		}
    	}
    }
    if (window.attachEvent) window.attachEvent("onload", sfHover);
	
	
// Assign a cookie for the collapsable menu state
// Author - Nathan Snobelen

	function setStateCookie(value){	
		
		document.cookie= "menuStateCookie" + "=" + escape(value) +
		((expdate) ? "; expires=" + expdate.toGMTString() : "") +
		("; path=/" );		
		
		
	}