/*
## ########################################################################	##
##					FlashChecker JS Class									##
##  © 1998-2006 Copyright Scheepens reclame adviseurs Tilburg Netherlands	##
##																			##
## 		     i:http://www.scheepens.nl  e:info@scheepens.nl 			  	##
##  Scheepens Reclame Adviseurs; p.o.box 954; 5000AZ Tilburg; Netherlands	##
## ########################################################################	##
## 2006.08.30												By Huub Segers	##
## ########################################################################	##
## __TODO__																	##
## ######################################################################## ##
## __CHANGES__																##
##	2006.09.11 door huub
##	* Toevoeging van de mogelijkheid tot het ontvangen / teruggeven van een boolean.
## ######################################################################## ##
## __HOWTO__																##

Initialisatie:
	var fc = new FlashChecker;
	
[optioneel] Instellen van de Minimale FlashVersie:
	standaard versienummer is 7
	
	fc.setRequiredVersion( long versienummer );


Controleren:
	Alert weergeven als de pagina geladen is:
		fc.checkForFlash();
	
	Custom:
		fc.checkForFlash("booleanReturn");
	
	Redirect naar een specifieke pagina:
		fc.checkForFlash( "redirectToPage", string url );
		
	Een Domelement weergeven (moet wel in de pagina aanwezig zijn):
		fc.checkForFlash( "showDomMessage", string domId, string styleproperty, string stylevalue );
	
##																			##
## ######################################################################## ##
## __VOORBEELD__															##	

	function checkflash(){
		var fc = new FlashChecker;
		fc.setRequiredVersion( 8.022 );
		fc.checkForFlash( "redirectToPage", "http://www.scheepens.nl" );
	}
	Event.add( window, "load", checkflash, false ); // EventObject moet ingeladen zijn
	
	of
	
	window.onload = function(){
		var fc = new FlashChecker;
		fc.checkForFlash( "showDomMessage", "flashwarning", "display", "block" );
	}
## 																			##
## ######################################################################## ##
*/

function FlashChecker(){
	this.requiredVersion = 7;
	this.foundVersion = 0;
	this.whattodo = "ShowAlertMessage";
	this.url;
	this.domid;
	this.styleproperty;
	this.stylevalue;
	
	this.version = {
		major : 1,
		minor : 1,
		build : 609
		};
	
	this.versionstring = this.version.major + "." + this.version.minor + " build " + this.version.build;
	
	this.setRequiredVersion = function( flashversion ){
		this.requiredVersion = flashversion;
	}
	
	this.checkForFlash = function(){
		var args = this.checkForFlash.arguments;
		var f = "-";
		var n = navigator;
		
		if( args.length > 2 && args[0] == "showDomMessage" ){
			this.whattodo = "ShowDomMessage";
			this.stylevalue = args[3];
			this.styleproperty = args[2];
			this.domid = args[1];
		}
		
		if( args.length == 2 && args[0] == "redirectToPage" ){
			this.whattodo = "redirectToPage";
			this.url = args[1];
		}
		
		if( args.length == 1 && args[0] == "returnBoolean" ){
			this.whattodo = "returnBoolean";
		}
		
		if( args.length < 1 ){
			this.whattodo = "ShowAlertMessage";
		}
		

		if (n.plugins && n.plugins.length) {
			for (var ii=0;ii<n.plugins.length;ii++) {
				if (n.plugins[ii].name.indexOf('Shockwave Flash')!=-1) {
					f=n.plugins[ii].description.split('Shockwave Flash ')[1];
					//return f;
				}
			}
		} 
		else if (window.ActiveXObject) {
			for (var ii=11;ii>=2;ii--) {
				try {
					var fl=eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash."+ii+"');");
					if (fl) { 
						f=ii + '.0'; 
						break;
						//return f; 
					}
				}
				catch(e) {}
			}
		}
		
		var re = /[^0-9\.]/gi;
		
		if( typeof( f ) == "undefined" ){
			this.__showFlashWarning();
			return;
		}
		
		f = f.replace( re, "" );
		f = new Number( f );
		this.foundVersion = f;
		if( f == NaN || f == "" || f == "undefined" || f == 0 || f < this.requiredVersion ){
			this.__showFlashWarning();
			return false;
		}
		return true;
	}
	
	this.__showFlashWarning = function(){
		switch( this.whattodo ){
			case "returnBoolean":
				break;
			case "ShowAlertMessage":
				alert( "U beschikt niet of niet over de juiste versie van Adobe / Macromedia Flash. Om de site op een juiste manier weer te geven is het sterk aan te raden om deze plugin te installeren.\r\n Ga naar de site van Adobe om de plugin te downloaden en te installeren\r\n\r\n     http://www.adobe.com/shockwave/download" )
				break;
			case "ShowDomMessage":
				var evalstring = "var oDomElement = document.getElementById( this.domid );";
				evalstring += "if( oDomElement ){";
				evalstring += "oDomElement.style." + this.styleproperty + "=\"" + this.stylevalue + "\";";
				evalstring += "}";
				//alert( evalstring );
				eval( evalstring );
				break;
			case "redirectToPage":
				location.href = this.url;
				break;
		}
		return;
	}
}
