var currSelectedSizeImg;
var smallBttn;
var fontCookieName = "fontSizer";
var BUTTON_IMAGE_SPACE = 3;
var currHighlightedImg = "";
var currHighlightedImgSrc = "";


function adjustFontSize(fontSize, isOnLoad) {
	var contentDiv = document.getElementById('divContentContainer');
	contentDiv.className = "content_fontSize_"+fontSize;
		
	if(!isOnLoad) {
		setCookie(fontCookieName, fontSize, "/");
		showSelectionIndication(fontSize);
	}
}

function getCookie(c_name) {
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) { 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) {
				c_end=document.cookie.length;
			}
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}

function setCookie(cookieName,cookieValue, cookiePath) {
	document.cookie = cookieName + "=" + escape(cookieValue) + ";path=" + cookiePath;
	// no time expiry set up, will remove upon exiting browser
}

function checkFontCookie() {
	var fontSize = 0;
	var numFontSize;
	fontSize=getCookie(fontCookieName);
	numFontSize = Number(fontSize);
	if(numFontSize > 0) {
		showSelectionIndication(numFontSize);
	}
	if (fontSize!=null && fontSize!="" && fontSize != "1" && fontSize!=0) {
		adjustFontSize(fontSize, true);
	}
}


function showSelectionIndication(numFontSize) {
	var imageNameConvention = "font-sizer-";
	var fontString = getSizeFromNum(numFontSize);
	$(currHighlightedImg).attr('src','/images/' + imageNameConvention + currHighlightedImgSrc + "-off.gif")
	currHighlightedImg = "#" + fontString + "FontImg";
	currHighlightedImgSrc = fontString;
	$(currHighlightedImg).attr('src','/images/' + imageNameConvention + fontString + "-on.gif")
}

function getSizeFromNum(numFontSize) {
	var fontString = "";
	switch(numFontSize) {
		case 1: 
			fontString = "small";
			break;
		case 2:
			fontString = "medium";
			break;
		case 3:
			fontString = "large";
			break;
	}
	return fontString;
}

