// Enlarge/Shrink font-sizes script  ** version 1.3 **
var FontSzConfig = {
  "doClientSide" : false,  // Relies by default on server-side functions.
  "fsBlockSelector" : "div.fontsizer li",
  "fontUpSelector" : ".up a",
  "fontDownSelector" : ".dwn a",
  "minSize" : 1,
  "maxSize" : 7
};
currentFontSize = 1; // default font size

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.fsBlockSelector + FontSzConfig.fontUpSelector);
  var _fontDn = document.getElementsBySelector(FontSzConfig.fsBlockSelector + FontSzConfig.fontDownSelector);

  if ((_fontUp[0] != null) && (_fontDn[0] != null))
  {
    _fontUp[0].onclick = function() { resizeFont(currentFontSize + 1); return false; };
    _fontDn[0].onclick = function() { resizeFont(currentFontSize - 1); return false; };
  }
  else
  {
    var _fszLinks = document.getElementsBySelector(FontSzConfig.fsBlockSelector + " a");
    for (var i = 0; i<_fszLinks.length; i++)
    {
      var _theLink = _fszLinks[i];
      var _Size = _theLink.href.replace(/.+setFontSize=(\d+).*/, "$1"); 
      if (_Size != "")
      {
        _theLink.fontSize = parseInt(_Size);
        _theLink.onclick = function() { resizeFont(this.fontSize); 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 = document.body.className;
  if ((_otherClasses != null) && (_otherClasses != ""))
  {
    _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