<!-- 
/*
------------------------------------------------------------------------
File Name: pH2.flash.js
Company: ph2enterprises
Author: Phil Henslee <ph2@ph2.us> ©2003
Purpose: Flash detection and Flash object insertion
Date Created: April 24, 2003
Last Modified: June 25, 2006
Dependent Files: pH2.config.js, pH2.detection.js
File Status: Optional
------------------------------------------------------------------------
*/

/* 
------------------------------------------------------------------------
** Create pH2.FlashManager Class
------------------------------------------------------------------------
*/ 

pH2.FlashManager = function(){
	this.init();
}

pH2.FlashManager.prototype.init = function() {
	this.detectedVersion = 0;
	this.detectFlash();
}


/* 
------------------------------------------------------------------------
Method detectFlash()
Purpose: detect presence of Flash plug-in
Arguments: None
------------------------------------------------------------------------
*/

pH2.FlashManager.prototype.detectFlash = function() {

	var maxFlashVersion = 7;
		
	if(pH2.Browser.isExplorer && pH2.Browser.isWindows){
		
		// create flash objects in vbscript
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
		document.write('isFlash3 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
		document.write('isFlash4 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
		document.write('isFlash5 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
		document.write('isFlash6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
		document.write('isFlash7 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n'); 
		document.write('isFlash7 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n'); 
		document.write('</SCR' + 'IPT\> \n');
		
		for (var i = 3; i <= maxFlashVersion; i++) {  
		if ( eval("isFlash" + i ) == true){this.detectedVersion = i};		
		}	
	 
		
	}   
	
	if (navigator.plugins){
		if (navigator.plugins["Shockwave Flash"]) {
			var flashDesc = navigator.plugins["Shockwave Flash"].description;
			this.detectedVersion = parseInt(flashDesc.charAt(flashDesc.indexOf(".") - 1));
		}
	
	}
	
	 
	if(pH2.debugState){
		if (this.detectedVersion > 0){
		alert("pH2 FlashManager\n\nFlash player detected!\nFlash player version: " + this.detectedVersion);
		}
	}


}

pH2.FlashManager.prototype.insertFlash = function(flashMovie,altImage,iwidth,iheight,isLoop,altPage,upgradePage,targetFlashVersion) {

	// Handle Redirection to alternate non flash page
		if(altPage != 'NO'){
			if(!isOtherBrw){
				window.location.replace(altPage);  
			}else{
				window.location = altPage;
			}
		}	  
        
        // Handle Upgrade page option
        if (this.detectedVersion < targetFlashVersion && upgradePage != 'NO'){
			if(!isOtherBrw){
				window.location.replace(upgradePage);  
			} else {
				window.location = upgradePage;
			}
		}	  
		
		// insert flash content if flash is detected or is ie
		if (this.detectedVersion > 0 | pH2.Browser.isExplorer ){
		
			// build html output string
			var strHTML = '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
			+ ' WIDTH="' + iwidth + '" HEIGHT="' + iheight +'" '
			+ 'CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#'
			+ 'version=' + targetFlashVersion +',0,0,0">'
			+ '<PARAM NAME="MOVIE" VALUE="' + flashMovie + '">'
			+ '<PARAM NAME="PLAY" VALUE="true">'
			+ '<PARAM NAME="LOOP"'
			if (isLoop == true){
				strHTML += ' VALUE="true"'
			}else{
				strHTML += ' VALUE="false"'
			}
			strHTML += '">'
			+ '<PARAM NAME="QUALITY" VALUE="high">'
			+ '<PARAM NAME="MENU" VALUE="false">'
			+ '<EMBED SRC="'  + flashMovie + '"'
			+ ' WIDTH="'+ iwidth + '" HEIGHT="' + iheight +'" '
			+ ' PLAY="true"'
			if (isLoop == true){
			strHTML += ' LOOP="true"'
			}else{
			strHTML += ' LOOP="false"'
			}
			strHTML += 'QUALITY="high"'
			+ 'MENU="false"'
			+ 'TYPE="application/x-shockwave-flash"'
			+ 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
			+ '</EMBED>'
			+ '</OBJECT>';
		
		} else {
			
			// Insert alternate image
			var strHTML = '<IMG SRC="' + altImage + '" HEIGHT="' + iheight + '" WIDTH="' + iwidth +'">'	+ '<BR>';
		}
		
		
		if(pH2.debugState == true){
			alert('pH2 FlashManager inserting flash content!\n\n' + strHTML);
		}
			
		// Insert Content
		document.write ( strHTML );
		
		return strHTML;
		

}   


// ** Create instance of the pH2 FlashManager object


pH2.Flash = new pH2.FlashManager();

	
	
