/**************************************************************/
/**************************************************************/
/* General functions for Business Jet                         */
/*   - bjforms.js contains form specific functions            */
/**************************************************************/
/**************************************************************/

ns4 = document.layers;
ie4 = document.all;
nn6 = document.getElementById && !document.all;

/**************************************************************/
/* call the tracking php to count the visitor                 */
/**************************************************************/
function count() {

  document.write( "\<SCRIPT type='text/javascript' SRC='/count.php?refer=" + escape(document.referrer) + "'\>\</SCRIPT\>" );

}

/*******************************************************************************/
/* open a new window and bring to the top                                      */
/*******************************************************************************/
function openWin(url,name) {
  newWin = window.open(url,name, 'menubar=1,scrollbars=1,location=1,toolbar=1,resizable=1,status=1, width='+(screen.width * .75)+',height='+(screen.height * .75)+',left=40,top=40')
  newWin.focus()
}

/**************************************************************/
/* show the 'under construction' popup                        */
/**************************************************************/
function showObject() {

  hideObject();

  /* figure out where to display the pop-up box */
  var topadd  = (document.body.clientHeight - 300) / 2;
  var newtop  = document.body.scrollTop + topadd;
  newtop      = newtop + "px";
  var newleft = (document.body.clientWidth - 500) / 2;

  if (document.getElementById) {
     document.getElementById('popup').style.visibility = "visible";
     document.getElementById('popup').style.top = newtop;
     document.getElementById('popup').style.left = newleft;
  }
  else {
     if (ns4) {
        document.popup.visibility = "show";
     }
     else {
        if (ie4) {
           document.all['popup'].style.visibility = "visible";
        }
     }
  }
}

/**************************************************************/
/* hide the 'under construction' popup                        */
/**************************************************************/
function hideObject() {
  if (document.getElementById) {
     document.getElementById('popup').style.visibility = "hidden";
  }
  else {
     if (ns4) {
        document.popup.visibility = "hide";
     }
     else {
        if (ie4) {
           document.all['popup'].style.visibility = "hidden";
        }
     }
  }
}

/**************************************************************/
/* show the image popup on the charter fleet pages            */
/* if browser doesn't support getById let them click the link */
/**************************************************************/
function showImg(img) {

  if(document.getElementById) {

      /* hide the image in case it needs to move */
      hideImg();

      /* get the width and height of the image */
      imgx      = new Image();
      imgx.src  = img;
      var wide  = imgx.width;	
      var high  = imgx.height;
      
      /* center the popup box in the middle of browser window */
      var topadd  = (document.body.clientHeight - high) / 2;
      var newtop  = document.body.scrollTop + topadd;
      var newleft = ((document.body.clientWidth - wide) / 2) - 63;
   
      document.getElementById('imgpop').style.visibility = "visible";
      document.getElementById('imgpop').style.top = newtop;
      document.getElementById('imgpop').style.left = newleft;
      document.getElementById('imgpop').style.backgroundImage = 'url('+img+')';
      document.getElementById('imgpop').style.width  = wide;
      document.getElementById('imgpop').style.height = high;
  }
}

/**************************************************************/
/* hide the image popups                                      */
/**************************************************************/
function hideImg() {
  if (document.getElementById) {
      document.getElementById('imgpop').style.visibility = "hidden";
  }
}

/**************************************************************/
/* show the directions popup                                  */
/* (has not been activated yet)                               */
/**************************************************************/
function showDirections() {

  /* figure out where to display the pop-up box */
  var topadd  = (document.body.clientHeight - 450) / 2;
  var newtop  = document.body.scrollTop + topadd;
  newtop      = newtop + "px";
  var newleft = (document.body.clientWidth - 500) / 2;

  if (document.getElementById) {
     document.getElementById('directionspopup').style.visibility = "visible";
     document.getElementById('directionspopup').style.top = newtop;
     document.getElementById('directoinspopup').style.left = newleft;
  }
  else {
     if (ns4) {
        document.directionspopup.visibility = "show";
     }
     else {
        if (ie4) {
           document.all['directionspopup'].style.visibility = "visible";
        }
     }
  }
}

/**************************************************************/
/* show the summary info (also used on partslist page         */
/**************************************************************/
function showSummary(name) {
    document.getElementById(name).style.display = "block";
}

/**************************************************************/
/* hide the summary info                                      */
/**************************************************************/
function hideSummary(name) {
    document.getElementById(name).style.display = "none";
}

/**************************************************************/
/* Form Validation functions                                  */
/**************************************************************/
function trim(str)
{
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}


