  var defaultfont = 87.5;
    function get_size_value(str) {
    str.replace("%", "");
    var val = parseInt(str);
    if (isNaN(val)) return defaultfont; else return val;
    }

    function apply_font_size(id, modifier) {
        var elem = document.getElementById(id) || document.body;
        var val = get_size_value(elem.style.fontSize);
        val = modifier(val);
        elem.style.fontSize = val + "%";
    }

    function set_text_size() {
        apply_font_size("page", function (v) {
            var value = readCookie( "thlPortalTextSize" );
            if( value != null ){
                return value;
            }else{
                return defaultfont;
            }
        });
		
		var style = readCookie( "thlPortalStyle" );
		if (style && d.getElementById('page')) d.getElementById('page').className = style;
    }

  function text_size_reset() {
        apply_font_size("page", function (v) {
          var value = defaultfont;
            createCookie( "thlPortalTextSize", value, 0 );
            return value;
        });
    }

    function text_size_increase() {
        apply_font_size("page", function (v) {
          var value;
          if ( v < (defaultfont + 35) ) {
            value = v + 10;
          } else {
             value=v;
          }
            createCookie( "thlPortalTextSize", value, 0 );
            return value;
        });
    }

    function text_size_decrease() {
        apply_font_size("page", function (v) {
           var value;
           if ( v > (defaultfont - 20) ) {
             value = v - 10;
           } else {
             value=v;
          }
            createCookie( "thlPortalTextSize", value, 0 );
            return value;
        });
    }

    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 = "";


       var str = document.location.hostname.split('.').splice(0,1)
       document.cookie = name+"="+value+expires+"; path=/"+((str.length<2) ? "" : "; domain=."+ str.join('.'));
    }

    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;
    }

    function eraseCookie(name) {
        createCookie(name,"",-1);
    }

  function set_style(o) {
  var p = d.getElementById('page'),
      style = (p.className.length) ? p.className.split(' ') : Array(3);
  style[0] = o.theme || (style[0] || '');
  style[1] = o.font || (style[1] || '');
  style[2] = o.kern || (style[2] || '');

  p.className = style.join(' ');

  createCookie('thlPortalStyle', p.className, 0);

  return (false);
}