function changeFsize(fontSize) {
	if (document.getElementById) {
		for (var i = 0; i < aryCSSFiles.length; i++) {
			var obj = document.getElementById(aryCSSFilesID[i]);
			var src = aryCSSFiles[i] + fontSize + ".css";
			src = ("./" == src.substr(0, 2)) ? src.substr(2) : src;
			if (null != obj && -1 == obj.href.indexOf(src)) {
				obj.href = src;
			}
		}
	}
}

function setCookie(strKey, strVal) {
	var strDefVal = "m";
	
	if ( ! is_FsizeExist(strKey) ) {
		strVal = strDefVal;
		setFsize(strKey, strVal);
	}
	
	var blFsizeChanged = is_FsizeChanged(strKey, strVal);
	
	if ( blFsizeChanged ) {
		setDate = new Date();
		setDate.setTime(setDate.getTime() + (7*1000*60*60*24));
		expDate = setDate.toGMTString();
		
		strNewCookie    = strKey + "=" + escape(strVal) + "; path=/; expires=" + expDate;
    	document.cookie = strNewCookie;
    }
	
    if (-1 != navigator.userAgent.indexOf("MSIE 6.0")) {
	    location.reload();
	    return;
    }
    else {
		if (typeof updateShim == "function") {
			setTimeout("shimTimer()", 100);
	    }
    }

	changeFsizeBtn(strVal, blFsizeChanged);

	if (document.all) {
		var chd = frames["CalFrame"];
		if (null != chd) {
			chd.resizeCalendar();
		}
	}
	else {
		var chd = document.getElementById("CalFrame");
		if (null != chd) {
			chd.contentWindow.resizeCalendar();
		}
	}
    
}

function shimTimer() {
   	updateShim();
}

function changeFsizeBtn(strVal, blFsizeChanged)
{
	var strPath   = '../../new_img2/';
	
	el1 = document.getElementById ("Image901");
	el2 = document.getElementById ("Image902");
	el3 = document.getElementById ("Image903");
	if (null == el1 || null == el2 || null == el3) {
		return;
	}

	if ("" == strVal || "m" == strVal) {
    	el1.src = strPath + "fsize_s.gif";
		el2.src = strPath + "fsize_m_on.gif";
		el3.src = strPath + "fsize_b.gif";
		if (blFsizeChanged) changeFsize('');
	}
	else if (strVal.match("s")) {
    	el1.src = strPath + "fsize_s_on.gif";
		el2.src = strPath + "fsize_m.gif";
		el3.src = strPath + "fsize_b.gif";
		if (blFsizeChanged) changeFsize("_" + strVal);
    }
    else if (strVal.match("b")) {
    	el1.src = strPath + "fsize_s.gif";
		el2.src = strPath + "fsize_m.gif";
		el3.src = strPath + "fsize_b_on.gif";
		if (blFsizeChanged) changeFsize("_" + strVal);
    }
}

function setFsize(strKey, strVal)
{
	setDate = new Date();
	setDate.setTime(setDate.getTime() + (7*1000*60*60*24));
	expDate = setDate.toGMTString();
	
	strNewCookie    = strKey + "=" + escape(strVal) + "; path=/;expires=" + expDate;
    document.cookie = strNewCookie;
}

function is_FsizeExist(strKey)
{
    strCurrCookie    = document.cookie + ";";
    intIsCookieExist = strCurrCookie.indexOf(strKey, 0);
    
    if(intIsCookieExist == -1) return false;
    else                       return true;
}

function is_FsizeChanged(strKey, strCurrVal)
{
    strCurrCookie    = document.cookie + ";";
    intIsCookieExist = strCurrCookie.indexOf(strKey, 0);
    
    if (intIsCookieExist != -1)
    {
    	strTargetCookie = strCurrCookie.substring(intIsCookieExist, strCurrCookie.length);
    	intTargetKey    = strTargetCookie.indexOf("=", 0);
    	intTargetVal    = strTargetCookie.indexOf(";", intTargetKey);
    	strTargetVal    = strTargetCookie.substring(intTargetKey + 1, intTargetVal);
    	
    	if (strTargetVal.match(strCurrVal)) return false;
    	else                                return true;
    }
    return false;
}

function rollOutForFsize(strKey, strCurrVal, objImg)
{
	var strPath      = '../../new_img2/';
	var strCookieVal = getFCookie(strKey);
	
	if      (typeof strCookieVal == "undefined")
	{
		objImg.src = strPath + "fsize_" + strCurrVal + ".gif";
	}
    else if (strCookieVal.match(strCurrVal))
    {
    	return;
    }
   	else
    {
    	objImg.src = strPath + "fsize_" + strCurrVal + ".gif";
    }
}

function rollOverForFsize(strKey, strCurrVal, objImg)
{
	var strPath      = '../../new_img2/';
	var strCookieVal = getFCookie(strKey);
	
	if      (typeof strCookieVal == "undefined")
	{
		objImg.src = strPath + "fsize_" + strCurrVal + "_on.gif";
	}
    else if (strCookieVal.match(strCurrVal))
    {
    	return;
    }
   	else
    {
		objImg.src = strPath + "fsize_" + strCurrVal + "_on.gif";
	}
}

function getFCookie(param) {
	var tmpCookie = document.cookie.split(";");
	var	kv;

	for (var i in tmpCookie) {
		kv = tmpCookie[i].split("=");
		if (2 == kv.length) {
			kv[0] = kv[0].replace(/(^\s+)|(\s+$)/g, "");
			if (param == kv[0]) {
				kv[1] = kv[1].replace(/(^\s+)|(\s+$)/g, "");
				return	kv[1];
			}
		}
	}
	
	return	"";
}

var strCurrFSizeCookie = getFCookie("fsize");

if ("" == strCurrFSizeCookie) {
	strCurrFSizeCookie = "m";
}

function initFontSize() {
	changeFsizeBtn(strCurrFSizeCookie, 1);
}

function saveReserveCookie() {
	var	validTime = 0;
	var params = window.location.search.substring(1).split("&");
	var	kv;

	for (var i in params) {
		kv = params[i].split("=");
		if (2 == kv.length) {
			kv[0] = kv[0].replace(/(^\s+)|(\s+$)/g, "");
			if ("aAId" == kv[0] || "aALang" == kv[0] || "aAHtL" == kv[0]) {
				kv[1] = kv[1].replace(/(^\s+)|(\s+$)/g, "");

				if (0 == validTime) {
					expString = "";
				}
				else {
					setDate = new Date();
					setDate.setTime(setDate.getTime() + (validTime * 60 * 60 * 1000));
					expDate = setDate.toGMTString();
					expString = ";expires=" + setDate.toGMTString();
				}
				
			    document.cookie = kv[0] + "=" + escape(kv[1]) + "; path=/" + expString;
			}
		}
	}
	
	return	"";
}

