//** **
//  User Agent
//** **
function DBrowser() {
	this.n = navigator.userAgent.toLowerCase();
	this.db = (document.compatMode && document.compatMode.toLowerCase() != "backcompat")?
		document.documentElement
		: (document.body || null);
	this.op = (window.opera && document.getElementById);
	this.op6 = (this.op && !(this.db && this.db.innerHTML));
	if (this.op && !this.op6) document.onmousedown = new Function('e',
		'if (((e = e || window.event).target || e.srcElement).tagName == "IMAGE") return false;'
	);
	this.sfr = this.n.indexOf("safari") > -1;
	this.ie = this.n.indexOf("msie") != -1 && document.all && this.db && !this.op;
	this.iemac = this.ie && this.n.indexOf("mac")!=-1;
	this.ie4 = this.ie && !document.getElementById;
	this.n4 = (document.layers && typeof document.classes != "undefined");
	this.n6 = !this.op && !this.sfr && !this.ie && document.defaultView && typeof document.defaultView.getComputedStyle != "undefined";
	this.ns = ( document.layers );
	this.ce = document.captureEvents && document.releaseEvents;
	this.px = (this.n4 || this.op6)? '' : 'px';

	if ( this.n6 ) this.n4 = false;
}
var oBrowser = new DBrowser();
//** **

var doc_onload = [];
function AddOnLoad( txt ) { doc_onload[ doc_onload.length ] = txt; }
function SetOnLoad() {
  tmp = '';
  for( var i in doc_onload ) tmp += doc_onload[ i ] + ' ';
  window.onload = new Function( tmp );
}


var activ_win = '';
function Adm_PopUp( theURL ) { Adm_PopOpen( theURL, 'adm_popup', 'width=100,height=100,scrollbars=no' ); }
function Adm_PopOpen( theURL, theName, theFeat ) {
  activ_win = window.open( theURL, theName, theFeat );
  activ_win.focus();
}

function Adm_PopDown() { self.close(); }

function OpenGlossary( url_glos, popup ) {
  if ( popup ) Adm_PopOpen( url_glos, 'gwin', 'width=300,height=400,scrollbars=yes,resizable=no' );
  else self.document.location.href = url_glos;
}
function OpenSubscribe() {
  Adm_PopOpen( 'abonnement.php', 'gwin', 'width=284,height=400,scrollbars=no,resizable=no' );
}

var debug_popup;
DebugObj = function( obj ) {
  if ( debug_popup == null ) debug_popup = window.open( '', 'debug_popup', 'width=400,height=300,resizable=yes,scrollbars=yes' );
  debug_popup.window.document.title = '..: Debug Console :..';

  if ( DebugObj.arguments.length > 1 ) {
    hidemethods = DebugObj.arguments[ 1 ];
    if ( DebugObj.arguments.length == 3 ) decalage = DebugObj.arguments[ 2 ];
    else decalage = '';
  } else {
    decalage = '';
    hidemethods = false;
  }

  debug_popup.document.writeln( '<pre>' );
	debug_popup.document.writeln( decalage + '> Object Properties' );
	debug_popup.document.writeln( decalage + '-------------------' );
	var s = [];
	for ( var i in obj ) {
		var l = s.length;
		if ( typeof obj[ i ] == 'function' ) {
			if ( !hidemethods ) s[ l ] = decalage + i + ' = [method]';
			else continue;
		} else {
  		if ( typeof( obj[ i ] ) == 'object' ) s[ l ] = decalage + i + ' = ' + obj[ i ];
  		else s[ l ] = decalage + i +' (' + ( typeof( obj[ i ] ) ) + ')' + ' = ' + obj[ i ];
		}
	};
	s.sort();
	debug_popup.document.writeln( s.join( '\n' ) );
  debug_popup.document.writeln( '</pre>' );
}

FlashDetector.prototype.GetVersion = pGetVersion;
FlashDetector.prototype.FlashDetect = pFlashDetect;

function pGetVersion() { return this.fVersion; }
function pFlashDetect() {
  //Du fait, qu'Opéra permet de choisir la signature du navigateur
  //Si aucune version n'est détectée, vérifier qu'Opéra signe bien "Opera" (et non "MSIE")
  if ( this.ua_IE && this.ua_WIN ) {
    document.write( '<SCR' + 'IPT LANGUAGE="VBScript">\r\n' );
    document.write( 'on error resume next\r\n' );
    document.write( 'TmpVBVersion = -1\r\n' );
  	document.write( 'For i='+this.fVer_min+' TO '+this.fVer_max+'\r\n' );
  	document.write( 'If NOT IsObject( CreateObject( "ShockwaveFlash.ShockwaveFlash." & i ) ) Then\r\n' );
  	document.write( 'Else\r\n' );
    document.write( ' TmpVBVersion = i\r\n' );
  	document.write( 'End If\r\n' );
  	document.write( 'Next\r\n' );
    document.write( '</SCR' + 'IPT>\r\n' ); // break up end tag so it doesn't end our script

    this.fVersion = TmpVBVersion;
  }

  if (navigator.plugins) { // If navigator.plugins exists...
    if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { // ...then check for flash 2 or flash 3+.
      // Some version of Flash was found. Time to figure out which.
      // Set convenient references to flash 2 and the plugin description.
      isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? ' 2.0' : '';
      flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;

      // DEBUGGING: uncomment next line to see the actual description.
      //alert("Flash plugin description: " + flashDescription);

      // A flash plugin-description looks like this: Shockwave Flash 4.0 r5
      // We can get the major version by grabbing the character before the period
      // note that we don't bother with minor version detection. 
      // Do that in your movie with $version or getVersion().
      TmpFlashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));

      // 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.
      this.fVersion = TmpFlashVersion;
    }
  }
}

function FlashDetector() {
  this.fVersion = -1; //version du client
  this.fVer_min = 2; //numéro de la version mini
  this.fVer_max = 7; //numéro de la version maxi

  this.ua_IE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
  this.ua_WIN = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
  this.FlashDetect();
}
