var detectableWithVB = false;
if (navigator.userAgent.indexOf('MSIE') != -1 && navigator.userAgent.indexOf('Win') != -1) {
    document.writeln('<script language="VBscript">');

    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');

    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('Function detectQuickTimeActiveXControl()');
    document.writeln('  on error resume next');
    document.writeln('  detectQuickTimeActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('    detectQuickTimeActiveXControl = False');
    document.writeln('    hasQuickTimeChecker = false');
    document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
    document.writeln('    If IsObject(hasQuickTimeChecker) Then');
    document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
    document.writeln('        detectQuickTimeActiveXControl = True');
    document.writeln('      End If');
    document.writeln('    End If');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('</scr' + 'ipt>');
}
function canDetectPlugins() {
    return detectableWithVB || (navigator.plugins && navigator.plugins.length > 0);
}
function getIndex(string) {
    return navigator.userAgent.toLowerCase().indexOf(string) + 1;
}
function MyBrowser() {
	this.Name = "unknown";
	this.Version = -1;
	this.OS = "unknown";
	if (getIndex('safari')) this.Name = "safari";
	else if (getIndex('firefox')) this.Name = "firefox";
	else if (getIndex('msie')) this.Name = "msie";
	else if (getIndex('opera')) this.Name = "opera";
	else if (!getIndex('compatible')) this.Name = "netscape";
	if (this.Name == "netscape")	
		this.Version = navigator.userAgent.charAt(8);
	else if (this.Name != "unknown")
		this.Version = navigator.userAgent.charAt(getIndex(this.Name) + this.Name.length);
	if (getIndex('linux')) this.OS = "Linux";
	else if (getIndex('x11')) this.OS = "Unix";
	else if (getIndex('mac')) this.OS = "Mac"
	else if (getIndex('win')) this.OS = "Windows"
	this.HasFlash = detectFlash;
	this.WriteFlash = writeFlashObject;
	this.HasQuickTime = detectQuickTime;
	this.WriteQuickTime = writeQuickTimeObject;
	this.IsSecure = document.location.href.indexOf("https://") == 0;
}
function detectFlash() {
    var pluginFound = detectPlugin('Shockwave','Flash'); 
    if (!pluginFound && detectableWithVB) 
		pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
    return pluginFound;
}
function detectQuickTime() {
    var pluginFound = detectPlugin('QuickTime');
    if (!pluginFound && detectableWithVB) 
		pluginFound = detectQuickTimeActiveXControl();
    return pluginFound;
}
function detectPlugin() {
    var daPlugins = detectPlugin.arguments;
    var pluginFound = false;
    if (navigator.plugins && navigator.plugins.length > 0) {
		var pluginsArrayLength = navigator.plugins.length;
		for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
			var numFound = 0;
			for (namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
				if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
					numFound++;
				}   
			}
			if (numFound == daPlugins.length) {
				pluginFound = true;
				break;
			}
		}
    }
    return pluginFound;
}
function writeFlashObject(height, width, src) {
	var _OBJECT_HTML = "";

	if (this.OS == "Windows" && this.Name == "msie") {
		_OBJECT_HTML += "<OBJECT height=\"$1\" width=\"$2\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\">";
		_OBJECT_HTML += "<PARAM NAME=\"FlashVars\" VALUE=\"\">";
		_OBJECT_HTML += "<PARAM NAME=\"Movie\" VALUE=\"$3\">";
		_OBJECT_HTML += "<PARAM NAME=\"Src\" VALUE=\"$4\">";
		_OBJECT_HTML += "<PARAM NAME=\"WMode\" VALUE=\"Transparent\">";
		_OBJECT_HTML += "<PARAM NAME=\"Play\" VALUE=\"0\">";
		_OBJECT_HTML += "<PARAM NAME=\"Loop\" VALUE=\"-1\">";
		_OBJECT_HTML += "<PARAM NAME=\"Quality\" VALUE=\"High\">";
		_OBJECT_HTML += "<PARAM NAME=\"SAlign\" VALUE=\"LT\">";
		_OBJECT_HTML += "<PARAM NAME=\"Menu\" VALUE=\"-1\">";
		_OBJECT_HTML += "<PARAM NAME=\"Base\" VALUE=\"\">";
		_OBJECT_HTML += "<PARAM NAME=\"AllowScriptAccess\" VALUE=\"\">";
		_OBJECT_HTML += "<PARAM NAME=\"Scale\" VALUE=\"ShowAll\">";
		_OBJECT_HTML += "<PARAM NAME=\"DeviceFont\" VALUE=\"0\">";
		_OBJECT_HTML += "<PARAM NAME=\"EmbedMovie\" VALUE=\"0\">";
		_OBJECT_HTML += "<PARAM NAME=\"BGColor\" VALUE=\"\">";
		_OBJECT_HTML += "<PARAM NAME=\"SWRemote\" VALUE=\"\">";
		_OBJECT_HTML += "<PARAM NAME=\"MovieData\" VALUE=\"\">";
		_OBJECT_HTML += "<PARAM NAME=\"SeamlessTabbing\" VALUE=\"1\">";
		_OBJECT_HTML += "<PARAM NAME=\"Profile\" VALUE=\"0\">";
		_OBJECT_HTML += "<PARAM NAME=\"ProfileAddress\" VALUE=\"\">";
		_OBJECT_HTML += "<PARAM NAME=\"ProfilePort\" VALUE=\"0\">";
		_OBJECT_HTML += "</OBJECT>";
	}
	else {
		_OBJECT_HTML += "<EMBED type=\"application/x-shockwave-flash\" height=\"$1\" width=\"$2\" src=\"$3\" ";
		_OBJECT_HTML += "quality=\"high\" salign=\"lt\" wmode=\"transparent\"></EMBED>";
	}

	_OBJECT_HTML = _OBJECT_HTML.replace("$1", height);
	_OBJECT_HTML = _OBJECT_HTML.replace("$2", width);
	_OBJECT_HTML = _OBJECT_HTML.replace("$3", src);
	_OBJECT_HTML = _OBJECT_HTML.replace("$4", src);

	document.write(_OBJECT_HTML);
}
function writeQuickTimeObject(height, width, src) {
	var objImg = document.getElementById("imgQuickTime");
	if (objImg) objImg.style.display="none";

	var _OBJECT_HTML = "";

	if (this.OS == "Windows" && this.Name == "msie") {
		_OBJECT_HTML += "<OBJECT height=$1 width=$2 classid=clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B>";
		_OBJECT_HTML += "<PARAM NAME=\"src\" VALUE=\"$3\">";
		_OBJECT_HTML += "<PARAM NAME=\"autoplay\" VALUE=\"true\">";
		_OBJECT_HTML += "<PARAM NAME=\"controller\" VALUE=\"true\">";
		_OBJECT_HTML += "<PARAM NAME=\"loop\" VALUE=\"false\">";
		_OBJECT_HTML += "</OBJECT>";
	}
	else {
		_OBJECT_HTML += "<EMBED height=\"$1\" width=\"$2\" src=\"$3\" ";
		_OBJECT_HTML += "autoplay=\"true\" controller=\"true\" loop=\"false\"></EMBED>";
	}

	_OBJECT_HTML = _OBJECT_HTML.replace("$1", height);
	_OBJECT_HTML = _OBJECT_HTML.replace("$2", width);
	_OBJECT_HTML = _OBJECT_HTML.replace("$3", src);

	document.write(_OBJECT_HTML);
} 
