///////////////////////////////////////////////////
// Flash handler
//
// Author: Derrick Grigg, Martin Andres
// Date: Sep 9, 2005
//
///////////////////////////////////////////////////

var flashVersion =	getFlashVersion();

// ----- Turn on Flash through css ----- //
// Must have flash 7 and "printerfriendly" is not in url
if (flashVersion >= 7 && document.URL.indexOf('printerfriendly') == -1 ) {
	document.writeln("<STYLE>.divFlash{display:block;}.divHtml{display:none;}</"+"STYLE>");
}

function getFlashVersion() {
	var flashversion = 0;
	if (navigator.plugins && navigator.mimeTypes.length) {
		var x = navigator.plugins["Shockwave Flash"];

		if(x && x.description) {
			var y = x.description;
			flashversion = y.charAt(y.indexOf('.')-1);
		}
	} else {
		result = false;
		for(var i = 10; i >= 3 && result != true; i--){
			var res = execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
			flashversion = i;
		}
	}
	return flashversion;
}


function detectFlash(ver, req) {
	return (ver >= req) ? true:false; 
}

function drawFlash(file, width, height, vars, elements, param) {
	var fl = "";
	var ele = new Array();
	var par = new Array();

	if (elements) ele = elements.split("&");
	if (param) par = param.split("&");

    fl+="<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'\n";
    fl+=" codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'\n";
	if (width)  fl+=" width='"+width+"'";
	if (height) fl+=" height='"+height+"'";
	fl+="\n";
	for (var i=0; i<ele.length; i++) {
		tmp = ele[i].split("=");
		if (tmp[1] && tmp[0].toLowerCase()!="name" && tmp[0].toLowerCase()!="scale") fl+=" "+tmp[0]+"="+tmp[1]+"\n";
	}
	fl+=">\n";
	fl+="<PARAM name='movie' value=\""+file+"\" />\n";
	fl+="<PARAM name='quality' value='high' />\n";
	fl+="<PARAM name='menu' value='false' />\n";
	//fl+="<PARAM name='scale' value='noscale' />\n";
	if (vars) fl+="<PARAM name='flashVars' value=\""+vars+"\" />\n";
	for (var i=0; i<par.length; i++) {
		tmp = par[i].split("=");
		if (tmp[1]) fl+="<PARAM name='"+tmp[0]+"' value="+tmp[1]+" />\n";
	}
	fl+="<EMBED src=\""+file+"\"\n";
	fl+=" QUALITY='high'\n";
	if (vars)   fl+=" FLASHVARS=\""+vars+"\"\n";
	if (width)  fl+=" width='"+width+"'";
	if (height) fl+=" height='"+height+"'";
	fl+="\n";
	for (var i=0; i<ele.length; i++) {
		tmp = ele[i].split("=");
		if (tmp[1] && tmp[0].toLowerCase()!="id") fl+=" "+tmp[0]+"="+tmp[1]+"\n";
	}
	fl+=" TYPE='application/x-shockwave-flash'\n";
	fl+=" PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'\n";
	fl+="></EMBED>\n";
	fl+="</OBJECT>";

	//fl+="<ABBR title=\""+file+"\">flash</ABBR>";
	//if (file.indexOf("globalFeatures")>-1) alert(fl);

	document.write(fl);
}
