//Flash object constructor
function flashObject(id, container, src, width, height, bgcolor, nonflash, staticimage, staticlink, html, version){
	this.id = id;
	this.container = container;
	this.src = src;
	this.width = width;
	this.height = height;
	this.bgcolor = bgcolor;
	this.nonflash = nonflash; //URL
	this.staticimage = staticimage; //Image
	this.staticlink = staticlink; //Image Link
	this.html = html; //HTML block
	this.version = version;
}

function initFlash(){
	try{
		for(i=0;i<arr_flash.length;i++){
			detectFlash(arr_flash[i]);
		}
	}catch(er){}
}

//detects major version and revision numbers (called from host page)
function detectFlash(obj){
	try{
		var sTemp = '';
		if(flashVersion >= flash.version){
			renderFlash(true,obj);
		}else{
			renderFlash(false,obj);
		}
	}
	catch(er){
		return false;
	}
}

//renders Flash or redirects to Upgrade page
function renderFlash(supported,obj){
	if(supported){
		var sTemp = '';		
		sTemp += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + obj.width + '" height="' + obj.height + '" id="' + obj.id + '" align="middle">';
		sTemp += '	<param name="allowScriptAccess" value="sameDomain" />';
		sTemp += '	<param name="movie" value="' + obj.src + '" />';
		sTemp += '	<param name="quality" value="high" />';
		sTemp += '	<param name="bgcolor" value="' + obj.bgcolor + '" />';
		sTemp += '	<param name="wmode" value="transparent" />';
		sTemp += '	<embed src="' + obj.src + '" quality="high" bgcolor="' + obj.bgcolor + '" width="' + obj.width + '" height="' + obj.height + '" name="' + obj.id + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" />';
		sTemp += '</object>';
		document.getElementById(obj.container).innerHTML = sTemp;
	}else{
		if(obj.staticimage && flash.staticlink){
			document.getElementById(obj.container).innerHTML = '<a href="' + obj.staticlink + '"><img src="' + obj.staticimage + '" width="' + obj.width + '" height="' + obj.height + '" border="0" alt="" /></a>';
		}else if(obj.staticimage){
			document.getElementById(obj.container).innerHTML = '<img src="' + obj.staticimage + '" width="' + obj.width + '" height="' + obj.height + '" border="0" alt="" />';
		}else if(obj.html){
			document.getElementById(obj.container).innerHTML = obj.html;
		}else{
			location.href = '' + escape(obj.nonflash);
		}
	}
}

//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 swf9Control = CreateObject("ShockwaveFlash.ShockwaveFlash.9") \n')
	document.write('set swf8Control = CreateObject("ShockwaveFlash.ShockwaveFlash.8") \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('if IsObject(swf8Control) then flashVersion = 8 \n');	
	document.write('if IsObject(swf9Control) then flashVersion = 9 \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;
