var useRedirect = false; 
var hasRightVersion = false;
// the above is for legacy with the old flash checker

var is_flash   = false;

var is_flash_2 = false;
var is_flash_3 = false;
var is_flash_4 = false;
var is_flash_5 = false;
var is_flash_6 = false;
var is_flash_7 = false;
var is_flash_8 = false;
var is_flash_9 = false;

var flash_ver  = false;

var detect_min_ver = 2;
var detect_max_ver = 9;



function detectIE() {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	for( var count = detect_min_ver; count <= detect_max_ver; count++ ) {
		document.write( 'is_flash_' + count + ' = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.' + count + '"))) \n' );
	}
	document.write('<\/SCR' + 'IPT\> \n');
	for( var count = detect_min_ver; count <= detect_max_ver; count++ ) {
		if( eval('is_flash_' + count ) == true ) {
			flash_ver = count;
		}
	}
	if( flash_ver > 0 ) {
		is_flash = true;
	}
}

function detectNS() {
	if( navigator.plugins['Shockwave Flash 2.0'] || navigator.plugins['Shockwave Flash'] ) {
		var is_version_2 = navigator.plugins['Shockwave Flash 2.0'] ? ' 2.0' : "";
		var flash_description = navigator.plugins['Shockwave Flash' + is_version_2].description;
		var flash_version = parseInt( flash_description.substring( 16 ) );
		if( flash_version > 0 ) {
			flash_ver = flash_version;
			is_flash = true;
		}
	}
}

function detect() {

	if( navigator.plugins ) {
		detectNS();
	} 
	if( ( ! is_flash ) && navigator.userAgent && navigator.userAgent.indexOf("MSIE") >= 0 && ( navigator.appVersion.indexOf( 'Win' ) != -1 ) ) {
		detectIE();
	}
	
}

detect();

var FlashTag = function() {

	this.src 		= '';
	this.quality	= 'high';
	this.bgcolor	= '#FFFFFF';
	this.flashvars	= '';
	this.align		= 'middle';
	this.width		= '100';
	this.height		= '100';
	this.id			= 'default';

}


FlashTag.prototype.replace = function( search, replace, string ) {
	
	return( string.split( search ).join( replace ) );
	
}



FlashTag.prototype.toString = function() {

	var ret_val = '';
	
	var template = '';
	
	template += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="{#width}" height="{#height}" id="{#id}" align="{#align}">';
	template += '<param name="movie" value="{#src}" />';
	template += '<param name="quality" value="{#quality}" />';
	template += '<param name="bgcolor" value="{#bgcolor}" />';
	template += '<param name="flashvars" value="{#flashvars}" />';
	template += '<embed flashvars="{#flashvars}" src="{#src}" quality="{#quality}" bgcolor="{#bgcolor}" width="{#width}" height="{#height}" name="{#id}" align="{#align}" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	template += '</object>';
	
	
	ret_val = template;
	
	ret_val = this.replace( '{#src}', 		this.src, ret_val );
	ret_val = this.replace( '{#quality}', 	this.quality, ret_val );
	ret_val = this.replace( '{#bgcolor}', 	this.bgcolor, ret_val );
	ret_val = this.replace( '{#flashvars}', this.flashvars, ret_val );
	ret_val = this.replace( '{#align}', 	this.align, ret_val );
	ret_val = this.replace( '{#width}', 	this.width, ret_val );
	ret_val = this.replace( '{#height}', 	this.height, ret_val );
	ret_val = this.replace( '{#id}', 		this.id, ret_val );
	
	return( ret_val );
}

if ( is_flash && (flash_ver > 7)){
	hasRightVersion = true;
}