
// ----------------------------------------------
// StyleSwitcher functions written by Paul Sowden
// http://www.idontsmoke.co.uk/ss/
// - - - - - - - - - - - - - - - - - - - - - - -
// For the details, visit ALA:
// http://www.alistapart.com/stories/alternate/
//
// nifty StyleSwitcher scripts modified by Aaron Jones 10/10/2002
// ----------------------------------------------

function setActiveStyleSheet(title, reset, cssFile, cssSize) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) {
        a.disabled = false;
      }
    }
  }
  if (reset == 1) {
    createCookie("css_file", cssFile, 0);
    createCookie("css_size", cssSize, 0);
  }
}

function setStyle() {
	var style = readCookie("wstyle");
	if (style != null) {
	  setActiveStyleSheet(style, 0);
	}
}

// ----------------------------------------------
// end StyleSwitcher functions
// ----------------------------------------------


// ----------------------------------------------

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+"";
}

// ----------------------------------------------

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 displayDiv(divNameStr, showDiv) {
  if (divNameStr == null) {
      // do nothing
  } else  {
      var docElem;
      
      if (document.getElementById) {
          docElem = document.getElementById(divNameStr);
      } else if (document.all) {
          docElem = document.all[divNameStr];
      }

      if (docElem != null) {
         if (showDiv) {
             docElem.style.display = 'block';
         } else {
             docElem.style.display = 'none';
         }
      }
  }
}

function bfnbr(s, gobble) {
  var m = "SWRPOKGDLMVJZCXNEIQU";
  var x = "";
  if (s == null) {
    return ("");
  }
  
  for (i=0; i < s.length; i++) {
    if (gobble) {
      if (s.charAt(i) == '.') {
        x += ".";
      } else if (s.charAt(i) == '-') {
        x += "-";
      } else {
        var c = s.charAt(i) - '0';
        x += m[c];
      }
    } else {
      if (s.charAt(i) == '.') {
        x += ".";
      } else if (s.charAt(i) == '-') {
        x += "-";
      } else {
        x += (m.indexOf(""+s.charAt(i)) % 10);
      }
    }
  }
  
  return (x);
}


//===============================================================================
// ROT 13 code
//===============================================================================
// This work is hereby released into the Public Domain. To view a copy
// of the public domain dedication, visit 
// http://creativecommons.org/licenses/publicdomain/
// or send a letter to 
// Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
// origin: 2000-01-08 nospam@geht.net http://tools.geht.net/rot13.html
// Use at own risk.
var rot13map;

// The problem is that JavaScript 1.0 does not provide a Char to Numeric
// value conversion. Thus we define a map. Because there are 64K UniCode
// characters, this map does not cover all characters.
function rot13init()
{
  var map = new Array();
  var s   = "abcdefghijklmnopqrstuvwxyz";
  
  for (i=0; i<s.length; i++)
    map[s.charAt(i)] = s.charAt((i+13)%26);
  for (i=0; i<s.length; i++)
    map[s.charAt(i).toUpperCase()] = s.charAt((i+13)%26).toUpperCase();
  return map;
}

function rot13(a)
{
  if (!rot13map)
    rot13map=rot13init();
  s = "";
  for (i=0; i<a.length; i++)
    {
      var b = a.charAt(i);

      s	+= (b>='A' && b<='Z' || b>='a' && b<='z' ? rot13map[b] : b);
    }
  return s;
}
//===============================================================================

 