// JavaScript Document

// TEXT SIZER

var currentFontSize;

var defaultFont='100%';

var mediumFont='110%';

var maximumFont='125%';

var path="/";

var domain=".outreachcollege.arizona.edu"

/**

* This functionality retrives the existing font from the cookie and based on the 

* cookie value this will call respective javascript functionality. If the cookie 

* value is null then it will set the default value.

*/

function getExistingFontSize(){

	var existingFontSize = getFontSizeCookie("fontSize");

	if (existingFontSize!=null){

		if (existingFontSize==defaultFont){

			defaults();

		}else if (existingFontSize==mediumFont){

			setMiniFontSize();			

		}else if (existingFontSize==maximumFont){

			setMaxFontSize();

		}

	}else{

		defaults();

	}	

}



/**

 * This function sets the default font size to the document's body style

 * and sets the fontSize cookie

 */

function defaults(){

	document.body.style.fontSize=defaultFont;

	setFontSizeCookie("fontSize",defaultFont,null,path,domain);

}



/**

 * This function sets the large font size to the document's body style

 * and sets the fontSize cookie

 */

function setMaxFontSize(){

	document.body.style.fontSize=maximumFont;

	setFontSizeCookie("fontSize",maximumFont,null,path,domain);

}



/**

 * This function sets the medium font size to the document's body style

 * and sets the fontSize cookie

 */

function setMiniFontSize(){

	document.body.style.fontSize=mediumFont;

	setFontSizeCookie("fontSize",mediumFont,null,path,domain);

}





/** getFontSizeCookie */

function getFontSizeCookie(cookieName){

	if (document.cookie.length > 0) { 

		var startOfCookie = document.cookie.indexOf(cookieName+"="); 

		if (startOfCookie != -1) { 

			startOfCookie += cookieName.length+1;

			var endOfCookie = document.cookie.indexOf(";", startOfCookie);

			if (endOfCookie == -1) 

				endOfCookie = document.cookie.length;

				return unescape(document.cookie.substring(startOfCookie, endOfCookie)); 

			} 

	}

	return null; 

}



/** setFontSizeCookie */

function setFontSizeCookie(cookieName, cookieValue, cookieExpiredays, path, domain) {

	var ExpireDate = new Date ();

	ExpireDate.setTime(ExpireDate.getTime() + (cookieExpiredays * 24 * 3600 * 1000));

	document.cookie = cookieName + "=" + escape(cookieValue) + 

	((cookieExpiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString())

	+ ( ( path ) ? ";path=" + path : "" ) +

	( ( domain ) ? ";domain=" + domain : "" );

}
