﻿// #### needs to be placed on the bottom of the page 

var browser = navigator.userAgent.toLowerCase();
var id = (document.getElementById) ? true : false;
var IEx = ((browser.indexOf('msie') != -1) && id) ? true : false;
var NS6 = ((browser.indexOf('gecko') != -1) && id) ? true : false;
var Applicable = true;
if (IEx || NS6) {
    elObj1 = (document.getElementById) ? document.getElementById('tResize') : document.all('tResize');
    if (elObj1 != null) {
        var fSize = null; //GetCookie('fSize');
        if (fSize == null) {
            elObj1.style.fontFamily = elObj1.style.fontFamily;
            elObj1.style.fontSize = elObj1.style.fontSize = 14 + 'px';
            //	document.fontForm.fontSize.selectedIndex[4]
        }
        else {
            elObj1.style.fontSize = fSize + 'px';
            //if (fSize > 5 && fSize < 21){
            //	document.fontForm.fontSize.options[(fSize-6)].selected = true;
            //}
        }
        subObjSet("td")
        subObjSet("p")
        subObjSet("font")
        subObjSet("span")
        //	for (i=0;i<elObj1.getElementsByTagName("font").length; i++) {
        //		elObj1.getElementsByTagName("font").item(i).style.fontSize = (parseInt(elObj1.style.fontSize)+1)+'px';
        //	}
    }
    else
        Applicable = false;
}


function subObjSet(tgName) {
    for (i = 0; i < elObj1.getElementsByTagName("td").length; i++) {
        elObj1.getElementsByTagName("td").item(i).style.fontSize = (parseInt(elObj1.style.fontSize)) + 'px';
        //elObj1.getElementsByTagName("td").item(i).style.lineHeight = (parseInt(elObj1.style.lineHeight)+2)+'px'; //"normal"; 
        elObj1.style.fontFamily = elObj1.style.fontFamily;
    }
}

function subObjUp(tgName) {

    for (i = 0; i < elObj1.getElementsByTagName("td").length; i++) {
        elObj1.getElementsByTagName("td").item(i).style.fontSize = (parseInt(elObj1.style.fontSize) + 1) + 'pt';
        //elObj1.getElementsByTagName("td").item(i).style.lineHeight = (parseInt(elObj1.style.lineHeight)+2)+'pt'; //"normal"; 
        elObj1.style.fontFamily = elObj1.style.fontFamily;
    }

}

function fontObjUp() {
    if (!Applicable) return;
    if ((parseInt(elObj1.style.fontSize) < 21) || (elObj1.style.fontSize == null)) {
        subObjDwn("td")
        subObjDwn("p")
        subObjDwn("font")
        subObjDwn("span")

        elObj1.style.fontSize = (parseInt(elObj1.style.fontSize) + 1) + ((IEx) ? 'pt' : 'px').toString();
        //elObj1.style.lineHeight = (parseInt(elObj1.style.lineHeight)+2)+'px'; //"normal"; 
        elObj1.style.fontFamily = elObj1.style.fontFamily;
        selectIn = (parseInt(elObj1.style.fontSize) - 6)
        //if (selectIn > 0 && selectIn < 15) document.fontForm.fontSize.options[selectIn].selected = true;
    }
}

function subObjDwn(tgName) {

    for (i = 0; i < elObj1.getElementsByTagName(tgName).length; i++) {
        elObj1.getElementsByTagName(tgName).item(i).style.fontSize = (parseInt(elObj1.style.fontSize) - 1) + ((IEx) ? 'pt' : 'px').toString();
        elObj1.getElementsByTagName(tgName).item(i).style.fontFamily = elObj1.style.fontFamily;
    }

}

function fontObjDwn() {
    if (!Applicable) return;
    if (parseInt(elObj1.style.fontSize) > 5) {
        subObjDwn("td")
        subObjDwn("p")
        subObjDwn("font")
        subObjDwn("span")
        elObj1.style.fontFamily = elObj1.style.fontFamily;
        elObj1.style.lineHeight = "normal";
        elObj1.style.fontSize = (parseInt(elObj1.style.fontSize) - 1) + 'px';
        selectIn = (parseInt(elObj1.style.fontSize) - 6)
        //	if (selectIn > 0 && selectIn < 15) document.fontForm.fontSize.options[selectIn].selected = true;
    }
}

function selectFont() {
    //fSize = (document.fontForm.fontSize.selectedIndex+6);

    subObjSet("td")
    subObjSet("p")
    subObjSet("font")
    subObjSet("span")
    elObj1.style.fontSize = fSize + 'px';
}

function saveSize() {
    var expDays = 1000; // number of days the cookie should last
    var expDate = new Date();
    expDate.setTime(expDate.getTime() + (24 * 60 * 60 * 1000 * expDays));
    SetCookie('fSize', parseInt(elObj1.style.fontSize), expDate);
}

function getCookieVal(offset) {
    var endstr = document.cookie.indexOf(";", offset);
    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return getCookieVal(j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}

function SetCookie(name, value) {
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape(value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}