function getCookie(name)
{
  var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0) {
    begin = dc.indexOf(cname);
    if (begin != -1) {
      begin += cname.length;
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
			 return unescape(dc.substring(begin, end));
    }
  }
  return null;
}





function setCookie(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 delCookie (name,path,domain) 
{
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}



var firstCall = true;
function changeFontsize(fSize, increment) 
{

//change these for max and minimum font percentages.

var maxsize=200;
var minsize=60;
var  unit="%";//use % as style sheet uses relative values

  if (firstCall) 
  {
    firstCall = false;
    if (increment != "")
		{
      changeFontsize('100', '');
    } 
  }
  if (document.getElementsByTagName) 
  {
 //  tags = new Array ("p", "li", "h1", "h2", "h3", "h4", "h5", "h6", "body");
    tags = new Array (  "body");
    for (j=0; j<tags.length; j++)
     {
      var getElement = document.getElementsByTagName(tags[j]);
      var eachElement, currentFontSize, fontIncrease, newFontSize;
     
      for (i=0; i<getElement.length; i++)
       {
        eachElement = getElement[i];
        if (increment != "")
         {
          currentFontSize = parseInt(eachElement.style.fontSize);
          fontIncrease = parseInt(increment);
          newFontSize = currentFontSize + fontIncrease;
         }
        else 
        if (fSize != "")
        {
         newFontSize = parseInt(fSize);
     
        }
        if (tags[j] == "li")
          eachElement.style.lineHeight = Math.round(newFontSize*1.2) + unit;
        else
          eachElement.style.lineHeight = Math.round(newFontSize*1.5) + unit;
       /*
			  if (fSize != "") 
        {
          switch(tags[j])
           {
        case "h1": newFontSize += 4; break;
          case "h2": newFontSize += 3; break;
          case "h3": newFontSize += 2; break;
          case "h4": newFontSize += 1; break;
          case "h5": newFontSize += 1; break;
          case "h6": newFontSize += 1;
				
					
            }
        }
				*/
     
        if (newFontSize>=maxsize)
        {
        (newFontSize=maxsize);
        }
         if (newFontSize<=minsize)
        {
        (newFontSize=minsize);
        }

        eachElement.style.fontSize = newFontSize + unit;
        setCookie('fontSize', newFontSize,'7');
      }
    }
  }
}



