var requiredVersion = 7;
var useRedirect = false;

var flash2Installed = false;
var flash3Installed = false;
var flash4Installed = false;
var flash5Installed = false;
var flash6Installed = false;
var flash7Installed = false;
var flash8Installed = false;
var flash9Installed = false;
var maxVersion = 9;
var actualVersion = 0;
var hasRightVersion = false;
var jsVersion = 1.0;
var flashPage
var noFlashPage
var upgradePage

function detectFlash() {  
	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
	var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; // true if we're on windows
	jsVersion = 1.1;
	if(isIE && isWin){
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
		document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
		document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
		document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
		document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
		document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
		document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
		document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
		document.write('<\/SCR' + 'IPT\> \n');
	}
	if (navigator.plugins) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
			var flashVersion = parseInt(flashDescription.substring(16));

			flash2Installed = flashVersion == 2;    
			flash3Installed = flashVersion == 3;
			flash4Installed = flashVersion == 4;
			flash5Installed = flashVersion == 5;
			flash6Installed = flashVersion == 6;
			flash7Installed = flashVersion == 7;
			flash8Installed = flashVersion == 8;
			flash9Installed = flashVersion >= 9;
		}
	}
	for (var i = 2; i <= maxVersion; i++) {  
		if (eval("flash" + i + "Installed") == true) actualVersion = i;
	}
	if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 4;  
	if (actualVersion >= requiredVersion) {
		return true;                
	} else {  
		return false;
	}
}

function flashComponent(){
	this.classId = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
	this.codeBase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0';
	this.fileName = '';
	this.altImage = '';
	this.bgColor = null;
	this.altText = '';
	this.width = '150';
	this.height = '30';
	this.align = 'middle';
	this.flashVars = null;
	this.id = 'FlashHtml';
	this.movie = '';
	this.scale = 'exactfit';
	this.quality = 'high'
	this.menu = '';
	this.flashVersion = 6;
	this.wMode = 'opaque';
	this.cabVersion = '6,0,0,0';
	this.allowScriptAccess = 'sameDomain';
	this.type = 'application/x-shockwave-flash';
	this.pluginspage = 'http://www.macromedia.com/go/getflashplayer';
}

flashComponent.prototype.render = function(){
	var requiredVersion = 4;
	var strFlashHtml = '';
	if(detectFlash()){
		strFlashHtml += '<object classid="' + this.classId + '" codebase="' + this.codeBase + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '">';
		strFlashHtml += '	<param name="allowScriptAccess" value="' + this.allowScriptAccess + '" />';
		strFlashHtml += '	<param name="movie" value="' + this.movie + '" />';
		strFlashHtml += '	<param name="quality" value="' + this.quality + '" />';
		strFlashHtml += ' <param name="wmode" value="transparent" />';
		if(this.bgColor){ strFlashHtml += '	<param name="bgcolor" value="' + this.bgColor + '" />';}
		strFlashHtml += '	<param name="scale" value="' + this.scale + '" />';
		if(this.flashVars){ strFlashHtml += '	<param name="FlashVars" value="' + this.flashVars + '" />'; }
		strFlashHtml += '	<embed src="' + this.movie + '" quality="' + this.quality + '" FlashVars="' + this.flashVars + '" bgcolor="' + this.bgColor + '" width="' + this.width + '" height="' + this.height + '" name="' + this.id + '" align="' + this.align + '" allowScriptAccess="' + this.allowScriptAccess + '" type="' + this.type + '" pluginspage="' + this.pluginsPage + '" wmode="transparent" />';
		strFlashHtml += '</object>';
	} else {
		strFlashHtml = '<img src="' + this.altImage + '" alt="' + this.altText + '"/>';
	}
	document.write(strFlashHtml);
}

function encodeTitle(strTitle){
	var strEncodedTitle = strTitle;
	return strEncodedTitle;
}


function encodeValue(sStr) {
	var strEncoded = escape(sStr).replace(/\+/g, '%2C').replace(/\"/g,'%22').replace(/\'/g, '%27');
	
	strEncoded = strEncoded.replace('%D8', 'Ø');
	strEncoded = strEncoded.replace('%E6', 'æ');
	strEncoded = strEncoded.replace('%C6', 'Æ');
	strEncoded = strEncoded.replace('%E5', 'å');
	strEncoded = strEncoded.replace('%C5', 'Å');
	strEncoded = strEncoded.replace('%E4', 'ä');
	strEncoded = strEncoded.replace('%C4', 'Ä');
	return strEncoded;
}