
function sinit()
{
}

function documentObj()
{
/*   this.ids       = new Array('body', 'bheader', 'informations', 'menu', 'content'); */
   this.ids       = new Array('bheader', 'informations', 'content');
   this.ids_nbr   = this.ids.length;
   this.fonts     = new Array();
   this.heights   = new Array();
   this.applyCss  = applyCss;
   this.ratio     = 1.3;
   deltaSize      = loadInitVals();
   this.deltaSize = 0;

   for (i=0; i<this.ids_nbr; i++)
   {
      el = document.getElementById(this.ids[i]);
      if (el!=null)
      {
         with (el)
         {
            size = parseInt(el.style.fontSize);
            this.fonts[i]   = size;
            this.heights[i] = Math.round(size*this.ratio);
         }
      }
   }
   this.applyCss(deltaSize, true);

}


function applyCss(delta, init)
{
   change = false;
   max = 25;
   min = 5;

   for (i=0; i<this.ids_nbr; i++)
   {
      el = document.getElementById(this.ids[i]);
      if (el!=null)
      {
         with (el)
         {
            if (delta==0)
            {
               size           = this.fonts[i];
               this.deltaSize = 0;
            }
            else
            {
               size           = parseInt(el.style.fontSize) + delta;
            }

            if ( el.style.fontSize && ((size > 5 && size < 30) || init) )
            {
               if (size <= min)  size = min+1;
               if (size >= max) size = max-1;

               style.fontSize			= size	+ "px" ;
  		         style.lineHeight		= Math.round(size*this.ratio) + "px" ;
               change               = true;
            }
         }
      }
   }

   if (change)
   {
      this.deltaSize += delta;
      saveInitVals(this.deltaSize);
   }
}


function saveInitVals(deltaSize)
{
   var expire = new Date ();
	expire.setTime (expire.getTime() + (6000 * 24 * 3600000)); //expires in 6 days from users clock
	expire = expire.toGMTString();

	document.cookie="deltaSize=" + deltaSize + "; path=/; expires=" + expire;
}


function loadInitVals()
{
	deltaSize = 0 ;
	if (document.cookie)
   {
		tempArray = document.cookie.split(";");
		for (tA = 0; tA < tempArray.length; tA++)
		{
		   if (tempArray[tA].indexOf('deltaSize') > -1)	 //found the font section in cookie
         {
			   fontValue = tempArray[tA].split("=")
			   deltaSize = parseInt(fontValue[1]);
			}
      }
   }

   return deltaSize ;
}
