// Flash Detection Object with variable support
// -----------------------------------------------------------------------------

var Flash = new Object();

Flash.hasVersion = function (versionRequired) {
	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
		var description = navigator.plugins["Shockwave Flash"].description;
		var version = parseInt (description.charAt (description.indexOf (".") - 1));
		return version >= versionRequired;
	}
	if (navigator.appVersion.indexOf ("Windows") != -1 && window.execScript) {
		this.hasVersionResult = null;
		execScript ('on error resume next: Flash.hasVersionResult=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.' + versionRequired + '"))','VBScript');
		return this.hasVersionResult;
	}
	return false;
}
Flash.redirect = function (versionRequired, noFlashPage, noRedirectFlag) {
	if (document.referrer.indexOf (noFlashPage) != -1) return;
	if (noRedirectFlag && window.location.search.indexOf (noRedirectFlag) != -1) return;
	if (!this.hasVersion (versionRequired)) window.location.href = noFlashPage;
}

// -----------------------------------------------------------------------------

Flashtag = function (version, movie, width, height) {
	this.version = version;
	this.movie = movie;
	this.width = width;
	this.height = height;
	this.props = new Array();
	this.vars = new Array();
}
Flashtag.prototype.addProperty = function (name, value) {
	this.props[name] = value;
}
Flashtag.prototype.addVariable = function (name, value) {
	this.vars[name] = value;
}
Flashtag.prototype.render = function () {
	var fvars = "";
	for (var i in this.vars) fvars += i + "=" + escape (this.vars[i]) + "&"; 
	this.addProperty ("FlashVars", fvars);
	var tag = '<object';
	tag += ' width="' + this.width + '"';
	tag += ' height="' + this.height + '"';
	tag += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	tag += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.version + ',0,0,0">';
	tag += '<param name="movie" value="' + this.movie + "?" + fvars + '" />';
	for (var i in this.props) tag += '<param name="' + i + '" value="' + this.props[i] + '" />';
	tag += '<embed src="' + this.movie + "?" + fvars + '"';
	tag += ' type="application/x-shockwave-flash"';
	tag += ' pluginspage="http://www.macromedia.com/go/getflashplayer"';
	tag += ' width="' + this.width + '"';
	tag += ' height="' + this.height + '"';
	for (var i in this.props) tag += ' ' + i + '="' + this.props[i] + '"';
	tag += '><\/embed>';
	tag += '<\/object>';
	return tag;
}