﻿// JScript File
var genConstant = -5325
var initTop = genConstant;
//alert (initTop);

function ShowPlayer ( flvPath ) {
// PRE: path to FLV (subject to change)
// POST: the page is screened back and a new page is loaded into the iframe with the correct flv

    // Reload the page in the iframe to swap video out. 
    var iframeObj = document.getElementById ( 'VideoIFrame' );
    iframeObj.src = flvPath;  // replace this with actual path

    // Show the container and its parts
    var playerCont = document.getElementById ( 'FlashVideoContainer' );
    playerCont.style.display = "block";
    
    
    // Add onResize or onScroll event to resize if in IE6?

    if ( navigator.appName.indexOf ( 'Microsoft' ) > -1 ) {

        if (typeof document.body.style.maxHeight != "undefined") {
          // NO OP
        } else {
           handleScroll();
           //window.onscroll = handleScroll;
            organizeCoverDimensions();
            window.onresize = organizeCoverDimensions;
            window.scrollTo(0);
        }
       
    }
    
    
}

function organizeCoverDimensions () {
// PRE: none
// POST: sets the height and width of the translucent cover to the size of the observed window

    var coverObj = document.getElementById ( 'Cover' );          
          
    coverObj.style.width = document.body.clientWidth + "px";
    coverObj.style.height = document.body.clientHeight + "px"
    
  
    var video = document.getElementById ( 'VideoIFrame' );
  
    var newLeft = ( document.body.clientWidth / 2 )
    //var newTop = ( document.body.clientHeight / 2 )
    
    video.style.left = Math.round ( newLeft ) + "px";
    //video.style.top = Math.round ( newTop ) + "px";
    
}


function handleScroll () {
// PRE: none
// POST: positions the video container appropriately within the window
    

    var iframe = document.getElementById ( 'VideoIFrame' );

    if ( initTop == genConstant ) {
        
     
    }
  
    // var actualTop = parseInt ( iframe.style.top.substr(0, iframe.style.top.length - 2 ) ) 
    //var newTop = document.documentElement.scrollTop + actualTop;
    //iframe.style.top = newTop + "px";
    //iframe.style.marginTop = document.documentElement.scrollTop - iframe.style.height;
    
}


function HidePlayer () {
// PRE: none (call from w/in iframe)
// POST: hides the screen and unloads the flash movie.

    // Hide the container and its parts
    var playerCont = document.getElementById ( 'FlashVideoContainer' );
    playerCont.style.display = "none";
    
    // Unload the iframe to prevent flash from cycling (give iframe a dummy page)
    var iframeObj = document.getElementById ( 'VideoIFrame' );
    iframeObj.src = "../EmptyPage.htm";

    // Clear event handlers to eliminate unneeded cpu cycles.
    window.onresize = null;
    window.onscroll = null;
    
}