﻿// JScript File
// Original version from internet
// Changelog: 
// Ross McKinlay 18/06/2007,
//  * Added querystring parameter
// Ross McKinlay 05/06/2007,
//  * Removed useless DisplayGetFlash parameter and associated code.
// Ross McKinlay 15/05/2007,
//  * Removed MAC code that wouldn't have worked anyway, lol.
//  * Incorporated isIE() function from old script.
//  * Provided DIV tag for IE fixingness
// Ross McKinlay 14/05/2007,
//  * Added special Flash detection for IE.. calls VBScript file
// Ross McKinlay 11/05/2007,
//  * Converted into function that takes parameters
//  * Changed to allow an alternate image and url to be displayed 
//  * Cleaned up crappy code a bit
//  * Added some validation checks

function ShowFlashScript( movieLocation, minimumVersion, width, height, alternateImage, alternateURL, queryString )
{
  
  if( movieLocation == "" )
  {
    return;
  }
    
	var MM_contentVersion = minimumVersion;  //Version of Flash required
	var MM_FlashCanPlay = false;
	  
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if ( plugin ) 
	{
			var words = navigator.plugins["Shockwave Flash"].description.split(" ");
			for (var i = 0; i < words.length; ++i)
			{
			  if (isNaN(parseInt(words[i])))
	  		  continue;
			  var MM_PluginVersion = words[i]; 
			}
		MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;				
	}
	
	if( MM_FlashCanPlay != true )
	{
	  //RM: At this stage it's possible no plugins were detected because the browser is IE,
	  //So we call our VBScript to check for Flash in IE:
	  MM_FlashCanPlay = DetectFlash( minimumVersion );			
	}
	      
	if ( MM_FlashCanPlay == true ) 
	{		  	 	  
	  var fullMovieLocation = ""; // contains additional querystring if neccesary
  	 //RM: Append querystring to the fullMovieLocation
	  if( queryString != "" )
	  {
	    if( queryString.substring(0,1) != "?" )
	       queryString = "?" + queryString;
	   
	    fullMovieLocation = movieLocation + queryString;
	  }
	  else
	  {
	    fullMovieLocation = movieLocation;
	  }

		document.write('<OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
		document.write('  codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + minimumVersion + ',0,0,0" ');
		document.write('  WIDTH="' + width + '" HEIGHT="' + height + '" ALIGN="middle">');
		document.write(' <PARAM NAME="movie" VALUE="' + movieLocation + '" /> ');
		document.write(' <PARAM NAME="quality" VALUE="high" />');
		document.write(' <PARAM NAME="allowScriptAccess" VALUE="sameDomain" />');
		document.write(' <PARAM NAME="bgcolor" VALUE="#FFFFFF" />'); 				
		document.write(' <EMBED src="' + fullMovieLocation  + '" quality="high" ');
		document.write(' allowScriptAccess="sameDomain" WIDTH="' + width + '" HEIGHT="' + height + '" NAME="' + movieLocation + '" ALIGN="middle"');
		document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"');
		document.write(' />');
		document.write(' </OBJECT>');					 
  } 
	else
	{	  	 
    document.write('<a href="' + alternateURL + '">');
	  document.write('<IMG style="border:0" SRC="' + alternateImage + '"/></a>');				  				
	}
//-->
}

		
function isIE()
{  
// only for Win IE 6+
// But not in Windows 98, Me, NT 4.0, 2000
  var strBrwsr= navigator.userAgent.toLowerCase();
  if(strBrwsr.indexOf("msie") > -1 && strBrwsr.indexOf("mac") < 0)
  {
    if(parseInt(strBrwsr.charAt(strBrwsr.indexOf("msie")+5)) < 6)
    {
          return false;
    }    
    if(strBrwsr.indexOf("win98") > -1 ||       
      strBrwsr.indexOf("win 9x 4.90") > -1 ||       
      strBrwsr.indexOf("winnt4.0") > -1 ||       
      strBrwsr.indexOf("windows nt 5.0") > -1)    
    {      
      return false;
    }    
    return true;  
  }
  else
  {
    return false; 
  }
}