// Requires: xbrowser.js
if(typeof(xBrowser) == "undefined") alert("xBrowser Required");

// ||||||||||||||||||||||||||||||||||||||||||||||||||

if(typeof(xFlash) == "undefined") xFlash = {};

xFlash.currentVersion = 8;// This variable will need to be updated as new Flash versions are released.
xFlash.versionInstalled = 0;
xFlash.getVersion = function(){
	if(navigator.plugins != null && navigator.plugins.length > 0){
		var plugin = navigator.plugins["Shockwave Flash"];
		if(typeof plugin == "object"){
			for(i=3; i<= this.currentVersion; i++){
				if(plugin.description.indexOf(i+".") != -1){
					this.versionInstalled = i;
				}
			}
		}else if(navigator.plugins["Shockwave Flash 2.0"]){
			this.versionInstalled = 2;
		}
	}else if(xBrowser.iex && xBrowser.win32){
		document.write('<'+'script language="VBScript"'+'> \n');
			document.write('set xFlashObj = Nothing \n');
			document.write('on error resume next \n');
			document.write('For i = '+this.currentVersion+' to 3 step -1 \n');
				document.write('set xFlashObj = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n');
				document.write('If (Not(xFlashObj is Nothing)) Then \n');
					document.write('xFlash.versionInstalled = i \n');
					document.write('Exit For \n');
				document.write('End If \n');
			document.write('Next \n');
		document.write('<'+'\/script'+'> \n');

	}else if(xBrowser.agent.indexOf("webtv/2.5") != -1){
		this.versionInstalled = 3;
	}else if(xBrowser.agent.indexOf("webtv") != -1){
		this.versionInstalled = 2;
	}else{
		this.versionInstalled = -1;
	}
};
xFlash.getVersion();

// ||||||||||||||||||||||||||||||||||||||||||||||||||

xFlash.redirect = function(required, upgradeFlash, noFlash, failedCheck){
	if(this.versionInstalled < required  && location.search.indexOf("skipcheck=true") == -1){
		var url;
		if(this.versionInstalled == -1){
			if(!failedCheck) failedCheck = upgradeFlash;
			url = failedCheck;
		}else if(this.versionInstalled == 0){
			if(!noFlash) noFlash = upgradeFlash;
			url = noFlash;
		}else{
			url = upgradeFlash;
		}
		window.location.href = url;
	}
};
xFlash.replace = function(required, name, width, height, bgcolor, quality, menu, noFlash, flashVars){
	if(this.versionInstalled >= required){
		flashVars = flashVars!=null ? flashVars : "";
		var swf = '';
		swf += '<object';
		swf += ' width="'+width+'"';
		swf += ' height="'+height+'"';
		swf += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
		swf += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+required+',0,0,0">';
		swf += '<param name="movie" value="'+name+'?'+flashVars+'">';
		swf += '<param name="FlashVars" value="'+flashVars+'">';
		swf += '<param name="bgcolor" value="'+bgcolor+'">';
		swf += '<param name="quality" value="'+quality+'">';
		swf += '<param name="menu" value="'+menu+'">';
			swf += '<embed src="'+name+'?'+flashVars+'"';
			swf += ' FlashVars="'+flashVars+'"';
			swf += ' width="'+width+'"';
			swf += ' height="'+height+'"';
			swf += ' bgcolor="'+bgcolor+'"';
			swf += ' quality="'+quality+'"';
			swf += ' menu="'+menu+'"';
			swf += ' type="application/x-shockwave-flash"';
			swf += ' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">';
			swf += '<\/embed>';
		swf += '<\/object>';
		document.write(swf);
	}else{
		document.write(noFlash);
	}
};