/**
 * General purpose functions that should be used to maintain cross-browser
 * compatibility
 */


/********* Set functions for page boundaries ************/
function setLeftOfPage(value) {
   if (navigator.appName == "Netscape") {
      window.pageXOffset = value;
   }else{
      document.body.scrollLeft = value;
   }
}

function setPageHeight(value) {
   if (navigator.appName == "Netscape") {
      window.innerHeight = value;
   }else{
      document.body.clientHeight = value;
   }
}

function setPageWidth(value) {
   if (navigator.appName == "Netscape") {
      window.innerWidth = value;
   }else{
      document.body.clientWidth = value;
   }
}

function setTopOfPage(value) {
   if (navigator.appName == "Netscape") {
      //alert("setTopOfPage");
      /******** ??? *********/
      //window.pageYOffset = value;
   }else{
      document.body.scrollTop = value;
   }
}

function setLeftOfPage(value) {
   if (navigator.appName == "Netscape") {
      window.pageXOffset = value;
   }else{
      document.body.scrollLeft = value;
   }
}

function setPageHeight(value) {
   if (navigator.appName == "Netscape") {
      window.innerHeight = value;
   }else{
      document.body.clientHeight = value;
   }
}

function setPageWidth(value) {
   if (navigator.appName == "Netscape") {
      window.innerWidth = value;
   }else{
      document.body.clientWidth = value;
   }
}

/********* Get functions for page boundaries ************/
function getLeftOfPage() {
   if (navigator.appName == "Netscape") {
      return window.pageXOffset;
   }else{
      return document.body.scrollLeft;
   }
}

function getPageHeight() {
   if (navigator.appName == "Netscape") {
      return window.innerHeight;
   }else{
      return document.body.clientHeight;
   }
}

function getPageWidth() {
   if (navigator.appName == "Netscape") {
      return window.innerWidth;
   }else{
      return document.body.clientWidth;
   }
}

function getTopOfPage() {
   if (navigator.appName == "Netscape") {
      return window.pageYOffset;
   }else{
      return document.body.scrollTop;
   }
}

function getLeftOfPage() {
   if (navigator.appName == "Netscape") {
      return window.pageXOffset;
   }else{
      return document.body.scrollLeft;
   }
}

function getPageHeight() {
   if (navigator.appName == "Netscape") {
      return window.innerHeight;
   }else{
      return document.body.clientHeight;
   }
}

function getPageWidth() {
   if (navigator.appName == "Netscape") {
      return window.innerWidth;
   }else{
      return document.body.clientWidth;
   }
}

/**
 * Retrieve an object regardless of what browser you are using
 */
function getForm(formName) {
   if(document.getElementById && document.getElementById(formName)) {
      return document.getElementById(formName);
   } else if (document.all && document.all(formName)) {
      return document.all(formName);
   } else if (document.forms) {
      if(document.forms[formName]) {
         return document.forms[formName]
      } else {
         return nsGetForm(formName);
      }
   } else {
      alert("returning false (fell through getForm(\""+formName+"\") )");
      return false;
   }
}

/**
 * Retrieve an object regardless of what browser you are using
 */
function getFormObject(formName,objectId) {
   var obj;
   if (document.forms) {
      var form;
      if( (form=document.forms[formName]) ) {
         obj=form.elements[objectId];
      }
   } else {
      alert("We are sorry. Your Browser may not support the features needed to use this site properly.");
   }
   return obj;
}

/**
 * Retrieve an object regardless of what browser you are using
 * (Such as a <div>)
 */
function getObject(objectId) {
   var obj = false;
   if(document.getElementById) {
      obj=document.getElementById(objectId);
   } else {
      alert("Browser incompatibility: Please contact techhelp@lawdepot.com for assistance.\n\nWe apologize for the inconvenience.");
   }
   return obj;
}
/**
 * Set visibility / display property.  We will use both at the same time.
 * second parameter should be boolean
 */
function setVisDisp(objectId,visible) {
   if(document.getElementById && document.getElementById(objectId)) {
      if(visible) {
         document.getElementById(objectId).style.visibility = "visible";
         document.getElementById(objectId).style.display = "block";
      } else {
         document.getElementById(objectId).style.visibility = "hidden";
         document.getElementById(objectId).style.display = "none";
      }
   } else if (document.all && document.all(objectId)) {
      if(visible) {
         document.all(objectId).style.visibility = "visible";
         document.all(objectId).style.display = "block";
      } else {
         document.all(objectId).style.visibility = "hidden";
         document.all(objectId).style.display = "none";
      }
   } else if (document.layers) {
      if(document.layers[objectId]) {
         if(visible) {
            document.layers[objectId].visibility = "show";
            document.layers[objectId].display = "block";
         } else {
            document.layers[objectId].visibility = "hide";
            document.layers[objectId].display = "none";
         }
      } else {
         // As this layer may be embedded, we have to traverse
         // the tree to find it.
         var retval= nsGetLayer(document.layers,objectId);
         if(retval) {
            if(visible) {
               retval.visibility = "show";
               retval.display = "block";
            } else {
               retval.visibility = "hide";
               retval.display = "none";
            }
         }
         /*
         var theString = "document.layers.length = "+document.layers.length+"\n\n";
         var i = 0;
         for(i=0;i<document.layers.length;i++) {
            theString += document.layers[i].name+"\n";
         }
         alert(theString);
         */
      }
   }
}

/**
 * Get visibility / display property.  We will use both at the same time.
 */
function getVisDisp(objectId) {
   if(document.getElementById && document.getElementById(objectId)) {
      if(document.getElementById(objectId).style.visibility == "visible") {
         return true;
      } else {
         return false;
      }
   } else if (document.all && document.all(objectId)) {
      if(document.all(objectId).style.visibility == "visible") {
         return true;
      } else {
         return false;
      }
   } else if (document.layers && document.layers[objectId]) {
      if(document.layers[objectId].visibility == "show") {
         return true;
      } else {
         return false;
      }
   } else {
      return false;
   }
}

/**
 * Get the style of an object regardless of browser
 */
function getStyleObject(objectId) {
   if(document.getElementById && document.getElementById(objectId)) {
      return document.getElementById(objectId).style;
   } else if (document.all && document.all(objectId)) {
      return document.all(objectId).style;
   } else if (document.layers && document.layers[objectId]) {
      return document.layers[objectId];
   } else {
      return false;
   }
}

function setStatus(msg) {
   window.status = msg;
}

function bookmark(){
   window.external.AddFavorite(window.location.href,window.document.title);
}

/* These two functions are for disabling selection in Netscape */
function disableselect(event) {
   return false;
}

function enableselect(event) {
   return false;
}
