function FlashWrapper(){}

FlashWrapper.prototype.initFlashWrapper = function(inMovie, inWidth, inHeight, inWmode, inStaticImg, inStaticImgLink, inStaticImgAlt, inStaticImgMap, inBoolStaticImgSizeDiff, inWidth2, inHeight2, inCSSClassFlash, inCSSClassNoFlash, inFlashVars)
{
	//DEBUG
	//alert("initFlashWrapper() called");

	this.thisMovie = unescape(inMovie);
	this.thisWidth = inWidth;
	this.thisHeight = inHeight;
	this.thisWmode = inWmode;
	this.thisStaticImg = unescape(inStaticImg);
	this.thisStaticImgLink = unescape(inStaticImgLink);
	this.thisStaticImgAlt = unescape(inStaticImgAlt);
	this.thisStaticImgMap = inStaticImgMap;
	this.thisBoolStaticImgSizeDiff = inBoolStaticImgSizeDiff;
	this.thisWidth2 = inWidth2;
	this.thisHeight2 = inHeight2;
	this.thisCSSClassFlash = inCSSClassFlash;
	this.thisCSSClassNoFlash = inCSSClassNoFlash;
	this.thisFlashVars = inFlashVars;
	
	// Check to see that Flash is installed and that it is the correct version
	// If not, show default image

	this.flashinstalled = 0;
	this.flashversion = 0;
	this.MSDetect = "false";
	this.finalObjString = "";
	
	if ( navigator.plugins && navigator.plugins.length )
	{
		x = navigator.plugins["Shockwave Flash"];
		
		if ( x )
		{
			flashinstalled = 2;
			
			if ( x.description )
			{
				y = x.description;
				flashversion = y.charAt(y.indexOf('.')-1);
			}
		}
		else {
			flashinstalled = 1;
		}
		
		if ( navigator.plugins["Shockwave Flash 2.0"] )
		{
			flashinstalled = 2;
			flashversion = 2;
		}
		
		if( flashinstalled == "2" && flashversion >= "7" )
		{
			finalObjString = this.getFlashObj();
		}
		else {				
			finalObjString = this.getStaticImg();
		}
	}
	else if ( navigator.mimeTypes && navigator.mimeTypes.length )
	{
		x = navigator.mimeTypes['application/x-shockwave-flash'];
		
		if ( x && x.enabledPlugin )
		{
			flashinstalled = 2;
		}
		else {
			flashinstalled = 1;
		}
		
		if ( flashinstalled == "2" && flashversion >= "7" )
		{
			finalObjString = this.getFlashObj();
		}
		else {
			finalObjString = this.getStaticImg();
		}
	}
	else
	{
		MSDetect = "true";
		//---------------------------------------------------------------------------------------------------------------------
		// 	Check the browser...we're looking for ie/win
		
		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
		
		if( isIE && isWin )
		{
			detectFlash();
		 	if ((flash6Installed == true) || (flash7Installed == true) || (flash8Installed == true) || (flash9Installed == true) || (flash10Installed == true)) 
			{
				finalObjString = this.getFlashObj();
			}
			else {
				finalObjString = this.getStaticImg();
			}
		}
	}
	
	// write the resulting object tag to the web page
	
	//DEBUG
	//alert("finalObjString: " + finalObjString);
	document.write(finalObjString);
}	


FlashWrapper.prototype.getFlashObj = function()
{
	var objTag = "";

	if ( this.thisWmode == "" )
	{
		this.thisWmode = "false";
	}
	
	if ( this.thisCSSClassFlash != "" )
	{
		objTag += '<div class="' + this.thisCSSClassFlash + '">';
	}
	
	objTag += '<object type="application/x-shockwave-flash" data="' + this.thisMovie + '" '
			+ 'width="' + this.thisWidth + '" height="' + this.thisHeight + '">'
			+ '<param name="movie" VALUE="' + this.thisMovie + '">'
			+ '<param name="play" VALUE="true">'
			+ '<param name="quality" VALUE="high">'
			+ '<param name="menu" VALUE="false">'
			+ '<param name="wmode" VALUE="' + this.thisWmode + '">'	
			+ '<param name="FlashVars" VALUE="' + this.thisFlashVars + '">'							
			+ '<\/object>';
			
	if ( this.thisCSSClassFlash != "" )
	{
		objTag += '<\/div>';
	}

	return(objTag);
}	
		
			
FlashWrapper.prototype.getStaticImg = function()
{
	var objTag = "";

	var p_width, p_height;
	var p_isStaticImgDiff = this.thisBoolStaticImgSizeDiff;
	
	// find size of static image
	if( p_isStaticImgDiff == "true" )
	{
		p_width = this.thisWidth2;
		p_height = this.thisHeight2;
	}
	else {
		p_width = this.thisWidth;
		p_height = this.thisHeight;
	}

	if ( this.thisStaticImg != "" ) 
	{
		if ( this.thisCSSClassNoFlash != "" )
		{
			objTag += ('<div class="' + this.thisCSSClassNoFlash + '">');
		}
			if( this.thisStaticImgMap == "" )
			{
				if ( this.thisStaticImgLink != "" )
				{
					objTag += '<a href="' + this.thisStaticImgLink + '">';
				}
				
				objTag += '<img src="' + this.thisStaticImg + '" width="' + p_width + '" height="' + p_height + '" border="0" alt="' + this.thisStaticImgAlt + '" />';
				
				if ( this.thisStaticImgLink != "" )
				{
					objTag += '<\/a>';
				}
			}
			
			else
			{
				objTag += '<img src="' + this.thisStaticImg + '" width="' + p_width + '" height="' + p_height + '" border="0" alt="' + this.thisStaticImgAlt + '" usemap="#' + this.thisStaticImgMap + '">';
			}
		if ( this.thisCSSClassNoFlash != "" )
		{
			objTag += '</div>';
		}

	}
	
	return(objTag);
}
function detectFlash() {

    for(var i=8; i>0; i--){

          flashVersion = 0;

          try{

                var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);

                flashVersion = i;

            // We found the version, now set appropriate version flags. Make sure

                // to use >= on the highest version so we don't prevent future version

                // users from entering the site.

                flash2Installed = flashVersion == 2;    

                flash3Installed = flashVersion == 3;

                flash4Installed = flashVersion == 4;

                flash5Installed = flashVersion == 5;

                flash6Installed = flashVersion == 6;

                flash7Installed = flashVersion == 7;

                flash8Installed = flashVersion == 8;

                flash9Installed = flashVersion >= 9;

                flash10Installed = flashVersion >= 10;    

                return;

          }

          catch(e){

          }

    }

}
