//Flash version 6+ detection
var ShockMode = false;
DetectFlash(8);

function DetectFlash(version) {
	var flashversion = function() {
		// ie
		try {
			try {
				// avoid fp6 minor version lookup issues
				// see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
				var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
				try { axo.AllowScriptAccess = 'always'; }
				catch (e) { return '6,0,0'; }
			} catch (e) { }
			return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
			// other browsers
		} catch (e) {
			try {
				if (navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
					return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
				}
			} catch (e) { }
		}
		return '0,0,0';
	} ();

	var major = parseInt(flashversion.substring(0, flashversion.indexOf(",")));
	ShockMode = major >= version;
	return ShockMode;
}

function WriteFlash (tagID_Name, swfName, width, height, imgSrc)
{
	if (ShockMode)
	{
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write(' codebase="'+document.location.protocol+'//www.adobe.com/go/getflashplayer"');
		document.write(' width="'+width+'" height="'+height+'" id="'+tagID_Name+'">');
		document.write(' <param name="movie" value="'+swfName+'"><param name="allowScriptAccess" value="always"> '); 
		document.write(' <param name="quality" value="best"><param name="wmode" value="opaque"> ');
		document.write(' <embed name="'+tagID_Name+'" src="'+swfName+'" quality="best" allowScriptAccess="always"'); 
		document.write(' swliveconnect="true" width="'+width+'" height="'+height+'"');
		document.write(' type="application/x-shockwave-flash" pluginspage="'+document.location.protocol+'//www.adobe.com/go/getflashplayer">');
		document.write('</embed>');
		document.write('</object>');
		if (imgSrc != null) document.write('<noembed><img id="'+tagID_Name+'" width="'+width+'" height="'+height+'" src="'+imgSrc+'" border=0></noembed>');
	}
	else
	{
		if (imgSrc != null) document.write('<img id="'+tagID_Name+'" width="'+width+'" height="'+height+'" src="'+imgSrc+'" border=0>');
	}
}

function WriteFlashToContainer (tagID_Name, swfName, width, height, containerID)
{
	if (ShockMode)
	{
		var container = document.getElementById(containerID);
		container.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+
				' codebase="'+document.location.protocol+'//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"'+
				' width="'+width+'" height="'+height+'" id="'+tagID_Name+'">'+
				' <param name="movie" value="'+swfName+'"><param name="allowScriptAccess" value="always"> '+
				' <param name="quality" value="best"><param name="wmode" value="opaque"> '+
				' <embed name="'+tagID_Name+'" src="'+swfName+'" quality="best" allowScriptAccess="always"'+
				' swliveconnect="true" width="'+width+'" height="'+height+'"'+
				' type="application/x-shockwave-flash" pluginspage="'+document.location.protocol+'//www.adobe.com/go/getflashplayer">'+
				'</embed>'+
				'</object>';
	}
}