/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var standardFontSize =  80;
var minFontSize =  60;
var maxFontSize = 120;
var defaultStyle = "Standard";


    function basedStyles(){
            var currentFontSize = standardFontSize;
            ScaleFontSize(0);
    }


    function ScaleFontSize(sizeDifference){

    if(sizeDifference!=0){
    var cookieSize = readCookie("fontSize");
            var	currentFontSize = (cookieSize) ? cookieSize : standardFontSize;
    currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 5);

    if(currentFontSize > maxFontSize){
                    currentFontSize = maxFontSize;
            }else if(currentFontSize < minFontSize){
                    currentFontSize = minFontSize;
            }
    //alert(currentFontSize);
    setFontSize(currentFontSize);
    writeCookie("fontSize", currentFontSize, 500);
    }else{
        setFontSize(standardFontSize);
        writeCookie("fontSize", standardFontSize, 500);
    }

}

    function setFontSize(fontSize){
//		var stObj = (document.getElementById) ? document.getElementById('boxarea') : document.all('boxarea');
            document.body.style.fontSize = fontSize + '%';
    createCookie("fontSize", fontSize, 500);
}


    function writeCookie(name,value,days) {
  if (value) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    document.cookie = name+"="+value+expires+"; path=/";}
    }

function createCookie(name,value,days) {
      if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
      }else{ var expires = "";
      document.cookie = name+"="+value+expires+"; path=/";}
    }

    function readCookie(name) {
      var nameEQ = name + "=";
      var ca = document.cookie.split(';');
      for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
      }
      return null;
    }


    window.onload = function(e) {
        var cookieStyle = readCookie("tipeStyle");
            var currentStyle = cookieStyle ? cookieStyle : "Standard";

                var cookieSize = readCookie("fontSize");
                var	currentFontSize = (cookieSize) ? cookieSize : standardFontSize;

        if (cookieStyle==null){
            createCookie("tipeStyle", defaultStyle, 500);
                    createCookie("fontSize", currentFontSize, 500);
        }else{
            //alert(currentStyle);
            //alert(currentFontSize);
            setFontSize(currentFontSize);
        }
    };



