
winIEpass = ((navigator.appName.indexOf("Microsoft") != -1) && 
	(navigator.appVersion.indexOf("Windows") != -1)) && 
	(parseFloat(navigator.appVersion) >= 4) ? true : false;

NNpass = ((navigator.appName == "Netscape") && 
	(navigator.userAgent.indexOf("Mozilla") != -1) && 
	(parseFloat(navigator.appVersion) >= 4)) ? true : false;
	//	&& 
	//(navigator.javaEnabled())) ? true : false;
#NNpass=true;

supportedBrowser = (winIEpass || NNpass) ? true : false;

// check for Flash Plug-in in Mac or Win Navigator. Get plug-in version.
minPlayer = 4;
var mySwf;

function flash_checkForPlugIn()
{
	var plugin = (navigator.mimeTypes &&
	navigator.mimeTypes["application/x-shockwave-flash"]) ?
	navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if (plugin) {
		var pluginversion = parseInt(plugin.description.substring(plugin.description.indexOf(".")-2)) 
		if(pluginversion >= minPlayer) {return true;}
	}
	return false;
}

// vbscript check for Flash ActiveX control in windows IE
if(supportedBrowser && winIEpass)
{
document.write(
		'<script language=VBScript>' + '\n' +
		'Function flash_checkForActiveX()' + '\n' +
			'Dim hasPlayer, playerversion' + '\n' +
			'hasPlayer = false' + '\n' +
			'playerversion = 10' + '\n' +
			'Do While playerversion >= minPlayer' + '\n' +
				'On Error Resume Next' + '\n' +
				'hasPlayer = (IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" & playerversion & \"\")))' + '\n' +
				'If hasPlayer = true Then Exit Do' + '\n' +
				'playerversion = playerversion - 1' + '\n' +
			'Loop' + '\n' +
			'flash_checkForActiveX = hasPlayer' + '\n' +
		'End Function' + '\n' +
		'<\/script>'
		);
}



function flash_checkForMinPlayer()
{
#alert('1')
	if(!supportedBrowser) return false;
#alert('2')
	if(NNpass) return (flash_checkForPlugIn());
#alert('3')
	if(winIEpass) return (flash_checkForActiveX());
}



function flash_embedSWF(srcURL, id, swfbgColor)
{
#	return false;
	if (!flash_checkForMinPlayer()) return;

#||define||_junk_||x||
||ifdef||_junk_||
	var defaultColor = (document.bgColor != null) ? document.bgColor : "#ffffff";
	var bgcolor = (swfbgColor != null) ? swfbgColor : defaultColor;

	document.writeln(
	'<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
	'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0"' +
	'ID="' + id + '" WIDTH="100%" HEIGHT="100%">' +
	'<PARAM NAME="movie" VALUE="' + srcURL + '">' + 
	'<PARAM NAME="quality" VALUE="high">' +
	'<PARAM NAME="wmode" VALUE="transparent">'+
    '<PARAM NAME="autostart" VALUE="false">'+
	'<PARAM NAME="bgcolor" VALUE=' + bgcolor + '>' +

	'<EMBED src="' + srcURL + '" quality="high"' +
	' bgcolor="' + bgcolor + '" WIDTH=100% HEIGHT=100% ' +
#	' wmode=transparent ' +
	' TYPE="application/x-shockwave-flash" NAME="' + id + '"' +
	' PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">' +
	'</EMBED></OBJECT>'
	);
||else||
	document.writeln(sound_flash_html(srcURL, id, swfbgColor));
||endif||
}

function sound_flash_html(srcURL, id, swfbgColor)
{
	var defaultColor = (document.bgColor != null) ? document.bgColor : "#ffffff";
	var bgcolor = (swfbgColor != null) ? swfbgColor : defaultColor;

||ifdef||_junk_||
	return 
	'<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
	'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0"' +
	'ID="sonify" WIDTH=1px HEIGHT=1px>' +
	'<PARAM NAME=movie VALUE="' + srcURL + '">' + 
	'<PARAM NAME=quality VALUE=low>' +
#	'<PARAM NAME=wmode VALUE=transparent>'+
	'<PARAM NAME=bgcolor VALUE=' + bgcolor + '>' +
	'<EMBED swLiveConnect="true" NAME="sonify"' +
	' src="' + srcURL + '" ' +
	' quality=low ' +
#	' wmode=transparent ' +
	' bgcolor= ' + bgcolor + 
	' WIDTH=1px HEIGHT=1px ' +
	' TYPE="application/x-shockwave-flash"'+	
	' PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">' +
	'</EMBED>' + 
	'</OBJECT>';
||else||
	return '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
	'ID="' + id + '" WIDTH="1px" HEIGHT="1px">' +
	'<PARAM NAME="movie" VALUE="' + srcURL + '">' + 
	'<PARAM NAME="quality" VALUE="high">' +
	'<PARAM NAME="wmode" VALUE="transparent">'+
    '<PARAM NAME="autostart" VALUE="false">'+
	'<PARAM NAME="bgcolor" VALUE=' + bgcolor + '>' +

	'<EMBED src="' + srcURL + '" quality="high"' +
	' bgcolor="' + bgcolor + '" WIDTH=1px HEIGHT=1px ' +
#	' wmode=transparent ' +
	' TYPE="application/x-shockwave-flash" NAME="' + id + '"' +
#	' PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">' +
	'</EMBED></OBJECT>';



	return '<OBJECT '+
	'ID="sonify" WIDTH=1px HEIGHT=1px type="application/x-shockwave-flash" data="' + srcURL +'>' +
	'<PARAM NAME=movie VALUE="' + srcURL + '">' + 
	'<PARAM NAME=quality VALUE=high>' +
#	'<PARAM NAME=wmode VALUE=transparent>'+
	'<PARAM NAME=bgcolor VALUE=' + bgcolor + '>' +
	'<param name="allowScriptAccess" value="always" />'+
	'<EMBED swLiveConnect="true" Name="sonify"' +
	' src="' + srcURL + '" ' +
	' quality=high ' +
#	' wmode=transparent ' +
	' bgcolor= ' + bgcolor + 
	' WIDTH=1px HEIGHT=1px ' +
	'</EMBED>' + 
	'</OBJECT>';

||endif||

}

function flash_embedSWF2(url) 
{
	var o,frag;
	o = document.getElementsByTagName("body")[0];
	frag = document.createElement("div");
#	container.style.width = "1px";
#	container.style.height = "1px";
	o.appendChild(frag);
	frag.innerHTML = sound_flash_html(url,'sonify');
};




function flash_sound(target,frame){
	try {

		if(!flash_checkForMinPlayer()) { dbg('Flash not supported'); return; }

		mySwf = window.document.sonify;
#		if (!mySwf || !mySwf.PercentLoaded || mySwf.PercentLoaded()<100) { dbg('Flash not loaded'); return; }
		if (!mySwf || mySwf.PercentLoaded()<100) { dbg('Flash not loaded'); return; }

		if(typeof(frame) == "number"){
			mySwf.TGotoFrame(target,frame - 1);
		}
		if(typeof(frame) == "string"){
			mySwf.TGotoLabel(target,frame);
		}
	}
	catch (ex) {
		dbg('ERROR CAUGHT: No Flash sounds')
	}
}
