//	flash detection a la fin de ce fichier

//constructeur de l<objet
function Detect()
{
	//Array qui contiendra les auttres array tout les info pout les fonction sur un plugin
	//pour faire un array multidimensionel...
	this.pluginArray = new Array(16);
	
	//array pour svgArray pos 1 ie object,pos 2 mime type, pos 3 nom dont on le call,si il y a une 4 pos
	//pour caller la version
	this.SVGArray = new Array ("Adobe.SVGCtl","image/svg-xml","SVG Viewer","1");
	this.DirectorArray = new Array ("SWCtl.SWCtl.1","version 8.5","Director","8.5");
	this.RealPlayerG2Array = new Array ("rmocx.RealPlayer G2 Control.1","RealPlayer(tm) G2","RealPlayer","G2");
	
	this.QuickTime4Array = new Array ("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime Plug-in 4","QuickTime","4");
	this.QuickTime5Array = new Array ("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime Plug-in 5","QuickTime","5");
	this.QuickTime6Array = new Array ("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime Plug-in 6","QuickTime","6");
	this.QuickTime7Array = new Array ("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime Plug-in 7","QuickTime","7");
	
	this.WindowsMediaPlayerArray = new Array ("MediaPlayer.MediaPlayer.1","Windows Media Player","Windows Media Player","1");
	//this.WindowsMediaPlayerArray = new Array ("PDF.PdfCtrl.5","Adobe Acrobat","Acrobat Reader","1");
	this.Flash1Array = new Array ("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash 1.0","Flash","1");
	this.Flash2Array = new Array ("ShockwaveFlash.ShockwaveFlash.2","Shockwave Flash 2.0","Flash","2");
	this.Flash3Array = new Array ("ShockwaveFlash.ShockwaveFlash.3","Shockwave Flash 3.0","Flash","3");
	this.Flash4Array = new Array ("ShockwaveFlash.ShockwaveFlash.4","Shockwave Flash 4.0","Flash","4");
	this.Flash5Array = new Array ("ShockwaveFlash.ShockwaveFlash.5","Shockwave Flash 5.0","Flash","5");
	this.Flash6Array = new Array ("ShockwaveFlash.ShockwaveFlash.6","Shockwave Flash 6.0","Flash","6");
	this.Flash7Array = new Array ("ShockwaveFlash.ShockwaveFlash.7","Shockwave Flash 7.0","Flash","7");
	this.Flash8Array = new Array ("ShockwaveFlash.ShockwaveFlash.8","Shockwave Flash 8.0","Flash","8");
	
	this.pluginArray[0] = this.SVGArray;
	this.pluginArray[1] = this.DirectorArray;
	this.pluginArray[2] = this.RealPlayerG2Array;
	this.pluginArray[3] = this.QuickTime4Array;
	this.pluginArray[4] = this.QuickTime5Array;
	this.pluginArray[5] = this.WindowsMediaPlayerArray;
	this.pluginArray[6] = this.Flash1Array;
	this.pluginArray[7] = this.Flash2Array;
	this.pluginArray[8] = this.Flash3Array;
	this.pluginArray[9] = this.Flash4Array;
	this.pluginArray[10] = this.Flash5Array;
	this.pluginArray[11] = this.Flash6Array;
	this.pluginArray[12] = this.Flash7Array;
	this.pluginArray[13] = this.Flash8Array;
	this.pluginArray[14] = this.QuickTime6Array;
	this.pluginArray[15] = this.QuickTime7Array;
	//variable qui servent lors de la detection des browser o/s etc....
	this.agt = navigator.userAgent.toLowerCase();
	this.ie  = (this.agt.indexOf("msie") != -1);
	this.ns  = (navigator.appName.indexOf("Netscape") != -1);
	this.win = ((this.agt.indexOf("win")!=-1) || (this.agt.indexOf("32bit")!=-1));
	this.mac = (this.agt.indexOf("mac")!=-1);
}

//fonction de detection de plug-in sur Ie
Detect.prototype.detectPluginIE = function(ClassID) { 
	result = false; 
	document.writeln('<S' + 'CRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))\n</S' + 'CRIPT>\n');
	if (result)
		return true;
	else
		return false; 
}

//fonction de detection de plug-in sur Netscape
Detect.prototype.detectPluginNS = function(ClassID){
result = false;
	for (looper=0; looper<navigator.plugins.length; looper++) 
	{
		if (navigator.plugins[looper].name.indexOf(ClassID) >= 0) 
		result = true;
		if (navigator.plugins[looper].description.indexOf(ClassID) >= 0)
		result = true;
	}
	return result;
}

