/*******************************************************************************/
/*******************************************************************************/
/* Functions for the Facilities page                                           */
/*******************************************************************************/
/*******************************************************************************/

/**************************************************************/
/* show the image popup on the facilities page                */
/* if browser doesn't support getById let them click the link */
/**************************************************************/
function showImg(img,evnt,pos) {

  if(document.getElementById) {
      var cursor = getPosition(evnt);
      
      /* hide the image in case it needs to move */
      hideElement('imgpop');

      /* get the width and height of the window */
      var myWidth = 0, myHeight = 0;
      if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
      }
      else {
        if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
            //IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
        }
        else {
            if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                //IE 4 compatible
                myWidth = document.body.clientWidth;
                myHeight = document.body.clientHeight;
            }
        }
      }

      /* get the width and height of the image */
      imgx      = new Image();
      imgx.src  = img;
      var wide  = imgx.width;	
      var high  = imgx.height;
      
      /* get the current scroll x and y coordinate */
      var xy = getScrollXY();
      

      /* position the popup in the center or above/below the cursor depending on the variable        */
      /* for cursor positioned popups - position image above cursor if it will fit - otherwise below */
      if( pos == 'cursor' ) {
          var imgtop = cursor.y - high - 20;
          if( imgtop < xy.y ) { 
              var newtop  = cursor.y + 40;
          }
          else { 
              var newtop  = cursor.y - high - 20;
          }
          /* set the left position to center the popup */
          var newleft = parseInt(((myWidth - wide) / 2) - 135);
      }
      else { 
          var topadd  = parseInt((myHeight - high) / 2);
          var newtop  = xy.y + topadd;
          /* set the left position to center the popup - do not let cursor enter popup area */
          var newleft = parseInt(((myWidth - wide) / 2) - 135);
          if ( newleft + wide > cursor.x ) {
              newleft = cursor.x - wide - 20;
          }
      }
    
            
      newtop      = newtop  + 'px'; 
      newleft     = newleft + 'px';
   
      document.getElementById('imgpop').style.display = 'inline';
      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 + 'px';
      document.getElementById('imgpop').style.height = high + 'px';
      initImage('imgpop');
  }
}

/**************************************************************/
/* preload the pop-up images for the Facilities page          */
/**************************************************************/
function preloadFacilities() {
 if (document.images) {
   img1  = new Image();
   img1.src  = "/images/facilities/conference-large.jpg";
   img2  = new Image();
   img2.src  = "/images/facilities/csr-desk-large.jpg";
   img3  = new Image();
   img3.src  = "/images/facilities/diversion-lounge-golf-large.jpg";
   img4  = new Image();
   img4.src  = "/images/facilities/diversion-lounge-gaming-large.jpg";
   img5  = new Image();
   img5.src  = "/images/facilities/flight-deck-large.jpg";
   img6  = new Image();
   img6.src  = "/images/facilities/flt-planning-person-large.jpg";
   img7  = new Image();
   img7.src  = "/images/facilities/lobby-large.jpg";
   img8  = new Image();
   img8.src  = "/images/facilities/lobby-lookover-large.jpg";
   img9  = new Image();
   img9.src  = "/images/facilities/tranquility-base-large.jpg";
   imgA  = new Image();
   imgA.src  = "/images/facilities/zero-gravity-large.jpg";
 }
}

/**************************************************************/
/* preload the pop-up images for the Oakland Facilities page  */
/**************************************************************/
function preloadOakFacilities() {
 if (document.images) {
   img1  = new Image();
   img1.src  = "/images/oakland/facilities/OAK-lobby-large.jpg";
   img2  = new Image();
   img2.src  = "/images/oakland/facilities/OAK-front-desk-large.jpg";
   img3  = new Image();
   img3.src  = "/images/oakland/facilities/lobby2-large.jpg";
   img4  = new Image();
   img4.src  = "/images/oakland/facilities/conference-room-large.jpg";
   img5  = new Image();
   img5.src  = "/images/oakland/facilities/flight-planning-large.jpg";
   img6  = new Image();
   img6.src  = "/images/oakland/facilities/flt-planning-person-large.jpg";
   img7  = new Image();
   img7.src  = "/images/oakland/facilities/pilots-lounge-large.jpg";
   img8  = new Image();
   img8.src  = "/images/oakland/facilities/bunk-rooms-large.jpg";
 }
}













