
// plugin detect module for macromedia flash 
// bigjolt@bigjolt.com
// http://www.bigjolt.com

// flashcheck.js

function flashDetect () {

	isNetscape     = ( navigator.appName   && navigator.appName.indexOf("Netscape") >= 0 );
	isIE           = ( navigator.userAgent && navigator.userAgent.indexOf("MSIE") >= 0 );
	isIE5          = ( navigator.userAgent && navigator.userAgent.indexOf("MSIE 5") >= 0 );
	isMac          = ( navigator.platform  && navigator.platform.indexOf("Mac") >= 0 );
	isWindows      = ( navigator.userAgent && navigator.userAgent.indexOf("Windows") >= 0 );
	bVersion = parseInt(navigator.appVersion );
	Flash   = 0;
	Flash2 = 0;
	Flash3 = 0;
	Flash4 = 0;
	Flash5 = 0;
	Flash6 = 0;
	FlashVersionRequired = 6;
	FlashVersionInstalled = 0;
	FlashUnknown = 0;
	//
	// check ns navigator
	if (navigator.plugins) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "" ;
			flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description ;
			flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1)) ;
			//
			if (flashVersion == 2) Flash2 = 1 ;
			if (flashVersion == 3) Flash3 = 1 ;
			if (flashVersion == 4) Flash4 = 1 ;
			if (flashVersion == 5) Flash5 = 1 ;
			if (flashVersion >= 6) Flash6 = 1 ;
		}
	} else {
		// check for unreliable browser + platform combinations
		if ( isIE ) {
			if ( isMac || bVersion < 4 ) { 
				FlashUnknown = 1;}
			} else if ( !isNetscape ) {
				FlashUnknown = 1;
		}
	}
	//
	// check ie or vb script browsers - opera??
	if ( isIE && isWindows ) {
		document.writeln('<scr'+'ipt language="VBScript">');
		document.writeln('on error resume next');
		document.writeln('Flash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash"))) \n');
		document.writeln('Flash3 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
		document.writeln('Flash4 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
		document.writeln('Flash5 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
		document.writeln('Flash6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
		document.writeln('</scr'+'ipt>');
	}
	// 
	// check for the highest Flash version.
	for (var f = 2; f <= FlashVersionRequired; f++) {  
		if (eval("Flash" + f ) == true) FlashVersionInstalled = f;
	}
	//
}

function flashRedirect (page) {
	//
	// done
	// for unreliable detection check Flash with Flash
	if ( FlashUnknown) { 
		location.replace("html/swfcheck.htm"); 
		return false ;
	}
	//
	// for Mac IE4.5 or below warn uses of possible errors if viewed
	if ( isMac && isIE && !isIE5 ) { 
		location.replace("html/mac.htm"); 
		return false ;
	}
	//
	// the final check
	if (FlashVersionInstalled >= FlashVersionRequired) {
		// location.replace(page) or document.write(flashTags);
		page ;
		return true ;
	} else if ((FlashVersionInstalled < FlashVersionRequired) && (FlashVersionInstalled != 0)) {
		location.replace("html/upgrade.htm");
		return false ;
	} else { 
		location.replace("html/getflash.htm");
		return false ;
	}
	//
	// nothing left to do but send the user to the getflash page 
	// by enforcing the refresh option on the main php or html page
}


