function detector() {
this.v = parseFloat(navigator.appVersion);
this.uA = navigator.userAgent;
this.ns = false;
this.ns6 = false;
this.ie = false;
this.ie5 = false;
this.opera = false;
this.AOL = false;
this.mac = false;
this.pc = false;
this.dhtml = false;
this.Java = false;
this.Flash = "Not Detected";
this.loaded = false;
navigator.appVersion.indexOf('Mac') != -1 ? (this.mac=true) : (this.pc=true);
var ns6pos = this.uA.indexOf('Netscape6/');
var iepos = this.uA.indexOf('MSIE');
var oppos = this.uA.indexOf('Opera');
var AOLpos = this.uA.toUpperCase().indexOf('AOL');
if(oppos >= 0) {
	this.v = parseFloat(this.uA.substring(oppos+6,this.uA.length));
	this.opera = true;
} else {
	navigator.appName.indexOf('Netscape') != -1 ? (this.ns = true) : (this.ie = true);
}
if(iepos!=-1) {
	ie5cut = this.uA.substring(iepos+5,this.uA.length);
	this.v = parseFloat(ie5cut.substring(0,ie5cut.indexOf('\;')));
	if(this.v >= 5) this.ie5 = true;
}
if(ns6pos!=-1) {
	this.v=parseFloat(this.uA.substring(ns6pos+10,this.uA.length));
	this.ns6=true;
}
if(AOLpos!=-1) {
	this.AOL = parseFloat(this.uA.substring((AOLpos+3),this.uA.length));
}
if(this.v>=4) {
	this.dhtml = this.opera ? false : true;
	this.Java = navigator.javaEnabled();
}
detector.prototype.DetectFlash = DetectFlash;
}

function DetectFlash() {
if(this.Flash!="Not Detected") {
	return;
}
ActiveX='<SCRIPT LANGUAGE="VBScript">\n';
ActiveX+='Function GetFlashValue\n';
ActiveX+='on error resume next\n';
ActiveX+='dim tmpobj, FlashInstalled\n';
ActiveX+='FlashInstalled = 0\n';
ActiveX+='tmpobj = 0\n';
ActiveX+='set tmpobj = CreateObject("ShockwaveFlash.ShockwaveFlash.3")\n';
ActiveX+='if IsObject(tmpobj) then FlashInstalled = 3\n';
ActiveX+='tmpobj = 0\n';
ActiveX+='set tmpobj = CreateObject("ShockwaveFlash.ShockwaveFlash.4")\n';
ActiveX+='if IsObject(tmpobj) then FlashInstalled = 4\n';
ActiveX+='tmpobj = 0\n';
ActiveX+='set tmpobj = CreateObject("ShockwaveFlash.ShockwaveFlash.5")\n';
ActiveX+='if IsObject(tmpobj) then FlashInstalled = 5\n';
ActiveX+='tmpobj = 0\n';
ActiveX+='set tmpobj = CreateObject("ShockwaveFlash.ShockwaveFlash.6")\n';
ActiveX+='if IsObject(tmpobj) then FlashInstalled = 6\n';
ActiveX+='tmpobj = 0\n';
ActiveX+='set tmpobj = CreateObject("ShockwaveFlash.ShockwaveFlash.7")\n';
ActiveX+='if IsObject(tmpobj) then FlashInstalled = 7\n';
ActiveX+='tmpobj = 0\n';
ActiveX+='GetFlashValue = FlashInstalled\n';
ActiveX+='set tmpobj = CreateObject("ShockwaveFlash.ShockwaveFlash.8")\n';
ActiveX+='if IsObject(tmpobj) then FlashInstalled = 8\n';
ActiveX+='tmpobj = 0\n';
ActiveX+='GetFlashValue = FlashInstalled\n';
ActiveX+='set tmpobj = CreateObject("ShockwaveFlash.ShockwaveFlash.9")\n';
ActiveX+='if IsObject(tmpobj) then FlashInstalled = 9\n';
ActiveX+='tmpobj = 0\n';
ActiveX+='GetFlashValue = FlashInstalled\n';
ActiveX+='set tmpobj = CreateObject("ShockwaveFlash.ShockwaveFlash.10")\n';
ActiveX+='if IsObject(tmpobj) then FlashInstalled = 10\n';
ActiveX+='GetFlashValue = FlashInstalled\n';
ActiveX+='End Function\n';
ActiveX+='<\/SCRIPT>\n';
if(navigator.plugins && navigator.plugins.length > 0) {
	nparray=navigator.plugins;
	nparraylen=nparray.length;
	for(i=0; i<nparraylen; i++) {
		npplugin=nparray[i];
		npname=npplugin.name;
		npdesc=npplugin.description;
		if(npdesc.indexOf("Shockwave Flash 3") != -1) {
			this.Flash=3;
		}
		if(npdesc.indexOf("Shockwave Flash 4") != -1) {
			this.Flash=4;
		}
		if(npdesc.indexOf("Shockwave Flash 5") != -1) {
			this.Flash=5;
		}
		if(npdesc.indexOf("Shockwave Flash 6") != -1) {
			this.Flash=6;
		}
		if(npdesc.indexOf("Shockwave Flash 7") != -1){
			this.Flash=7;
		}
		if(npdesc.indexOf("Shockwave Flash 8") != -1){
			this.Flash=8;
		}
		if(npdesc.indexOf("Shockwave Flash 9") != -1){
			this.Flash=9;
		}
		if(npdesc.indexOf("Shockwave Flash 10") != -1){
			this.Flash=10;
		}
	}
} else if(this.ie) {
	if(!this.mac || (this.mac && this.ie && this.v>=5)) {
		document.write(ActiveX);
		this.Flash = GetFlashValue();
		if(!this.Flash) {
			this.Flash = false;
		}
	} else {
		this.Flash = -1;
	}
}
disableFlash = document.URL.toLowerCase().indexOf("flash=false") > document.URL.indexOf("?");
if(disableFlash) {
	this.Flash = false;
}
}

