var intSize = 100;
var intMin = 20;
var intStd = 80;
var intMax = 10000;
var intPer = 10;

function fontsize() {
    try {
        intSize = parseInt(getCookieInfo("strctrlsize"));
    } catch (e){
        intSize = intStd;
    }
    if ( intSize == "" || !( intMin <= intSize && intSize <= intMax ) ) {
        intSize = intStd;
    }
    if ( intSize != intStd ) {
        changeSize();
    }
}

function strctrl( ctrlType ) {
    switch ( ctrlType ) {
    case 1:
        intSize = eval(intSize) - intPer;
        if ( intSize < intMin ) {
            intSize = intMin;
        }
        break;
    case 2:
        intSize = intStd;
        break;
    case 3:
        intSize = eval(intSize) + intPer;
        if ( intSize > intMax ) {
            intSize = intStd;
        }
        break;
    }
    saveCookieInfo("strctrlsize", intSize);
    changeSize();
}

function changeSize() {
	var vastr_tagnames = new Array("h1", "h2", "h3", "h4", "h5", "h6", "p", "a", "span");
    var j;
    if ( document.getElementById ) {
    	for ( j=0; j<vastr_tagnames.length; j++) {
	        var nodeList = document.body.getElementsByTagName( vastr_tagnames[j] );
	        var i;
	        for ( i=0; i < nodeList.length; i++){
    	        if ( nodeList[i].hasChildNodes() ) {
	                if ( nodeList[i].firstChild.nodeType == 3) {
                    nodeList[i].style.fontSize = intSize + "%";
    	            }
    	        }
    		}
        }
    }
}

function getCookieInfo( cookietype ){
    var ret = "";
    if ( document.cookie.indexOf( cookietype ) != -1) {
        try {
            var cookieList = document.cookie.split(";");
            for ( var i=0; i < cookieList.length; i++ ){
                var cookieInfo = cookieList[i].replace(" ", "");

                if ( cookieInfo != "" ){
                    var cookieData = cookieInfo.split("=");
                    if ( cookieData.length == 2 ){
                        var type = cookieData[0];
                        var data = cookieData[1];
                        if ( type == cookietype ){
                            ret = data;
                            break;
                        }
                    }
                }
            }
        } catch (ex) {
            return "";
        }
    }
    return ret;
}

function saveCookieInfo( cookietype, savedata ){
    var ret = false;
    var cookiedata= cookietype + "=";
    if ( savedata != "" ) {
        cookiedata = cookiedata + savedata;
        cookiedata = cookiedata + ";expires=Fri, 31-Dec-2030 0:0:0; path=/;";
        try {
            document.cookie = cookiedata;
            ret = true;
        } catch (ex) {
            return false;
        }
    }
    return ret;
}

