function XOffset() {
   var x;
   if (self.pageXOffset) { // all except Explorer^M
        x = self.pageXOffset;
   } else if (document.documentElement && document.documentElement.scrollTop) {
// Explorer 6 Strict
        x = document.documentElement.scrollLeft;
   } else if (document.body) { // all other Explorers
        x = document.body.scrollLeft;
   }
   return x;
}

function YOffset() {
   var y;
   if (self.pageYOffset) { // all except Explorer
        y = self.pageYOffset;
   } else if (document.documentElement && document.documentElement.scrollTop) {
// Explorer 6 Strict
        y = document.documentElement.scrollTop;
   } else if (document.body) { // all other Explorers
        y = document.body.scrollTop;
   }
   return y;

}


//
// Browser - Represents a browser object.
//
function Browser() {

var IE_CLIENT = 0;   // Microsoft Internet Explorer
var NS_CLIENT = 1;   // Netscape Navigator/Communicator

//
// Browser::getClient - Returns the type of browser.
//
function _browser_getClient() {

  var appName = navigator.appName;
  if (appName.indexOf( 'Microsoft' ) != -1)
    return IE_CLIENT;
  else if (appName.indexOf( 'Netscape' ) != -1)
    return NS_CLIENT;

  return -1;
}

//
// Browser::getAgent
//
function _browser_getAgent() {
  return navigator.userAgent;
}

//
// Browser::getVersion - Returns the major version of the browser.
//
function _browser_getVersion() {
  var version = navigator.appVersion;
  return version.substring( 0, 1 );
}

//
// Get the named DIV element from the DOM.
//

this.getElementByName = function(name, nest, dnest, ddnest) {

  var element = null;
  if (!this.ns4) {
    if (this.dom) {
      element = document.getElementById(name);
    } else if (this.ie4) {
      element = document.all[name];
    }
  } else {
    if (ddnest) {
      element = document[nest].document[dnest].document[ddnest].document[name];
    } else if (dnest) {
      element = document[nest].document[dnest].document[name];
    } else if (nest) {
      element = document[nest].document[name];
    } else {
      element = document.layers[name];
    }
  }
  return element;
}

this.changeCursor = function(element, cursor) {
   if (element) {
      var css = this.dom || this.ie4 ? element.style : element;
      if (css) css.cursor = cursor;
   }
}
this.changeCursorByName = function(id, cursor) {
   this.changeCursor(this.getElementByName(id), cursor);
}
this.changeElemCursor = function(element, cursor) {
   for (var c = element.firstChild; c; c = c.nextSibling) {
      this.changeCursor(c,cursor);
      if (c.nodeType == 1) this.changeElemCursor(c, cursor);
   }
}

this.getElementStyle = function(name) {
   var elem = this.getElementByName(name);
   return elem != null && (this.dom || this.ie4) ? elem.style : elem;
}

this.showElement = function(name,bVisible) {
   var elem = this.getElementByName(name);
   if (elem != null) {
      var css = this.dom || this.ie4 ? elem.style : elem;
      css.display = bVisible ? "block" : "none";
   }
}


  this.client = _browser_getClient();
  this.version = _browser_getVersion();
  this.userAgent = _browser_getAgent();

  this.dom = document.getElementById ? 1 : 0;

  this.ns4 = (this.client == NS_CLIENT) && (this.version == 4);
  this.ns6 = (this.client == NS_CLIENT) && (this.version >= 5);
  this.ns7 = false;

// Patch for Mozilla browser: force NS 7 behavior for Mozilla
  if((this.userAgent.indexOf("Gecko") > 0
     && this.userAgent.indexOf("Netscape") < 0)
  || this.userAgent.indexOf("Netscape") != -1 && this.ns6) {
    this.ns7 = true; this.ns6 = false;
  }

  this.ie4 = (this.client == IE_CLIENT) && (this.version == 4);
  this.ie5 = (this.client == IE_CLIENT) &&
               (navigator.appVersion.indexOf("MSIE 5") > -1);
  this.ie6 = (this.client == IE_CLIENT) &&
               (navigator.appVersion.indexOf("MSIE 6") > -1);
  this.ie7 = (this.client == IE_CLIENT) &&
               (navigator.appVersion.indexOf("MSIE 7") > -1);

}

var browser = new Browser;

