/*
	$Id: $
*/

function pluginDetection() {

	this.targetPlugName = "";
	this.targetVersion = 0;

	this.getPlugVersion = getPlugVersion;
	this.getAssessment = getAssessment;
	this.setTargetPlugName = setTargetPlugName;
	this.setTargetPlugVersion = setTargetPlugVersion;

	function setTargetPlugName(nm) {
		if (!!nm) this.targetPlugName = pluginNameConv(nm);
	}

	function setTargetPlugVersion(version) {
		if (!!version && version > 0) this.targetVersion = version;
	}

	function pluginNameConv() {
		if (arguments[0].indexOf("Shockwave",0) != -1 && arguments[0].indexOf("Flash",0) != -1 ) {
			if (document.all && navigator.userAgent.indexOf("Win",0) != -1 && navigator.userAgent.indexOf("Opera",0) == -1) return "ShockwaveFlash.ShockwaveFlash";
			else return "Shockwave Flash";
		} else {
			return arguments[0];
		}
	}

	function getPlugVersion() {
		if (document.all && navigator.userAgent.indexOf("Win",0) != -1 && navigator.userAgent.indexOf("Opera",0) == -1) {
			document.writeln('<script type="text/VBscript">');
			document.writeln('Function isPlugin(plugName, targetVer)');
			document.writeln('	Dim i, plg, range');
			document.writeln('	On Error Resume Next');
			document.writeln('	isPlugin = False');
			document.writeln('	range = targetVer * 5');
			document.writeln('	For i=range To 0 Step -1');
			document.writeln('		Set plg = CreateObject(plugName & "." & i)');
			document.writeln('		if IsObject(plg) Then');
			document.writeln('			isPlugin = CStr(i)');
			document.writeln('			Exit For');
			document.writeln('		End If');
			document.writeln('	Next');
			document.writeln('End Function');
			document.writeln('</sc'+ 'ript>');
		}

		function isTargetPlugin(pnm, pvn) {
			this.result = false;
			if (navigator.plugins) {
				if ( !!navigator.plugins[pnm] ) {
					for (this.i=0; this.i<=parseInt(pvn)*5; this.i++) {
						if ( navigator.plugins[pnm].description.indexOf(this.i+".0",0) != -1 ) this.result = this.i;
					}
				}
			}
			return this.result;
		}

		if (document.all && navigator.userAgent.indexOf("Win",0) != -1 && navigator.userAgent.indexOf("Opera",0) == -1) {
			return isPlugin( this.targetPlugName, this.targetVersion);
		} else {
			return isTargetPlugin( this.targetPlugName, this.targetVersion);
		}
	}

	function getAssessment() {
		if (parseInt(this.getPlugVersion()) >= this.targetVersion) return true;
		else if (document.all && navigator.userAgent.indexOf("Mac",0) != -1 && navigator.userAgent.indexOf("Opera",0) == -1) return false;
		else return false;
	}
}
