// Base Lightbox
// Overlays the site in a transparent box and places a layer on top of it

var activeLightbox;
var setLightbox       = 'lightbox';
// var setLightboxLayer  = 'lightboxlayer';


// Function: baseLoadBox()
// Takes over the page by placing a transparent box above all others

function baseLightbox(openVideoLink) {

  // Check the height and width of the page
  pageWidth  = (self.innerWidth != undefined) ? self.innerWidth : document.body.clientWidth;
  viewHeight = (self.innerHeight != undefined) ? self.innerHeight : document.body.clientHeight;
  pageHeight = (document.getElementById('wrapsite').innerHeight != undefined) ? document.getElementById('wrapsite').innerHeight : document.getElementById('wrapsite').clientHeight;
  footHeight = (document.getElementById('wrapfooter').innerHeight != undefined) ? document.getElementById('wrapfooter').innerHeight : document.getElementById('wrapfooter').clientHeight;
  
  fullHeight = pageHeight + footHeight + 60; // (margin is 60)

  var myLightbox       = document.getElementById(setLightbox);
  myLightbox           = (myLightbox != undefined) ? document.getElementById(setLightbox) : false;

  if( myLightbox != false ) {

    // Set the box to visible
    myLightbox.style.visibility = 'visible';
    myLightbox.style.width      = '100%';
    myLightbox.style.height     = fullHeight + 'px';

    // Wee, another Safari special treatment
    // Unload the video nav rollover so it switches to the inactive state
    // ...

      // Load content into the lightbox?
      if( activeLightbox != setLightbox ) {

        myLBvideo         = document.getElementById('videoplayer');

        // myLBcontent.style.visibility = 'visible';
        myLBvideo.style.zIndex     = 999;
        myLBvideo.style.width      = 804 + 'px';
        myLBvideo.style.height     = 447 + 'px';

        // myLBcontent.style.top        = Math.round((viewHeight - 447) / 2) + 'px';
        myLBvideo.style.top        = 50 + 'px';
        myLBvideo.style.left       = Math.round((pageWidth - 804) / 2) + 'px';

        // Show the "close video" link
        myLBcloseVideo                  = document.getElementById('videocloselink2');
        myLBcloseVideo.style.visibility = 'visible';
        myLBcloseVideo.style.top        = 447 + 50 + 'px';
        myLBcloseVideo.style.left       = myLBvideo.style.left;
        myLBcloseVideo.style.zIndex     = 999;

        if( openVideoLink == undefined ) {
          openVideoLink = 'http://www.my21.tv/test.html';
        }

        myLBvideo.src     = openVideoLink;

      } // ! load content?

    activeLightbox              = setLightbox; // mark active box

  } // ! does the lightbox exist?

} // ! baseLightbox()




function baseLightboxHide2() {

  // Hide the "close player" link
  document.getElementById('videocloselink2').style.visibility = 'hidden';

  // Revert the video player back to nothing ...
  cancelVideo       = document.getElementById('videoplayer');
  cancelVideo.src          = '/blank_frame.html';
  cancelVideo.style.width  = 0 + 'px';
  cancelVideo.style.height = 0 + 'px';
  cancelVideo.style.top    = 0 + 'px';
  cancelVideo.style.left   = 0 + 'px';

  // Clear the lightbox effect
  document.getElementById('lightbox').style.visibility = 'hidden';

  activeLightbox = '';

} // ! baseLightboxHide()

