var flashVersion = 0;
var latestFlashVersion = 9;
var agent = navigator.userAgent.toLowerCase(); 

// IE4+ 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) {

if (agent.indexOf("Mac_") == -1 && agent.indexOf("Macintosh") == -1) {
	var doc = '<scr' + 'ipt language="VBScript"\> \n';
	doc += 'On Error Resume Next \n';
	doc += 'Dim obFlash \n';
	doc += 'For i = ' + latestFlashVersion + ' To 3 Step -1 \n';
	doc += '   Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n';
	doc += '   If IsObject(obFlash) Then \n';
	doc += '      flashVersion = i \n';
	doc += '      Exit For \n';
	doc += '   End If \n';
	doc += 'Next \n';
	doc += '</scr' + 'ipt\> \n';
	document.write(doc);
}

function detectFlash() {

	// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object') { 
			for (var i = latestFlashVersion; i >= 3; i--) {
				if (flashPlugin.description.indexOf(i + '.') != -1) {
					flashVersion = i;
					break;
				}
			}
		}
	} else {
		// WebTV 2.5 supports flash 3
		if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;
		// older WebTV supports flash 2
		if (agent.indexOf("webtv") != -1) flashVersion = 2;
	}

	// disable all flash on Mac
	//if (agent.indexOf("Mac_") != -1) flashVersion = 0;
	//if (agent.indexOf("Macintosh") != -1) flashVersion = 0;

	return parseFloat(flashVersion);
}

function DrawFlash(file,width,height,minver,image,link,title) {
 var html=''
 //if (detectFlash()>=<?php if (isset($form['noflash'])) {echo "99";} else {echo "minver";} ?>) {
 if (detectFlash()>=minver) {
  html+="<OBJECT classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'"
  html+=" codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'"
  html+=" width='"+width+"' height='"+height+"'>"
  html+="<param name='allowScriptAccess' value='sameDomain'>"
  html+="<param name='movie' value='"+file+"'>"
  html+="<param name='quality' value='high'>"
  //html+="<param name='bgcolor' value='#ffffff'>"
  //html+="<param name='loop' value='false'>"
  html+="<param name='menu' value='false'>"
  html+="<param name='wmode' value='transparent'>"
  //html+="<param name='FlashVars' value='playintro=false'>"
  html+="<EMBED src='"+file+"'"
  //html+=" wmode='transparent' loop='false' menu='false' quality='high'"
  //html+=" FlashVars='playintro=false'"
  html+=" bgcolor='#ffffff' width='"+width+"' height='"+height+"'"
  html+=" allowScriptAccess='sameDomain'"
  html+=" type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></EMBED>"
  html+="</OBJECT>"
 } else {
  html+="<A href=\""+link+"\">"
  html+="<IMG src=\""+image+"\" alt='"+title+"' width='"+width+"' height='"+height+"' border=0>"
  html+="</A>"
 }
 return html
}
