
var _uOsr=new Array();
var _uOkw=new Array();
_uOsr[0]="google";	    _uOkw[0]="q";
_uOsr[1]="yahoo";	    _uOkw[1]="p";
_uOsr[2]="msn";		    _uOkw[2]="q";
_uOsr[3]="aol";		    _uOkw[3]="query";
_uOsr[4]="lycos";	    _uOkw[4]="query";
_uOsr[5]="ask";		    _uOkw[5]="q";
_uOsr[6]="altavista";	_uOkw[6]="q";
_uOsr[7]="search";	    _uOkw[7]="q";
_uOsr[8]="netscape";	_uOkw[8]="query";
_uOsr[9]="earthlink";	_uOkw[9]="q";
_uOsr[10]="cnn";	    _uOkw[10]="query";
_uOsr[11]="looksmart";	_uOkw[11]="key";
_uOsr[12]="about";	    _uOkw[12]="terms";
_uOsr[13]="excite";	    _uOkw[13]="qkw";
_uOsr[14]="mamma";	    _uOkw[14]="query";
_uOsr[15]="alltheweb";	_uOkw[15]="q";
_uOsr[16]="gigablast";	_uOkw[16]="q";
_uOsr[17]="voila";	    _uOkw[17]="kw";
_uOsr[18]="virgilio";	_uOkw[18]="qs";
_uOsr[19]="teoma";	    _uOkw[19]="q";




function EcrireCookie(nom, valeur)
{
    var argv=EcrireCookie.arguments;
    var argc=EcrireCookie.arguments.length;
    var expires=(argc > 2) ? argv[2] : null;
    var path=(argc > 3) ? argv[3] : null;
    var domain=(argc > 4) ? argv[4] : null;
    var secure=(argc > 5) ? argv[5] : false;
    document.cookie=nom+"="+valeur+
    ((expires==null) ? "" : ("; expires="+expires.toLocaleString()))+
    ((path==null) ? "; path=/" : ("; path="+path))+
    ((domain==null) ? "" : ("; domain="+domain))+
    ((secure==true) ? "; secure" : "");
}

function getCookieVal(offset)
{
    var endstr=document.cookie.indexOf (";", offset);
    if (endstr==-1) endstr=document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function LireCookie(nom)
{
    var arg=nom+"=";
    var alen=arg.length;
    var clen=document.cookie.length;
    var i=0;
    while (i<clen)
    {
        var j=i+alen;
        if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
        i=document.cookie.indexOf(" ",i)+1;
        if (i==0) break;
    }
    return "-1";
}


function DateCookie(nom,date)
{
    EcrireCookie(nom,LireCookie(nom),date);
}


function motcle(chaine) {
    referrer = chaine;
    if (!referrer || referrer=="") return "";
    var i=0,h,k;
    if ((i=referrer.indexOf("://")) < 0) return "";
    h=referrer.substring(i+3,referrer.length);
    if (h.indexOf("/") > -1) {
        h=h.substring(0,h.indexOf("/"));
    }
    for (var ii=0;ii<_uOsr.length;ii++) {
        if (h.indexOf(_uOsr[ii]) > -1) {
            if ((i=referrer.indexOf("?"+_uOkw[ii]+"=")) > -1 || (i=referrer.indexOf("&"+_uOkw[ii]+"=")) > -1) {
                k=referrer.substring(i+_uOkw[ii].length+2,referrer.length);
                if ((i=k.indexOf("&")) > -1) k=k.substring(0,i);
                return _uOsr[ii]+"|"+k;
            }
        }
    }
    return "";
}








function addStatRecherche(idTextBox, idListe){
    var recherche = document.getElementById(idTextBox).value;
    if (idListe != ""){
        rubrique = document.getElementByName(idListe).options[document.getElementByName(idListe).selectedIndex].text;
    }
    else {
        rubrique = "";
    }
    var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
     try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
      }
     }
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	    try {
		    xmlhttp = new XMLHttpRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    if (!xmlhttp && window.createRequest) {
	    try {
		    xmlhttp = window.createRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }

      
    xmlhttp.open("POST", "/stat/stat.asp",true);
    
    xmlhttp.setRequestHeader("Man", "POST /stat/stat.asp HTTP/1.1");
    xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xmlhttp.send("typeDeStat=StatRecherche&rech="+recherche.split(' ').join('|')+"&siteId="+_statId+"&rub="+rubrique);
}



function addGenericStat(){
   motcleReferrer = motcle(document.referrer);

    urlTmp = document.title;
    _url=document.title.split(' ').join('|');
    
    _referrer = "";
    _motscles = "";
    if (motcleReferrer!=""){
        _referrer = motcleReferrer.split("|")[0];
        _motscles = motcleReferrer.split("|")[1];
    }
    else {
        _referrer = document.referrer;
    }
    _visiteurId = LireCookie("visiteurId");
    _sessionId = LireCookie("sessionId");
    if (_sessionId != "-1"){
        _referrer = "";
        _motscles = "";
    }

    _resolution = screen.width+"*"+screen.height;
    _couleurs = screen.colorDepth;
  Version_Browser = navigator.appVersion.toString(); 
    
   if(Version_Browser.split("MSIE").length != 1)
   {
    Version_Browser=Version_Browser.split("MSIE")[1].split(";")[0];
   }
   else if(Version_Browser.split("Safari").length != 1)
   {
    Version_Browser="Safari";
   }
   else
   {
    Version_Browser=Version_Browser.split("(")[0];
   }
   leNavigateur=navigator.appName;
   if(leNavigateur=="Netscape")
   {
       if(navigator.userAgent.split("Firefox").length!=1)
       {
           leNavigateur="Firefox";
           Version_Browser=navigator.userAgent.split("Firefox/")[1];
       }
       else if(navigator.userAgent.split("Mozilla").length!=1)
       {
            leNavigateur="Mozilla";
            Version_Browser=navigator.userAgent.split("Mozilla/")[1].split(" (")[0];
       }
   }
   
    _origine = leNavigateur+"|"+Version_Browser+"|"+navigator.platform+"|"+navigator.userLanguage;
    _gpCode = _statGpCode;


    var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
     try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
      }
     }
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	    try {
		    xmlhttp = new XMLHttpRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    if (!xmlhttp && window.createRequest) {
	    try {
		    xmlhttp = window.createRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
      
           
xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) {

	reponse = xmlhttp.responseText.split('<addStatGeneriqueResult>')[1].split('</addStatGeneriqueResult>')[0];
            _sessionId=reponse.split("|")[0];
            _visiteurId=reponse.split("|")[1];
            if (_sessionId!="" && _visiteurId!=""){
                d = new Date();
                d.setFullYear(d.getFullYear()+50);
                EcrireCookie("visiteurId",_visiteurId);
                DateCookie("visiteurId",d);
                EcrireCookie("sessionId",_sessionId);
            }
            else {
                EcrireCookie("sessionId",_sessionId);
            }
        }
    }


    xmlhttp.open("POST", "/stat/stat.asp",true);
    
    xmlhttp.setRequestHeader("Man", "POST /stat/stat.asp HTTP/1.1");
    xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    
    xmlhttp.send("typeDeStat=Gene&siteId="+_statId+"&url="+_url+"&ref="+_referrer+"&mots="+_motscles+"&visit="+_visiteurId+"&sessionId="+_sessionId+"&origine="+_origine+"&resol="+_resolution+"&couleurs="+_couleurs+"&gpcode="+_gpCode+"&langue="+_lang);
}


