var hasFlash2 = false;
var hasFlash3 = false;
var hasFlash4 = false;
var hasFlash5 = false;
var hasFlash6 = false;

var versionNeeded = 6;
var versionUsed = 0;
var versionCheck = false;

var ieUser = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var winUser = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;

if(ieUser && winUser)
{

  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('hasFlash2 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('hasFlash3 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('hasFlash4 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('hasFlash5 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
  document.write('hasFlash6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
  document.write('</SCR' + 'IPT\> \n');
  
}


function checkForFlash(directory,elementName,imageType,elementWidth,elementHeight){

	if(navigator.plugins)
	{
  
  	if(navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"])
  	{

      var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
      var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));

      hasFlash2 = flashVersion == 2;
      hasFlash3 = flashVersion == 3;
      hasFlash4 = flashVersion == 4;
      hasFlash5 = flashVersion == 5;
      hasFlash6 = flashVersion >= 6;
      
    }
    
  }

  
  for(var i = 2; i <= versionNeeded; i++)
  {
  	
  	if(eval("hasFlash" + i) == true)
  	{
  	
  		versionUsed = i;
  		
  	}
  	
  }

  if(navigator.userAgent.indexOf("WebTV") != -1)
  {
  
  	versionUsed = 3;
  	
  }

  if(versionUsed >= versionNeeded)
  {
  
  	var flashOutput = "";
  	
  	flashOutput += "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' WIDTH='" + elementWidth + "' HEIGHT='" + elementHeight + "' id='" + elementName + "' ALIGN=''>";
		flashOutput += "<PARAM NAME=movie VALUE='" + directory + elementName + ".swf'>";
		flashOutput += "<PARAM NAME=quality VALUE=high>";
		flashOutput += "<PARAM NAME=bgcolor VALUE=#FFFFFF>"; 
		flashOutput += "<EMBED src='" + directory + elementName + ".swf' quality=high bgcolor=#FFFFFF  WIDTH='" + elementWidth + "' HEIGHT='" + elementHeight + "' NAME='" + elementName + "' ALIGN='' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED>";
		flashOutput += "</OBJECT>";
		
		document.write(flashOutput);
  	
  	
  }
  else
  {
  
  	var imageOutput = "";
  	
  	imageOutput += "<img src='" + directory + elementName + "." + imageType + "' border='0' width='" + elementWidth + "' height='" + elementHeight + "' usemap='#index_map'>";
  
  	document.write(imageOutput);
  
  }

    
}
