var min=0.7;
var max=2;

function addLoadEvent(func) { 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function'){ 
		window.onload = func
	} else { 
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function increaseFontSize() {
   var p = document.getElementById('sitebody');
      if(p.style.fontSize) {
         var s = parseFloat(p.style.fontSize.replace("em",""));
      } else {
         var s = 1;
      }
      if(s!=max) {
         s += 0.1;
      }
      p.style.fontSize = s+"em"
      set_cookie ( "fontsize",  p.style.fontSize);
}

function decreaseFontSize() {
   var p = document.getElementById('sitebody');
      if(p.style.fontSize) {
         var s = parseFloat(p.style.fontSize.replace("em",""));
      } else {
         var s = 1;
      }
      if(s!=min) {
         s -= 0.1;
      }
      p.style.fontSize = s+"em";
      set_cookie ( "fontsize",  p.style.fontSize);
}   

function setFontSize() {
   var size = get_cookie( "fontsize" );
   var p = document.getElementById('sitebody');
   if(size != null )
   {
   	p.style.fontSize = size;
   }
} 
   
function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}
