var flashVideoPlayer;
var isIE;

var REPLAY_DELAY = 500;
var REPLAY_TRIES = 10;

var m_intRetries = 0;


function overlay(startingMovie, moviePath)
{
	el = document.getElementById("overlay");
	el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
	//el.style.display = (el.style.visibility == "inline") ? "none" : "inline";
	
	el2 = document.getElementById("overlay2");
	el2.style.visibility = (el2.style.visibility == "visible") ? "hidden" : "visible";
	//el2.style.display = (el2.style.display == "inline") ? "none" : "inline";
	
	//callFlashPlayPauseVideo();
	
	initialize();
	
    if ( startingMovie )
    {
        //objFlash.rewind();
        //objFlash.play();

        flashVideoPlayer = (isIE) ? window['videoPlayer'] : document['videoPlayer'];
        callFlashPlayVideo(moviePath);
    }
    else
    {
        //objFlash.stop();
        //callFlashPlayPauseVideo();
        callFlashStopVideo();
    }

	
	/*var objFlash = document.getElementById("player");
	if ( objFlash != null )
	{
	}*/
    
}



    // Use a variable to reference the embedded SWF file.
    //var flashVideoPlayer;
    
    /* When the HTML page loads (through the onLoad event of the <body> tag), it calls the initialize() function. */
    function initialize() {
        /* Check whether the browser is IE. If so, flashVideoPlayer is
window.videoPlayer. Otherwise, it's document.videoPlayer. The
videoPlayer is the ID assigned to the <object> and <embed> tags. */
        //var isIE = navigator.appName.indexOf("Microsoft") != -1;
        isIE = navigator.appName.indexOf("Microsoft") != -1;
        //flashVideoPlayer = (isIE) ? window['videoPlayer'] : document['videoPlayer'];
        
        var elOverlay = document.getElementById("overlay");
        //elOverlay.style.visibility = "visible";
        elOverlay.style.height = screen.availHeight;
    }

    /* When the user clicks the play button in the form, update the videoStatus text area, and call the playVideo() function within the SWF file, passing it the URL of the FLV file. */
    function callFlashPlayVideo(video) {
        //var comboBox = document.forms['videoForm'].videos;
        //var video = comboBox.options[comboBox.selectedIndex].value;
        //updateStatus("____" + video + "____");

        
        // kpw 2008-10-21
        // this is a hack for Internet Explorer to allow it time to load the Flash video player object
        try
        {
            flashVideoPlayer.playVideo(video, "../SteelExternalAll.swf");
        }
        catch(ex)
        {
            if ( m_intRetries == REPLAY_TRIES )
            {
                alert("Unable to play video. Try closing the video window and choosing 'Watch the video' again.");
            }
            else
            {
                m_intRetries++;
                var tmr = setTimeout("callFlashPlayVideo('" + video + "')", REPLAY_DELAY);
            }
        }
        
    }

    // Call the pauseResume() function within the SWF file.
    function callFlashPlayPauseVideo() {
        flashVideoPlayer.pauseResume();
    }

    /* The updateStatus() function is called from the SWF file from the onStatus() method of the NetStream object. */
    function updateStatus(message) {
        document.forms['videoForm'].videoStatus.value += message + "\n";
    }
    
    function callFlashPlayVideo2()
    {
        flashVideoPlayer.playVideo2();
    }
    
    function callFlashPauseVideo()
    {
        flashVideoPlayer.pauseVideo();
    }
    
    function callFlashStopVideo()
    {
        flashVideoPlayer.stopVideo();
    }
