﻿// Global method to handle browser incompatibilities when 
// loading flash players and attempting to communicate with them
function getFlashMovieObject(movieName)
{
    if (window.document[movieName]){
        return window.document[movieName];
    }
    if (navigator.appName.indexOf("Microsoft Internet")==-1)
    {
        if (document.embeds && document.embeds[movieName])
        {
            return document.embeds[movieName];
        }
        else // if (navigator.appName.indexOf(”Microsoft Internet”)!=-1)
        {
            return document.getElementById(movieName);
        }
    }
}

//
// give focus the named flasj embedded object. Known to work for IE but not for other browsers.
// This is called directly from flash when it is finished initializing which seems more reliable than
// calling with onload for the page
//
function FocusFlashMovie( swfid ) 
{ 
	// internet explorer or another brand of browse
	
	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	
	if ( isIE )
		window[swfid].focus();
	else
		window.document[swfid].focus(); 
} 

// this close the browser window on IE8 and Firefox supposedly. Needs more testing on other browsers etc    
function closeWindowFromFlash() 
{   
    var isNetscape = (navigator.appVersion.indexOf("Netscape") != -1) ? true : false;
    
    if ( isNetscape )
    {
        // netscape / firefox. I don't think this can be made to work unless we 
        // change the way the window is opened.
        
        window.open('','_parent','');
        
        window.close();
    }
    else
    {
        // IE and all other browsers
        
        window.opener='X'; 
        window.open('','_parent',''); 
        window.close();
    }
} 

/* generic method to handle showing our movies yet using the AC_OETags.js javascript; 
   that file must be included before this one */
function showSwf(width, height, mode, id, src, flashvars, alternateContent, name) {

    if (name == null || name == "") {
        name = id;
    }
            
    // Major version of Flash required
    var requiredMajorVersion = 9;
    // Minor version of Flash required
    var requiredMinorVersion = 0;
    // Minor version of Flash required
    var requiredRevision = 124;

    // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
    var hasProductInstall = DetectFlashVer(6, 0, 65);

    // Version check based upon the values defined in globals
    var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
    
    // Check to see if a player with Flash Product Install is available and the version does not meet the requirements for playback
    if ( hasProductInstall && !hasRequestedVersion ) {
        // MMdoctitle is the stored document.title value used by the installation process to close the window that started the process
        // This is necessary in order to close browser windows that are still utilizing the older version of the player after installation has completed
        // DO NOT MODIFY THE FOLLOWING FOUR LINES
        // Location visited after installation is complete if installation is required
        var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
        var MMredirectURL = window.location;
        document.title = document.title.slice(0, 47) + " - Flash Player Installation";
        var MMdoctitle = document.title;

        AC_FL_RunContent(
            "src", "playerProductInstall",
            "FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
            "width", width,
            "height", height,
            "wmode", mode,
            "quality", "high",
            "id", id,
            "name", name,
            "allowScriptAccess","sameDomain",
            "type", "application/x-shockwave-flash",
            "pluginspage", "http://www.adobe.com/go/getflashplayer"
        );
    } else if (hasRequestedVersion) {
        // if we've detected an acceptable version
        // embed the Flash Content SWF when all tests are passed
        AC_FL_RunContent(
            "src", src,
            "width", width,
            "height", height,
            "wmode", mode,
            "quality", "high",
            "id", id,
            "name", name,
            "flashvars", flashvars,
	        "allowFullScreen","true",
            "type", "application/x-shockwave-flash",
            'codebase', 'http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',
            "pluginspage", "http://www.adobe.com/go/getflashplayer"
        );
      } else {
        // flash is too old or we can't detect the plugin
/*        var alternateContent = 'Alternate HTML content should be placed here. '
        + 'This content requires the Adobe Flash Player. '
        + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
        document.write(alternateContent);  // insert non-flash content
*/      document.write(alternateContent);  // insert non-flash content
      }
}