//Flash object constructor
function flashObject(id, src, width, height, bgcolor, nonflash, staticimage){
   this.id = id;
	this.src = src;
	this.width = width;
	this.height = height;
	this.bgcolor = bgcolor;
	this.nonflash = nonflash;
	this.staticimage = staticimage;
}

//detects major version and revision numbers (called from host page)
function detectFlash(staticImage){
	var sTemp = '';
	if(flashVersion >= 6){
		sTemp += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="../../../fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,65,0/#version=6,0,65,0/default.htm" width="10" height="10" id="" align="middle">';
		sTemp += '<param name="allowScriptAccess" value="sameDomain" />';
		sTemp += '<param name="movie" value="../../flash/flashdetect.swf@version=6,0,79,0" />';
		sTemp += '<param name="quality" value="high" />';
		sTemp += '<param name="bgcolor" value="#ffffff" />';
		sTemp += '<param name="wmode" value="opaque" />';		
		sTemp += '<embed src="../../flash/flashdetect.swf@version=6,0,79,0" quality="high" wmode="opaque" bgcolor="#ffffff" width="10" height="10" name="" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="../../../www.macromedia.com/go/getflashplayer" />';
		sTemp += '</object>';
		
		document.getElementById('divFlashDetect').innerHTML = sTemp;
      
	}else{
		renderFlashFeature(false, staticImage);
      
	}
   renderFlashFeature(true, sTemp);
}

//renders Flash or redirects to Upgrade page
function renderFlashFeature(supported, staticImage){

	if(supported){
   
		var sTemp = '';
		sTemp += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="../../../fpdownload.macromedia.com/pub/shockwave/cabs/flash/swthis.cab#version=6,0,65,0/#version=6,0,65,0/default.htm" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="middle">';
		sTemp += '<param name="allowScriptAccess" value="sameDomain" />';
		sTemp += '<param name="movie" value="' + this.src + '" />';
		sTemp += '<param name="quality" value="high" />';
		sTemp += '<param name="bgcolor" value="' + this.bgcolor + '" />';
		sTemp += '<param name="wmode" value="opaque" />';
		sTemp += '<embed src="' + this.src + '" quality="high" wmode="opaque" bgcolor="' + this.bgcolor + '" width="' + this.width + '" height="' + this.height + '" name="' + this.id + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="../../../www.macromedia.com/go/getflashplayer" />';
		sTemp += '</object>';
		document.getElementById('divFlash').innerHTML = sTemp;
	}else{
		if(this.nonflash != ''){ //load non-Flash URL
			location.href = this.nonflash;
		}else if(this.staticimage != ''){ //show static image in place of the Flash movie
			document.getElementById('divFlash').innerHTML = '<img src="' + this.staticimage + '" width="' + this.width + '" height="' + this.height + '" border="0" alt="" />';
		}
	}
}


//suppress myFlash_DoFSCommand errors in Mozilla/Netscape browsers
function myflash_DoFSCommand(command, args){
	
}




//==============================================
//FLASH MAJOR VERSION DETECTION

var agent = navigator.userAgent.toLowerCase();
var flashVersion = 0;

// IE4+ on Win32:  attempt to create an ActiveX object using VBScript
if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	document.write('<scr' + 'ipt language="VBScript"\> \n');
	document.write('on error resume next \n');
	document.write('set swf7Control = CreateObject("ShockwaveFlash.ShockwaveFlash.7") \n')
	document.write('set swf6Control = CreateObject("ShockwaveFlash.ShockwaveFlash.6") \n')
	document.write('set swf5Control = CreateObject("ShockwaveFlash.ShockwaveFlash.5") \n')
	document.write('set swf4Control = CreateObject("ShockwaveFlash.ShockwaveFlash.4") \n')
	document.write('set swf3Control = CreateObject("ShockwaveFlash.ShockwaveFlash.3") \n')	
	document.write('if IsObject(swf3Control) then flashVersion = 3 \n');
	document.write('if IsObject(swf4Control) then flashVersion = 4 \n');
	document.write('if IsObject(swf5Control) then flashVersion = 5 \n');
	document.write('if IsObject(swf6Control) then flashVersion = 6 \n');
	document.write('if IsObject(swf7Control) then flashVersion = 7 \n');	
	document.write('</scr' + 'ipt\> \n'); 
}

// NS3+ and Opera3+ (support plugin array):  check for Flash plugin in plugin array
else if (navigator.plugins != null && navigator.plugins.length > 0) {
	var thearray = navigator.plugins
	for (i=0; i < thearray.length; i++) {
		var theplugin = thearray[i]
		var thename   = theplugin.name
		var thedesc   = theplugin.description
		if (thename.indexOf("Shockwave") != -1 && thename.indexOf("Flash") != -1) {
			var flaDnum = thedesc.search(/\d\.\d/);
			flashVersion = parseInt(thedesc.slice(flaDnum));
		}
	}
}

// WebTV 2.5 supports flash 3
else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;

// older WebTV supports flash 2
else if (agent.indexOf("webtv") != -1) flashVersion = 2;

