/* 
*  Let us see if we have the right 
*  browser. 
*/ 

function Is() {
  var agent = navigator.userAgent.toLowerCase();
  this.major = parseInt(navigator.appVersion);
  this.minor = parseFloat(navigator.appVersion);
  this.ns = ((agent.indexOf('mozilla')!=-1) &&
((agent.indexOf('spoofer')==-1) &&
(agent.indexOf('compatible') == -1)));
  this.ns2 = (this.ns && (this.major == 3));
  this.ns3 = (this.ns && (this.major == 3));
  this.ns4b = (this.ns && (this.minor < 4.5));
  this.ns4 = (this.ns && (this.major = 4));
  this.ie = (agent.indexOf("msie") != -1);
  this.ie3 = (this.ie && (this.major == 2));
  this.ie4 = (this.ie && (this.major >= 4));
  this.op3 = (agent.indexOf("opera") != -1);
  this.win = (agent.indexOf("win")!=-1);
  this.mac = (agent.indexOf("mac")!=-1);
  this.unix = (agent.indexOf("x11")!=-1);
}

var is = new Is();

var n4 = (document.layers) ? true:false;
var ie = (document.all) ? true:false;
var n6 = (document.getElementById) ? true:false;

if (ie) n6=false;
if (is.ns4) n4=false;

var screen_width = screen.width;
var screen_height = screen.height;

function layerObject(id) { 
/*
LayerObject()
Takes the ID of a positioned HTML element and returns an object reference.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Taylor
Author Email: taylor@wired.com
Author URL: http://www.taylor.org/

Usage: layerObject('id')
*/
  // First we initialize all the variables.
  var theObj,ss,sr,i,j,WM_layers=new Array();
  // This chunk handles the IE portion of the checkIn code.
  if (is.ie4) {
    // This checks to see if the inline style declaration has 
    // a position property associated with it. If not, it will 
    // scan the global stylesheets for the ID.
    if((document.all[id].style.position != 'absolute') && 
      (document.all[id].style.position != 'relative')){
      // This little loop I'm very proud of, because it's kinda 
      // slick and I wrote it all myself. It loops through all 
      // global stylesheets and all the rules in each stylesheet, 
      // tests for the selected ID, then returns that as the object.
      for (ss=0 ; ss < document.styleSheets.length; ss++) {
        for (sr=0 ; sr < document.styleSheets(ss).rules.length; sr++) { 
          if (document.styleSheets(ss).rules(sr).selectorText == '#' + id) {
            theObj = document.styleSheets(ss).rules(sr).style;
            break;
          }
        }
      }
    } else {
      // This works the same as in the light version, so you can 
      // use inline styles.
      theObj = document.all[id].style;
    }
  } else if(is.ns4) {
    // Now we're in Netscapeland. The main problem here 
    // is finding the object in a maze of hierarchy.
    // I wish I could say that I'm proud of this code, 
    // because it's really slick. Unfortunately, I ripped 
    // it off from Macromedia Dreamweaver's drag layer code 
    // (with permission, of course :-) 
    // Dreamweaver/Configuration/Behaviors/Actions/Drag Layer.htm 
    // It works wonderfully and solves the problem.
    allLayers = new Array();
    with (document) {
      for (i=0; i<layers.length; i++) allLayers[i]=layers[i]; {
        for (i=0; i<allLayers.length; i++) {
          if (allLayers[i].document && allLayers[i].document.layers) {
            for (j=0; j<allLayers[i].document.layers.length; j++) {
              allLayers[allLayers.length] = allLayers[i].document.layers[j];
            }
            if(allLayers[i].name == id){
              // So if the code matches the name of the layer, 
              // return the reference. 
              theObj = allLayers[i];
            }
          }
        }
      }
    }
  }
  return theObj;
}

function swapLayerBgcolor() {
  // Make sure the browser supports DHTML.
  if(document.layers || document.all)
    with(swapLayerBgcolor)
      // Loop through all arguments, two at a time.
      for(i = 0; i < (arguments.length - 1); i += 2)
  // Get an object reference and set the 
  // bgcolor according to the DOM.
  if(document.layers) 
    layerObject(arguments[i]).document.bgColor = arguments[i+1];
  else if(document.all)
    layerObject(arguments[i]).backgroundColor = arguments[i+1];
}

