/* Script for Flash Player detection and dynamic writes of swf movies vs. alt images */

// global constants - changing these will change the parameters of all swf instances, except when forced by an individual function call.
var FLASH_CONTENT_VERSION = 8;
var FLASH_CLASS_ID = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
var FLASH_CODEBASE = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0';
var FLASH_PLUGINTYPE = 'application/x-shockwave-flash';
var FLASH_PLUGINSPAGE = 'http://www.macromedia.com/go/getflashplayer';
var FLASH_ALLOWSCRIPTACCESS = 'sameDomain';
var FLASH_AUTOPLAY = 'true';
var FLASH_LOOP = 'false';
var FLASH_MENU = 'false';
var FLASH_LIVECONNECT = 'false';
var FLASH_QUALITY = 'high';
var FLASH_DEFAULT_BGCOLOR = '#ffffff';
var FLASH_DEFAULT_ALIGN = 'middle';
var FLASH_DEFAULT_ID = 'styleFlash';

// local variables
var blnFlashCanPlay = false;

	
function flashDetectVideo(divName, videoContainerName, intFlashVersion) {
   
    intFlashVersion = (intFlashVersion) ? intFlashVersion : FLASH_CONTENT_VERSION;

	var blnPluginPresent = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;

    if ( blnPluginPresent != 0 ) 
    { 
			var words = navigator.plugins["Shockwave Flash"].description.split(" ");
		    for (var i = 0; i < words.length; ++i)
		    {
			if (isNaN(parseInt(words[i])))
			continue;
			var intPluginVersion = words[i]; 
		    }
             
        intPluginVersion = parseInt(intPluginVersion);  

	}
    
    // Internet Explorer does not properly support navigator object
	if  ( blnPluginPresent == 0 && document.all ) 
    {

        intPluginVersion = ControlVersion();            
        if ( intPluginVersion != -1 ) {      
            // Given "WIN 2,0,0,11"
    	    tempArray         = intPluginVersion.split(" "); 	// ["WIN", "2,0,0,11"]
    		tempString        = tempArray[1];			// "2,0,0,11"
    		versionArray      = tempString.split(",");	// ['2', '0', '0', '11']      
            intPluginVersion = versionArray[0];    
        }
    }
    

    if (intPluginVersion >= intFlashVersion)
            blnFlashCanPlay = true;


            
	if ( !blnFlashCanPlay ) {   
                document.getElementById(divName).style.display="block";      
                document.getElementById(videoContainerName).style.display="none";
	}
}


function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}
/* obaptist - 2007-05-15 - test to see /scripts has been removed from bulk deploys */

function switchVideoList(list)
{
    var videoTabID;    
    var videoTabs = []; 
    var videoListDivEl;
    var videoListsDivs = [];
    
    videoTabID = list.replace(/list/,"on");
        
    videoTabs = getElements("shows_tabs", "div", "video_hed");
     
    if ( videoTabs.length > 0 )
    {       
        for (var u = 0; u < videoTabs.length; u++)
        {
           
            if ( videoTabs[u].id == videoTabID )
            {
               
                videoTabs[u].style.display = 'block';
                
            }
            else
            {
    
                videoTabs[u].style.display = 'none';
            }

        }
    }

    if (document.getElementById("video_lists"))
    {
       
        videoListsDivs = getElements("vlist", "div", "video_lists");

        for (var v = 0; v < videoListsDivs.length; v++)
        {
           
            if ( videoListsDivs[v].id == list )
            {
                videoListsDivs[v].style.display = 'block';
            }
            else
            {
                videoListsDivs[v].style.display = 'none';
            }
            
        
        }
    
    }   

}