//utiliser cette Fonction lors d<une recherche pour un plugin....
Detect.prototype.detectPlugin = function(strPluginName,strVersion){	
	if (strVersion){
		for (var i=0;i < this.pluginArray.length;i++){
		
			if (!isNaN(this.pluginArray[i][3]) && !isNaN(strVersion))
				strVersionCondition = (parseInt(this.pluginArray[i][3]) >= parseInt(strVersion));
			else
				strVersionCondition = (this.pluginArray[i][3] == strVersion);
			if ((this.pluginArray[i][2].toString().toLowerCase() == strPluginName.toLowerCase())&& strVersionCondition){
				if (this.ie && this.win){					
					resultSearch = Detect.prototype.detectPluginIE(this.pluginArray[i][0]);
					return resultSearch;
					break;
				}
				else if (this.ns || this.mac) {								
					resultSearch = Detect.prototype.detectPluginNS(this.pluginArray[i][1]);
					return resultSearch;					
					break;
				}
			}			
		}
	}	
	else{		
		for (var i=0;i < this.pluginArray.length;i++){			
			if (this.pluginArray[i][2].toString().toLowerCase() == strPluginName.toLowerCase()){					
				if (this.ie && this.win){
					resultSearch = Detect.prototype.detectPluginIE(this.pluginArray[i][0]);
					return resultSearch;					
					break;
				}
				else if (this.ns || this.mac) {								
					resultSearch = Detect.prototype.detectPluginNS(this.pluginArray[i][1]);
					return resultSearch;					
					break;
				}
			}			
		}
	}	
}

//fonction qui permet la verification par browser,version,platform
Detect.prototype.isBrowserAcceptable = function(strBrowser,strVersion,strPlatform){

browserName = navigator.appName.toLowerCase();
browserVersion = navigator.appVersion.toLowerCase();
browserPlatform = navigator.platform.toLowerCase();

//alert("Browser : "+browserName+" Version : "+browserVersion+" Platform : "+browserPlatform);
//alert(navigator.userAgent);
	if ((browserName.indexOf(strBrowser.toLowerCase())!=-1)&&(browserPlatform.indexOf(strPlatform.toLowerCase())!=-1)){
		if (browserName.indexOf("explorer")!=-1){
			posFirstAt = browserVersion.indexOf("msie") + 4;
			posLastAt = (browserVersion.length - (browserVersion.indexOf(";") + 2));
			lengthExtract = posLastAt - posFirstAt;
			versionNumber = browserVersion.substr(posFirstAt,lengthExtract);			
				if (versionNumber >= strVersion){
					return true;
				}
				else{
					return false;
				}
		}
		else if (browserName.indexOf("netscape")!=-1){		
			posFirstAt = 0;
			posLastAt = 4;	
			versionNumber = browserVersion.substr(posFirstAt,posLastAt);			
				if (versionNumber >= strVersion){
					return true;
				}
				else{
					return false;
				}
		}
	}
	else{
		return false;
	}
}	

//fonction qui affiche tout les plug-in de netscape et de internet explorer version mac
Detect.prototype.showAll = function(){
	document.writeln("<TABLE BORDER=1><TR VALIGN=TOP>",   "<TH ALIGN=left>i",   "<TH ALIGN=left>name",   "<TH ALIGN=left>filename",   "<TH ALIGN=left>description",   "<TH ALIGN=left># of types</TR>")
	
	for (i=0; i < navigator.plugins.length; i++) {
		document.writeln("<TR VALIGN=TOP><TD>",i,      "<TD>",navigator.plugins[i].name,      "<TD>",navigator.plugins[i].filename,      "<TD>",navigator.plugins[i].description,      "<TD>",navigator.plugins[i].length,      "</TR>")
		document.writeln("</TABLE>")
	}
}

Detect.prototype.checkBrowserOs = function(strBrowser,strPlatform){
	browserName = navigator.appName.toLowerCase();
	browserPlatform = navigator.platform.toLowerCase();
		if((browserName.indexOf(strBrowser.toLowerCase())!=-1)&&(browserPlatform.indexOf(strPlatform.toLowerCase())!=-1)){
			return true;
		}
		else{
			return false;
		}
}

//	flash detection
var d = new Detect();
flash_installed = d.detectPlugin("Flash","5") || d.detectPlugin("Flash","6") || d.detectPlugin("Flash","7") || d.detectPlugin("Flash","8");
quicktime_installed = d.detectPlugin("QuickTime","5") || d.detectPlugin("QuickTime","6") || d.detectPlugin("QuickTime","7");
windowsmedia_installed = d.detectPlugin("Windows Media Player","1");
realmedia_installed = d.detectPlugin("RealPlayer","G2");
