// font sizer changer
var prefsLoaded = false;
var defaultFontSize = 75;
var currentFontSize = defaultFontSize;
function revertStyles(){
 currentFontSize = defaultFontSize;
 changeFontSize(0);
}

function changeFontSize(sizeDifference){
 currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 10);
 if(currentFontSize > 100){
  currentFontSize = 100;
 }else if(currentFontSize < 60){
  currentFontSize = 60;
 }

 setFontSize(currentFontSize);
};

function setFontSize(fontSize){
 var stObj = (document.getElementById) ? document.getElementById('content_area') : document.all('content_area');
 document.body.style.fontSize = fontSize + '%';
 //alert (document.body.style.fontSize);
};
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 expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
};
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 dpionload(func) {
if(typeof window.addEventListener != 'undefined')
{window.addEventListener('load', func, false);}
else if(typeof document.addEventListener != 'undefined')
{document.addEventListener('load', func, false);}
else if(typeof window.attachEvent != 'undefined')
{window.attachEvent("onload", func);}
else{ if(typeof window.onload == 'function') {
var prevonload = onload; window.onload = function() {prevonload();func();};} 
else { window.onload = func;}}}

dpionload(setUserOptions);
function setUserOptions(){
 if(!prefsLoaded){
  cookie = readCookie("fontSize");
  currentFontSize = cookie ? cookie : defaultFontSize;
  setFontSize(currentFontSize);
  prefsLoaded = true;
 }
}

window.onunload = saveSettings;
function saveSettings()
{
  createCookie("fontSize", currentFontSize, 365);
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

function getActiveStyleSheet()
{
   return "title";
}
    
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (version < 7) && (document.body.filters))
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id=\'" + img.id + "\' " : ""
            var imgClass = (img.className) ? "class=\'" + img.className + "\' " : ""
            var imgTitle = (img.title) ? "title=\'" + img.title + "\' " : "title=\'" + img.alt + "\' "
            var imgStyle = "display:inline-block;" + img.style.cssText
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod=\'scale\');\"></span>"
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }
}
//here we don't care about browser compatiblity, it's for IE anyways.
if(window.attachEvent) window.attachEvent("onload", correctPNG);
