var message="Sorry, you can't go home until you're better.";

function home() {
alert(message);
location.href = "http://" + location.hostname + location.pathname;
}

function previous() {
location.href = previous_page;
}

function next() {
location.href = next_page;
}

function footnote(url) {
        window.open('/footnotes/' + url, 'footnotePane', 'width=600,height=400,dependent,scrollbars')
}

function newWindow(url) {
        window.open(url, 'newPane', '')
}

function imageSwap(daImage, daSrc){
  var objStr,obj;

  // Check to make sure that images are supported in the DOM.
  if(document.images){
    // Check to see whether you are using a name, number, or object
    if (typeof(daImage) == 'string') {
      // This whole objStr nonesense is here solely to gain compatability
      // with ie3 for the mac.
      objStr = 'document.' + daImage;
      obj = eval(objStr);
      obj.src = daSrc;
    } else if ((typeof(daImage) == 'object') && daImage && daImage.src) {
      daImage.src = daSrc;
    }
  }
}

function WM_preloadImages() {

  // Don't bother if there's no document.images
  if (document.images) {
    if (typeof(document.WM) == 'undefined'){
      document.WM = new Object();
    }
    document.WM.loadedImages = new Array();
    // Loop through all the arguments.
    var argLength = WM_preloadImages.arguments.length;
    for(arg=0;arg<argLength;arg++) {
      // For each arg, create a new image.
      document.WM.loadedImages[arg] = new Image();
      // Then set the source of that image to the current argument.
      document.WM.loadedImages[arg].src = WM_preloadImages.arguments[arg];
    }
  }
}

function setMsg(msg) {
  window.status = msg
  return true
}

var pageColor = 15;
var moody = 0;

function upLevel() {
    setMoodyObjects(13);
    if (pageColor < 16) {pageColor += 2};
    document.bgColor=newBgColor();
    document.fgColor=newFgColor();
    if (pageColor > 15) {
       document.linkColor = randomColor();
       document.vlinkColor = randomColor();
       getobject("menu_box").style.backgroundColor = randomColor();
    }
}

function downLevel() {
    setMoodyObjects(17);
    if (pageColor > 2) {pageColor -= 2};
    document.bgColor=newBgColor();
    document.fgColor=newFgColor();
    document.linkColor = pageLinkColor;
    document.vlinkColor = pageVlinkColor;
}

function setMoodyObjects(normal) {
    if (!moody) {
        moody = 1;
        getobject("left_panel").style.backgroundImage = "";
        getobject("adam").src = "/lucid-images/adam.gif";
    } else {
        if (pageColor == normal) {
            moody = 0;
            getobject("left_panel").style.backgroundImage = "url(/lucid-images/background01.jpg)";
            getobject("menu_box").style.backgroundColor = "";
            getobject("adam").src = "/lucid-images/adam.jpg";
        }
    }
}

function newBgColor() {
   if (pageColor > 15) {
       return randomColor();
   } else {
      newDigit = hexDigit(pageColor);
      return "#" + newDigit + newDigit + newDigit + newDigit + newDigit + newDigit;
   }
}

function newFgColor() {
   if (pageColor > 15) {
       return randomColor();
   } else {
      newDigit = hexDigit(15 - pageColor);
      return "#" + newDigit + newDigit + newDigit + newDigit + newDigit + newDigit;
   }
}

function randomColor(){
      return "#" + randomDigit() + randomDigit() + randomDigit() + randomDigit() +              randomDigit() + randomDigit();
}

function randomDigit() {
   return hexDigit(Math.floor(Math.random()*16));
}

function hexDigit(k) {
   switch (k) {
      case 0 : return '0';
      case 1 : return '1';
      case 2 : return '2';
      case 3 : return '3';
      case 4 : return '4';
      case 5 : return '5';
      case 6 : return '6';
      case 7 : return '7';
      case 8 : return '8';
      case 9 : return '9';
      case 10 : return 'A';
      case 11 : return 'B';
      case 12 : return 'C';
      case 13 : return 'D';
      case 14 : return 'E';
      default : return 'F';
   }
}

function getobject(obj) {
    if (document.getElementById)
        return document.getElementById(obj)
    else if (document.all)
        return document.all[obj]
    else if (document.layers)
        return document.layers[obj]
}