function addStatOffre(offreId, offreLibelle, statType, lang, urlFichier){

    _sessionId=LireCookie("sessionId")     
     
    if (_sessionId=="-1"){
        var wait="addStatOffre('"+offreId+"','"+offreLibelle+"','"+statType+"','"+lang+"','"+urlFichier+"')";
        setTimeout(wait,100);
    }
    else {
    var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
     try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
      }
     }
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	    try {
		    xmlhttp = new XMLHttpRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    if (!xmlhttp && window.createRequest) {
	    try {
		    xmlhttp = window.createRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }

     offreLibelle=offreLibelle.split(' ').join('|');
     urlFichier=urlFichier.split(' ').join('|');
    xmlhttp.open("POST", "/stat/stat.asp",true);
    
    xmlhttp.setRequestHeader("Man", "POST /stat/stat.asp HTTP/1.1");
    xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    
    xmlhttp.send("typeDeStat=offre&siteId="+_statId+"&offreId="+offreId+"&offreLib="+offreLibelle+"&statType="+statType+"&urlFichier="+urlFichier+"&sessionId="+_sessionId+"&langue="+lang);
}

}



function addStatOffreSyndic(offreId,offreObjTour,syndicId,statType,urlFichier,lang){
    _sessionId=LireCookie("sessionId")     
     
    if (_sessionId=="-1"){
        var wait="addStatOffreSyndic('"+offreId+"','"+offreObjTour+"','"+syndicId+"','"+statType+"','"+urlFichier+"','"+lang+"')";
        setTimeout(wait,100);
    }
    else {
    var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
     try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
      }
     }
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	    try {
		    xmlhttp = new XMLHttpRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    if (!xmlhttp && window.createRequest) {
	    try {
		    xmlhttp = window.createRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
     



    xmlhttp.open("POST", "/stat/stat.asp",true);
    
    xmlhttp.setRequestHeader("Man", "POST /stat/stat.asp HTTP/1.1");
    xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    
    xmlhttp.send("typeDeStat=offreSyndic&siteId="+_statId+"&offreId="+offreId+"&offreObjTour="+offreObjTour+"&syndicId="+syndicId+"&statType="+statType+"&urlFichier="+urlFichier+"&sessionId="+_sessionId+"&langue="+lang);
}
}


var _fauxId="-1";
function addStatRechSyndic(idSyndic,champ,valeur)
{
    var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
     try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
      }
     }
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	    try {
		    xmlhttp = new XMLHttpRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    if (!xmlhttp && window.createRequest) {
	    try {
		    xmlhttp = window.createRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    if(_fauxId=="-1")
    {
       xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) {

	        _fauxId = xmlhttp.responseText.split('<addStatRechSyndicResult>')[1].split('</addStatRechSyndicResult>')[0];
            
        }
      }
        xmlhttp.open("POST", "/stat/statRechSyndic.asp");
        xmlhttp.setRequestHeader("Man", "POST /stat/statRechSyndic.asp HTTP/1.1");
        xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        xmlhttp.send("typeDeStat=getId&idSyndic="+idSyndic+"&urlRef="+_statId);
    }
    finRech(idSyndic,champ,valeur);
}

function finRech(idSyndic,champ,valeur)
{
    if(_fauxId=="-1")
    {
        var wait="finRech('"+idSyndic+"','"+champ+"',\""+valeur+"\")";
        setTimeout(wait,50);
    }
    else
    {
    var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
     try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
      }
     }
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	    try {
		    xmlhttp = new XMLHttpRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    if (!xmlhttp && window.createRequest) {
	    try {
		    xmlhttp = window.createRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
        xmlhttp.open("POST", "/stat/statRechSyndic.asp");
        xmlhttp.setRequestHeader("Man", "POST /stat/statRechSyndic.asp HTTP/1.1");
        xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        xmlhttp.send("typeDeStat=setRech&fauxIdSyndic="+_fauxId+"&champ="+champ+"&valeur="+valeur);
        setTimeout("_nbStatEnCours++",1000);
    }
}
