//
//	Version 2.2
//	
//	History
//	1.0 	Initial version
//	1.1	Added Macintosh browser check
//  	1.2 	Fixed Macintosh IE 5.x detection, added version detection for PC IE
//  	2.0	Added IE and Netscape 4 Flash version detection
//  	2.1	Functions added: generateBasicFlashObject, generateBasicNoFlashPage
//      2.2     Fixed Opera browser compatibility problem
//
var flash2Installed = false; 
var flash3Installed = false;   
var flash4Installed = false;    
var flash5Installed = false;  
var flash6Installed = false;   
var flash7Installed = false;   
var flash8Installed = false;    
var flash9Installed = false; 
var maxver = 9;

function checkBrowser() {
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent;
	this.netscape4=document.layers;
	this.browserCheckArray = this.agent.split(" ");
 	this.mozMac=this.agent.indexOf("Mozilla")>-1 && this.dom && this.mac?1:0;
 	this.macSafari=this.mac>-1&&this.agent.indexOf("Safari")>-1&&(this.dom)>-1?1:0;
	this.isopera = browserCheckArray[0].split("/");
	return this;
}

var br = checkBrowser();

function flashDetectHTML(flashHTML,noFlashHTML,required_version) {
	required_version = parseInt(required_version);
	if (br.browserCheckArray[4]=="Symbian") {
		document.write(noFlashHTML);
	} else {
		
		if (br.isopera[0]=="Opera" || br.browserCheckArray[7]=="Opera" || br.browserCheckArray[0]=="Mozilla/5.0" || br.mozMac==1 || br.macSafari==1 || (br.browserCheckArray[2]=="MSIE" && navigator.appVersion.indexOf("Win")==-1)) {
		//
		//	Detection for Mac Internet Explorer, Safari, Opera (7.x) and Gecko (Mozilla, Netscape 6.x, 7.x) based browsers.
		//	Detects also version of Flash player and compares value to "required_version" variable.
		//
			if (navigator.plugins['Shockwave Flash']) {
				var description = navigator.plugins['Shockwave Flash'].description;
				var description_array = description.split(" ");
				var version_array = description_array[2].split(".");
				if (version_array[0]<required_version) {
					document.write(noFlashHTML);
				} else {
					document.write(flashHTML);
				}
			} else {
				document.write(noFlashHTML);
			}
		} else if (br.browserCheckArray[7]!="Opera" && br.browserCheckArray[2]=="MSIE" && navigator.appVersion.indexOf("Win") != -1) {
		//
		//	Detection for Microsoft Internet Explorer 5.x and 6.x PC browsers.
		//	Does not detect flash version, just checks if plugin exists.
		//
		  var ie_true = false;
		  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
		  document.write('on error resume next \n');
		  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
		  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
		  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
		  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
		  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
		  document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
		  document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
		  document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
		  document.write('<\/SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script

		  for (var i=2;i<=maxver;i++) {
		  		if (i==required_version) {
					if (eval("flash" + i + "Installed") == true) {
						ie_true = true;
					}
				}
		  }

		  if (!ie_true) {
			document.write(noFlashHTML);
		  } else {
			document.write(flashHTML);
		  }
				
		} else if (br.netscape4) {
		//
		//	Detection for old Netscape 4.x browsers. 
		//
			ns_flash = false;
			for (var i=0;i<=navigator.plugins.length;i++) {
				var plugin = navigator.plugins[i];
				if (plugin.name=="Shockwave Flash") {
					ns_flash = true;
					var description = plugin.description;
					var description_array = description.split(" ");
					var version_array = description_array[2].split(".");
					if (version_array[0]>=required_version) {
						document.write(flashHTML);
					} else {
						document.write(noFlashHTML);
					}
				}
			}
			if (!ns_flash) {
				document.write(noFlashHTML);
			}
		} 
	}
}

// Generates object and embed tags needed
function generateBasicFlashObject(flash_file, flash_width, flash_height, flash_params_obj, flash_params_emb) {

	var flash_HTML;

	flash_HTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+flash_width+'" height="'+flash_height+'" id="index" align="middle">';
	flash_HTML += '<param name="allowScriptAccess" value="sameDomain" />';
	flash_HTML += '<param name="movie" value="'+flash_file+'" />';
	if(flash_params_obj) { flash_HTML += flash_params_obj; }
	flash_HTML += '<param name="quality" value="high" />';
	flash_HTML += '<param name="bgcolor" value="#ffffff" />';
	flash_HTML += '<embed src="'+flash_file+'" ';
	if(flash_params_emb) { flash_HTML += flash_params_emb; }
	flash_HTML += ' quality="high" bgcolor="#ffffff" width="'+flash_width+'" height="'+flash_height+'" name="index" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	flash_HTML += '</object>';   

	return flash_HTML;

}

// Generates download link to flash plug-in
function generateBasicNoFlashPage() {
	
	var noFlash_HTML;
	
	noFlash_HTML = '<table bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0"><tr>';
	noFlash_HTML += '<td valign="top" valign="top">';
	noFlash_HTML += '<img src="/pics/1x1trans.gif" width="1" height="15" /><br />';
	noFlash_HTML += '<table bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0"><tr><td><p>In order to view the Flash content, you need to have Macromedia Flash Player installed on your computer. You can  <a href="http://www.macromedia.com/go/getflashplayer/" target="_blank">download the latest Flash Player for free</a> from Macromedia\'s website.<br><br>';
	noFlash_HTML += '</td></tr></table>';
	noFlash_HTML += '</td></tr></table>';

	return noFlash_HTML;

}
