﻿/***ZT 10/28/08 adding function to increase elements in td and li tags***/
/***a tags are commented out because it will increase the menu links as well ***/
/********jscript file, should allow users to increase/decrease the font size******/
/****** global variables ******/
var str_cookieName = "fontSize";
var int_fontSize = 14;
var int_maxFontSize = 20;
var int_minFontSize = 10;
var int_increment = 2;
var int_unitType = 'px';
var min=10;
var max=20;

/****** check font size in cookie ******/ 
function handleFontSize(_override){
	var _domain='',_expires=getDate(),_path='/';
	if((readCookie(str_cookieName)=='')||(_override==true)){
		setCookie(str_cookieName,int_fontSize,_expires,_path);
	}else{
		int_fontSize=readCookie(str_cookieName);
	}
	setFontSize();
}

function setFontSize(str_value) {
	switch(str_value){
		case '+':(int_fontSize=parseInt(int_fontSize)+int_increment);break;
		case '-':(int_fontSize=parseInt(int_fontSize)-int_increment);break;
	}
	if(typeof(str_value)=="number")int_fontSize=str_value;
	if(int_fontSize > int_maxFontSize) {int_fontSize = int_maxFontSize;}
	if(int_fontSize < int_minFontSize) {int_fontSize = int_minFontSize;}

	//document.body.style.fontSize = (int_fontSize + 2 + "px");
	
//	//div tags
//	var div = document.getElementsByTagName('div');
//    for(i=0;i<div.length;i++) {
//      if(div[i].style.fontSize) {
//         var s = parseInt(div[i].style.fontSize.replace("px",""));
//      } else {
//         var s = 14;
//      }
//      if(s!=max) {
//         //s += 1;
//         s = int_fontSize;
//         }else {
//         s = int_maxFontSize - int_increment;
//      }
//      div[i].style.fontSize = s+"px"
//   }
//   //p tags
   	var p = document.getElementsByTagName('p');
    for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=max) {
         //s += 1;
         s = int_fontSize;
         }else {
         s = int_maxFontSize - int_increment;
      }
      p[i].style.fontSize = s+"px"
   }

   //td's
   var td = document.getElementsByTagName('td');
    for(i=0;i<td.length;i++) {
      if(td[i].style.fontSize) {
         var s = parseInt(td[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=max) {
         //s += 1;
         s = int_fontSize;
         }else {
         s = int_maxFontSize - int_increment;
      }
      td[i].style.fontSize = s+"px"
   }
//   
//   //span?
//   var span = document.getElementsByTagName('span');
//    for(i=0;i<span.length;i++) {
//      if(span[i].style.fontSize) {
//         var s = parseInt(span[i].style.fontSize.replace("px",""));
//      } else {
//         var s = 14;
//      }
//      if(s!=max) {
//         //s += 1;
//         s = int_fontSize;
//         }else {
//         s = int_maxFontSize - int_increment;
//      }
//      span[i].style.fontSize = s+"px"
//   }
   
   //li's
    var li = document.getElementsByTagName('li');
      for(i=0;i<li.length;i++) {
        if(li[i].style.fontSize) {
          var s = parseInt(li[i].style.fontSize.replace("px",""));
        } else {
          var s = 14;
       }
       if(s!=max) {
          //s += 1;
          s = int_fontSize;
          }else {
           s = int_maxFontSize - int_increment;
        }
       li[i].style.fontSize = s+"px"
     }
	 
   //a href's (links)
//    var a = document.getElementsByTagName('a');
//      for(i=0;i<a.length;i++) {
//        if(a[i].style.fontSize) {
//          var s = parseInt(a[i].style.fontSize.replace("px",""));
//        } else {
//          var s = 14;
//       }
//       if(s!=max) {
//          //s += 1;
//          s = int_fontSize;
//          }else {
//           s = int_maxFontSize - int_increment;
//        }
//       a[i].style.fontSize = s+"px"
//     }
	
	setCookie(str_cookieName,int_fontSize,getDate(),"/");
} 

function setCookie(str_name,str_value,str_expires,str_path,str_domain){
	var str_cookie=	str_name+'='+escape(str_value)
	+((str_expires)? ' ;expires='+str_expires.toGMTString() : '')
	+((str_path)? '; path='+str_path : '')
	+((str_domain)? '; domain='+str_domain : '');
	document.cookie=str_cookie;
}

function readCookie(_name){
	_name+="=";
	var _at=document.cookie.split(';');
	for(_i=0;_i<_at.length;_i++){
		 //alert(_at[_i]);
		var _st=_at[_i];
		while(_st.charAt(0)==' '){
			_st=_st.substring(1,_st.length);
		}
		if(_st.indexOf(_name)==0){
			return _st.substring(_name.length,_st.length);
		}
	}
	return('');
}

function getDate(){
	var date_now=new Date();
	date_now.setTime(date_now.getTime()+365*24*60*60*1000);
	return(date_now);
}

window.onload=function(){
	handleFontSize(false);
}
