function addLoadEvent(func) { 
	  var oldonload = window.onload; 
	  if (typeof window.onload != 'function') 
	  { 
	    window.onload = func; 
	  } 
	  else
	  { 
	    window.onload = function() 
		{ 
	      if (oldonload) 
		  { 
	        oldonload(); 
	      } 
	      func(); 
	    } 
	  } 
} 
$.FontSizer = {
	defaultsize: 75,
	incrrate: 10,
	level: 0,
	min: -2, 
	max: 5,
	cookiename: 'wstw_font',

	Init : function() {
		var level = ($.cookie($.FontSizer.cookiename) != null) ? parseInt($.cookie($.FontSizer.cookiename)) : 0;
		$.FontSizer.SetFontSize(level);
	},

	Increase : function() {
		if(($.FontSizer.level) + 1 <= $.FontSizer.max) {
			$.FontSizer.SetFontSize(parseInt($.FontSizer.level) + 1);
		}
	},

	Reset : function() {
		$.FontSizer.SetFontSize(0);
	},

	Decrease : function() {
		if(($.FontSizer.level - 1) >= $.FontSizer.min) {
			$.FontSizer.SetFontSize(parseInt($.FontSizer.level) - 1);
		}
	},
	
	SetFontSize: function(level) {
		$.FontSizer.level = level;
		$.cookie($.FontSizer.cookiename, level, { expires: 14 } );
		var fontsize = parseInt( $.FontSizer.defaultsize + level*$.FontSizer.incrrate ) + "%";
		//$("body").css( "fontSize", fontsize );
	    document.getElementsByTagName('body')[0].style.fontSize =fontsize;
	}

};
$.cookie = function(name, value, options) {
    if (typeof value != 'undefined') {
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString();
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } 
	else {
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = cookies[i];
				while (cookie.charAt(0)==' '){ 
					cookie = cookie.substring(1,c.length);
				}
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

window.onload = function()  {
	$.FontSizer.Init();;
};
