

/*Javascript for FontSize adjustment tool*/


function FontSizer() {
    this.iSize=16;
    this.defaultSize = 16;
    this.maxSize = 20;
    this.minSize = 14;
    
    this.init = init;
    this.adjust = adjust;
    this.reset = reset;

    function init() {
    
    	if(!document.getElementById)
    		return;
    	var size;
    	var oStyle=document.body.style;
    	size=getCookie("fontSize");
    	if(isNaN(parseFloat(size)) || size > this.maxSize || size< this.minSize) {
    		size = this.defaultSize;
    		}
    	
    	size = parseInt(size);
    	oStyle.fontSize = size + 'px';
    	setCookie('fontSize', size , 0, '/');
    	}
    
    function reset() {
    	if(!document.getElementById)
    		return;
    	var size;
    	var oStyle=document.body.style;
    	size = this.defaultSize;
    	this.iSize = size;	
    	oStyle.fontSize = size + 'px';
    	deleteCookie("fontSize","/");
    	}
    
    
    function adjust(n) {
    	if(!document.getElementById)
    		return;
    	var oStyle=document.body.style;
    	size=getCookie("fontSize");
    	if(isNaN(parseFloat(size)) || size > this.maxSize || size < this.minSize) {	
    		size = this.iSize;
    		}
    	size = parseInt(size);	
    	if((size + n ) > this.maxSize){
    		alert('You are already at the largest font size available. If you still have trouble reading the site, you may wish to adjust the font size preferences in your web browser.');
    		return;
    		}
    	else if((size + n ) < this.minSize) {
    		alert('You are already at the smallest font size available.');
    		return;
    		}
    	else size = size + n;
    
    	oStyle.fontSize= size + 'px';
    	this.iSize = size;
    	setCookie('fontSize', size, 0 ,'/');
    	}
    
    
    function setCookie(name,value,days,path,domain,secure) {
      var expires, date;
      if (typeof days == "number") {  		
        date = new Date();
        date.setTime( date.getTime() + (days*24*60*60*1000) ); 
    		expires = date.toGMTString();
      }
     
      if((typeof days == "number") && (days == 0))
      	document.cookie = name + "=" + escape(value) +
    	    "; expires="  +
    	    ((path) ? "; path=" + path : "") +
    	    ((domain) ? "; domain=" + domain : "") +
    	    ((secure) ? "; secure" : "");
      else
    	  document.cookie = name + "=" + escape(value) +
    	    ((expires) ? "; expires=" + expires : "") +
    	    ((path) ? "; path=" + path : "") +
    	    ((domain) ? "; domain=" + domain : "") +
    	    ((secure) ? "; secure" : "");
    }
    
    
    function getCookie(name) {
      var nameq = name + "=";
      var c_ar = document.cookie.split(';');
      for (var i=0; i<c_ar.length; i++) {
        var c = c_ar[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameq) == 0) return unescape( c.substring(nameq.length, c.length) );
      }
      return null;
    }
    
    
    function deleteCookie(name,path,domain) {
      if (getCookie(name)) {
        document.cookie = name + "=" +
          ((path) ? "; path=" + path : "") +
          ((domain) ? "; domain=" + domain : "") +
          "; expires=Thu, 01-Jan-70 00:00:01 GMT";
      }
    }
}
/*End Javascript for FontSize adjustment tool*/