/*-----------------------------------------------------------------------*/
/*--C_BrowserInfo--------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
/*--NW 15/05/2007--------------------------------------------------------*/
/*-----------------------------------------------------------------------*/

/*--------------------*/
/*classe C_BrowserInfo*/
/*--------------------*/

function C_BrowserInfo()
{
  this.useragent=null;
  this.version=null;
  this.version_maj=null;
  this.version_min=null;
  this.isIE=false;//IE
  this.isOP=false;//Opera
  this.isNS=false;//Netscape
  this.isMZ=false;//Mozilla
  this.isFF=false;//FireFox
  this.isMT=false;//Maxthon
  this.isWIN=false;
  this.isMAC=false;
  this.language='';
  this.language_code='';
  this.cookieEnabled=false;
  this.plugin_acrobat=false;
  this.plugin_flash=false;
  this.plugin_flash_majversion=-1;
}

C_BrowserInfo.prototype.initialize = function()
{
  this.detect_browser_type();
  this.get_browser_language();
  this.check_browser_cookies();
  this.check_browser_plugins();
}

C_BrowserInfo.prototype.detect_browser_type = function()
{
  var ua=navigator.userAgent.toLowerCase();
  this.useragent=ua;
  this.isWIN=(ua.indexOf("win")!=-1)||(ua.indexOf("16bit")!=-1);
  this.isMAC=(ua.indexOf("mac")!=-1);
  //moteur MSIE:
  this.isOP=(ua.indexOf("opera")!=-1);
  this.isMT=(ua.indexOf("maxthon")!=-1);
  this.isIE=(!this.isOP)&&(!this.isMT)&&(ua.indexOf("msie")!=-1);
  //moteur Gecko:
  this.isNS=(ua.indexOf("netscape")!=-1);
  this.isFF=(ua.indexOf("firefox")!=-1);
  this.isMZ=(!this.isNS)&&(!this.isFF)&&(ua.indexOf("gecko")!=-1);
  var v=null;
  if(this.isOP)v=ua.substring(ua.indexOf('opera')+6,ua.indexOf(' ',ua.indexOf('opera')+6));else
  if(this.isMT)v='';else
  if(this.isIE)v=ua.substring(ua.indexOf('msie')+5,ua.indexOf(';',ua.indexOf('msie')+5));else
  if(this.isNS)v=ua.substring(ua.indexOf('netscape')+9,ua.indexOf(' ',ua.indexOf('netscape')+9));else
  if(this.isFF)v=ua.substring(ua.indexOf('firefox')+8,ua.length);else
  if(this.isMZ)v=ua.substring(ua.indexOf('rv:')+3,ua.indexOf(')',ua.indexOf('rv:')+3));
  else v=navigator.appVersion.substring(0,ua.indexOf('('));
  this.version=v;
  if(v!=null)
  {
    var tmp=v.split('.');
    this.version_maj=parseInt(tmp[0]);
    this.version_min=parseInt(tmp[1]);
  }
}

C_BrowserInfo.prototype.get_browser_language = function()
{
  /*détermine la langue définie pour le navigateur*/
  this.language=navigator.language;
  if(this.language){this.language_code=this.language.substring(0,2);}
  else{this.language='';}
}

C_BrowserInfo.prototype.check_browser_cookies = function()
{
  /*récupère des infos sur la configuration des cookies*/
  this.cookieEnabled=navigator.cookieEnabled;
}

C_BrowserInfo.prototype.check_browser_plugins = function()
{
  /*récupère des infos sur les plugins installéss*/
  /*! FF only !*/
  var dsc,p1,p2,i,lst;
  lst=navigator.plugins;
  for(i=0;i<lst.length;i++)
  {
    dsc=lst[i].description;
    if(!this.plugin_flash)
    {
      p1=dsc.indexOf('Flash');
      if(p1!=-1)
      {
        this.plugin_flash=true;
        p1+=6;
        p2=dsc.indexOf('.',p1);
        this.plugin_flash_majversion=parseInt(dsc.substring(p1,p2));
      }
    }
    if(!this.plugin_acrobat)if(dsc.indexOf('Acrobat')!=-1){this.plugin_acrobat = true;}
  }
}

C_BrowserInfo.prototype.showresults = function()
{
  var t='';
  t+='User Agent : '+this.useragent;
  t+='\nnavigator.appVersion : '+navigator.appVersion;
  t+='\n\nOS : ';
  t+=this.isWIN?'windows':'mac';
  t+='\nBrowser : ';
  t+=this.isIE?'Internet Explorer':(this.isOP?'Opera':(this.isNS?'Netscape':(this.isFF?'FireFox':(this.isMZ?'Mozilla':(this.isMT?'Maxthon':'inconnu')))));
  t+='\nVersion trouvée : '+this.version;
  t+='\nVersion-maj : '+this.version_maj;
  t+='\nVersion-min : '+this.version_min;
  alert(t);
}

/*------------------------*/
/*initialisation immediate*/
/*------------------------*/

var oBrowserInfo=new C_BrowserInfo();
oBrowserInfo.initialize();

/*--------------------------------*/
/*fonctions utilisées dans l'appli*/
/*--------------------------------*/

function is_browser_ok_for_app()
{
  /*vérifie si le navigateur est compatible avec cette appli*/
  var r=false;
  if(oBrowserInfo)
  {
    r=r||((oBrowserInfo.isIE)&&(oBrowserInfo.version_maj>=7));
    r=r||((oBrowserInfo.isFF)&&(oBrowserInfo.version_maj>=2));
  }
  return r;
}

function alert_browser_not_ok_for_app()
{
  /*alerte l'utilisateur que son navigateur n'est pas compatible*/
  var t='';
  switch(oBrowserInfo.language_code)
  {
    case "fr":t='Votre navigateur ne présente pas un niveau de compatibilité suffisant pour cette application.\n\nNavigateurs supportés :';break;
    default:t='Your browser does not offer the expected level of compatibility for this application.\n\nSupported browsers :';
  }
  t+='\n\n          - Microsoft Internet Explorer 7.0';
  t+='\n          - Mozilla Firefox 2.0';
  alert(t);
}

/*-----------------------------------------------------------------------*/