function flashObject() {
	// standard properties
	this.classid = "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000";
	this.codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0";
	this.type = "application/x-shockwave-flash";
	this.pluginspage = "http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash";
	
	// required properties
	this.file = -1;
	this.width = -1;
	this.height = -1;
	this.containerId = -1;
	
	// default properties
	this.flashVersion = 7;
	this.flashId = "flash_fcb";
	this.swliveconnect = "true";
	this.menu = "false";
	this.quality = "best";
	this.align = "l";
	this.salign = "t";
	this.bgcolor = "#000000";
	this.flashvars = "basepath=./";
	
	// detection
	this.flashDetected = true;
	
	this.required = new Array("file", "width", "height", "containerId");
	this.defaults = new Array("swliveconnect", "menu", "quality", "align", "salign", "bgcolor", "flashvars");
	this.optional = new Array("play", "loop", "scale", "wmode");
	flashObject.prototype.write = mtdFlashObject_Write;
	flashObject.prototype.display = mtdFlashObject_Display;
}

function mtdFlashObject_Write() {
	var strValues = "";
	var hasErrors = false;
	for (var i in this) {
	//		strValues += "this." + i + " = " + eval("this." + i) + "\n";		
		if (this.required.search(i) > -1 && this[i] == -1) {
			strValues += "property " + i + " is required.\n";
			hasErrors = true;
		}
	}
	if (hasErrors) {
		alert(strValues);
	} else {
		objDetector = new detector();
		objDetector.DetectFlash();
		if (objDetector.Flash >= this.flashVersion) {
		    this.flashDetected = true;
			document.getElementById(this.containerId).innerHTML = "";
			document.getElementById(this.containerId).style.visibility = "visible";
			document.getElementById(this.containerId).style.display = "block";
			this.insHTML = ('<OBJECT classid="' + this.classid + '" codebase="' + this.codebase + '" width="' + this.width + '" height="' + this.height + '" id="' + this.flashId +'">\n');
			this.insHTML += ('<PARAM NAME="movie" VALUE="' + this.file + '" />\n');
			var strEmbedParams = "";
			for (var i=0; i<this.defaults.length; i++) {
				var currParam = this.defaults[i];
				var currParamValue = eval("this." + currParam);
				if (currParamValue && currParamValue != "") {
					this.insHTML += ('<PARAM NAME="' + currParam + '" VALUE="' + currParamValue + '" />\n');
					strEmbedParams += (currParam + '="' + currParamValue + '" ');
				}
			}
	
			for (var i=0; i<this.optional.length; i++) {
				var currParam = this.optional[i];
				var currParamValue = eval("this." + currParam);
				if (currParamValue && currParamValue != "") {
					this.insHTML += ('<PARAM NAME="' + currParam + '" VALUE="' + currParamValue + '" />\n');
					strEmbedParams += (currParam + '="' + currParamValue + '" ');
				}
			}
			this.insHTML += ('<EMBED src="' + this.file + '" width="' + this.width + '" height="' + this.height + '" name="' + this.flashId + '" type="' + this.type + '" pluginspage="' + this.pluginspage + '" ' + strEmbedParams + '></EMBED>');
			this.insHTML += ('</OBJECT>');
		} else {
		    this.flashDetected = false;
			document.getElementById(this.containerId).style.visibility = "visible";
			document.getElementById(this.containerId).style.display = "block";
		}
	}
}

function mtdFlashObject_Display() {
	if (objDetector.Flash >= this.flashVersion) {
		document.getElementById(this.containerId).innerHTML = this.insHTML;
	}
}

Array.prototype.search = mtdArray_Search;

function mtdArray_Search(strQuery) {
var intFound = -1;
for (var i=0; i<this.length; i++) {
	if (this[i] == strQuery) {
		intFound = i;
	}
}
return intFound;
}
