// Enlarge/Shrink font-sizes script  ** version 1.3 **
var FontSzConfig = new Array ();
FontSzConfig["fontUpSelector"] = "div.fontsizer li.up a";
FontSzConfig["fontDownSelector"] = "div.fontsizer li.dwn a";
FontSzConfig["minSize"] = 1;
FontSzConfig["maxSize"] = 7;
FontSzConfig["doClientSide"] = false;  // Relies by default on server-side functions.
currentFontSize = 1;

function initFontSizer()
{
  var zoomclass = document.body.className.match(/\bzoom(\d+)\b/);
  currentFontSize =  zoomclass ? parseInt(zoomclass[1]) : currentFontSize;
  if (FontSzConfig["doClientSide"]) { applyFontSize(); }

  var fontUp = document.getElementsBySelector(FontSzConfig["fontUpSelector"])[0];
  var fontDn = document.getElementsBySelector(FontSzConfig["fontDownSelector"])[0];

  if ((fontUp != null) && (fontDn != null))
  {
    fontUp.onclick = function() { resizeFont(currentFontSize + 1); return false; };
    fontDn.onclick = function() { resizeFont(currentFontSize - 1); return false; };
  }

  return;
}


function resizeFont(newSize)
{
  newSize = (newSize < FontSzConfig["minSize"]) ? FontSzConfig["minSize"] : (newSize > FontSzConfig["maxSize"]) ? FontSzConfig["maxSize"] : newSize;
  setCookie("fontSize", newSize, "/");
  currentFontSize = newSize;
  applyFontSize();
  return;
}

function applyFontSize()
{
  if (FontSzConfig["doClientSide"])
  {
    var cookieFontSize = getCookieValue("fontSize");
    if (cookieFontSize)
    {
      cookieFontSize = parseInt(cookieFontSize);
      if (cookieFontSize != "NaN")
      {
        currentFontSize = (cookieFontSize > 10) ? currentFontSize : (cookieFontSize > FontSzConfig["maxSize"]) ? FontSzConfig["maxSize"] : cookieFontSize;
      }
    }
  }

  var otherClasses = "";
  if ((document.body.className != null) && (document.body.className != ""))
  {
    otherClasses = document.body.className;
    otherClasses = otherClasses.replace(/\s*zoom\d+/g, "");
    otherClasses = otherClasses.replace(/(^\s+|\s+$)/g, "");
    if ((otherClasses != "")) { otherClasses += " "; }
  }
  document.body.className = otherClasses + "zoom" + currentFontSize;
  return;
}




// -----------------------------------------------------------------

function setCSS(theURL)
{
  cssSwitch(theURL)
  setCookie("CSSfile", theURL, "/");
}


function cssSwitch(theURL)
{
  if (document.getElementsByTagName && theURL && (theURL != ""))
  {
    var cssLinks = getCssLinks();

    var i = cssLinks.length
    if (i+1) { do
    {
      var link = cssLinks[i];
      if ( (link.rel != null) && (link.rel.indexOf("stylesheet") > -1) && ( (link.media.indexOf("screen") > -1) || (link.media == null) ) )
      {
        link.disabled = true;
        if (stripHref(link.href) == stripHref(theURL))
        {
          link.disabled = false;
        }
      }
    } while (i--); }
  }
  return false;
};


function getCssLinks(theMedia)
{
  if (!document.getElementsByTagName) return null;

  if (theMedia == null) { theMedia = "screen"; }
  var theLinks = new Array();

  var allLinks = document.getElementsByTagName("link");
  var i = allLinks.length
  if (i+1) { do
  {
    var link = allLinks[i];
    if ( (link.rel != null) && (link.rel.indexOf("stylesheet") > -1) && ( (link.media.indexOf(theMedia) > -1) || (link.media == null) ) )
    {
      theLinks[theLinks.length] = link;
    }
  } while (i--); }

  return theLinks;
}




// Depends on utils_1.0.js