// TEXT SIZER
var currentFontSize;
var defaultFont='0.7em';
var mediumFont='0.85em';
var maximumFont='1em';
var path="/";
var domain=document.domain;
/**
* 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);

	if (document.getElementById('panel1d')) {
		document.getElementById('panel1d').className='fontSize';
		document.getElementById('panel2d').className='';
		document.getElementById('panel3d').className='';
	}
}

/**
 * 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);

	if (document.getElementById('panel3d')) {
		document.getElementById('panel1d').className='';
		document.getElementById('panel2d').className='';
		document.getElementById('panel3d').className='fontSize';
	}

}

/**
 * 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);

	if (document.getElementById('panel2d')) {
		document.getElementById('panel1d').className='';
		document.getElementById('panel2d').className='fontSize';
		document.getElementById('panel3d').className='';
	}
}


/** 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 : "" );
}
