/* reconnaitre les moteurs de recherche du marche français avec Google Analytics
  Auteur : Olivier Vit, http://www.feuilledunet.info/
  version 1.4, avril 2007
  changements:
  1.1
  - ajout de (JaiDeLaChance) pour les visiteurs du moteur Google utilisant le bouton "J'ai de la Chance" dont le keyword est absent du referer
  1.2
  - d'autres moteurs francophones
  - plus de moteurs reconnus malgre l'absence de parametres (passe en POST)
  1.3
  - MS IE 6 n'aime pas les accents dans les commentaires !
  1.4
  - detection des webmails pour les grouper comme affluent specifique

Nota: http://www.phpmyvisites.us/documentation/Search_engines_file_listing contient une liste tres detaillee de moteurs de recherche avec leurs parametres

  Utilisation: inserer l'appel de ce fichier entre l'appel de urchin.js et l'utilisation de la fonction urchinTracker()

  Par exemple :
  <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
  <script src="http://www.boutique-oiseaux.com/js/urchin-fr.js" type="text/javascript"></script>
  <script type="text/javascript"><!--
		_uacct = "UA-xxxxxxxxxxx";  // mettre votre identifiant ici
        urchinTracker() ;
		//-->
		</script>
*/

var w = _uOsr.length;
_uOsr[w] = "mirago"; _uOkw[w] = "qry"; w+=1 ;
_uOsr[w] = "myway.com"; _uOkw[w] = "searchfor"; w+=1 ;
_uOsr[w] = "mysearch.com"; _uOkw[w] = "searchfor"; w+=1 ;
_uOsr[w] = "netscape.fr"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "search.tele2internet.fr"; _uOkw[w] = "query"; w+=1 ;
_uOsr[w] = "search.mywebsearch.com"; _uOkw[w] = "searchfor"; w+=1 ;
_uOsr[w] = "need2find.com"; _uOkw[w] = "searchfor"; w+=1 ;
_uOsr[w] = "netscape.fr"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "search.dmoz.org"; _uOkw[w] = "search"; w+=1 ;
_uOsr[w] = "find.copernic.com"; _uOkw[w] = "query"; w+=1 ;
_uOsr[w] = "eu.ixquick.com"; _uOkw[w] = "query"; w+=1 ;
_uOsr[w] = "myway.com"; _uOkw[w] = "searchfor"; w+=1 ;
_uOsr[w] = "excite.fr"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "toile.com"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "hotbot"; _uOkw[w] = "query"; w+=1 ;
_uOsr[w] = "vivisimo"; _uOkw[w] = "query"; w+=1 ;
_uOsr[w] = "scroogle.org"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "kartoo"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "ujiko"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "search.ke.voila"; _uOkw[w] = "rdata"; w+=1 ;
_uOsr[w] = "search.ke.voila"; _uOkw[w] = "kw"; w+=1 ;
_uOsr[w] = "mozbot"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "recherche.aol"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "recherche.aol"; _uOkw[w] = "query"; w+=1 ;
_uOsr[w] = "exalead"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "accoona"; _uOkw[w] = "qt"; w+=1 ;
_uOsr[w] = "dir.com"; _uOkw[w] = "req"; w+=1 ;
_uOsr[w] = "clusty.com"; _uOkw[w] = "query"; w+=1 ;
_uOsr[w] = "recherche.neuf.fr"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "r.neuf.fr"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "search1-2.free.fr"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "search2-2.free.fr"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "search.free.fr"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "rechercher.aliceadsl"; _uOkw[w] = "qs"; w+=1 ;
_uOsr[w] = "recherche.club-internet"; _uOkw[w]="q"; w+=1 ;
_uOsr[w] = "search.msn"; _uOkw[w]="q"; w+=1 ;
_uOsr[w] = "search.live.com"; _uOkw[w]="q"; w+=1 ;
_uOsr[w] = "search.yahoo.com"; _uOkw[w]="p"; w+=1 ;
_uOsr[w] = "books.google."; _uOkw[w]="dq"; w+=1 ;
_uOsr[w] = "images.google."; _uOkw[w]="q"; w+=1 ;
_uOsr[w] = "directory.google."; _uOkw[w]="q"; w+=1 ;
_uOsr[w] = "groups.google."; _uOkw[w]="q"; w+=1 ;
_uOsr[w] = "www.google."; _uOkw[w]="q";



function _uOrg(t) {
    if (_ur == "0" || _ur == "" || _ur == "-") {return "";}
    var i = 0,h,k;
    if ((i = _ur.indexOf("://")) < 0) {return "";}
    h = _ur.substring(i + 3, _ur.length);
    if (h.indexOf("/") > -1) { h = h.substring(0, h.indexOf("/")); }
    h = h.toLowerCase();
    for (var ii = _uOsr.length-1 ; ii >=0  ; ii--) {
        // commencer par la fin de la liste pour donner la priorite aux moteurs ajoutes
        if (h.indexOf(_uOsr[ii].toLowerCase()) > -1) {
            // referal dans la liste des moteurs connus
            // si moteur de free ou neuf, ajouter un keyword par defaut '(masque)' car masque en POST
            if ( (_uOsr[ii].indexOf('masque') > -1 )&& (_ur.indexOf('?') < 0) ) { _ur+="?q=(masque)"};
            if ((i = _ur.indexOf("?" + _uOkw[ii] + "=")) > -1 || (i = _ur.indexOf("&" + _uOkw[ii] + "=")) > -1) {
                k = _ur.substring(i + _uOkw[ii].length + 2, _ur.length);
                if ((i = k.indexOf("&")) > -1) { k = k.substring(0, i);
                // mot clef extrait
                }
                // trim sur l'expression de recherche
                k=_uTrim(k);
                // utilisation jaidelachance
                if (( (k=="") || k.length == 0) && ( h.indexOf("google") > -1 && _ur.lastIndexOf("/")== _ur.length)) { k="(JaiDeLaChance)" ;}
                for (var yy=0;yy<_uOno.length;yy++) { if (_uOno[yy].toLowerCase()==k.toLowerCase()) { _ufno=1; break; } }
                if ( (k!="") || k.length > 0) {
                    // mot clef non vide
                    if (t) {return _uEC(k);}
                    else {return "utmccn=(organic)|utmcsr="+_uEC(_uOsr[ii])+"|"+"utmctr="+_uEC(k)+"|utmcmd=organic"};
                }
                // mot clef vide : moteur suivant
            }
            // parametre du mot clef non trouve : moteur suivant
        }
    }
    return "";
}

function _uRef() {
 if (_ur=="0" || _ur=="" || _ur=="-") return "";
 var i=0,h,k,n;
 if ((i=_ur.indexOf("://"))<0) return "";
 h=_ur.substring(i+3,_ur.length);
 if (h.indexOf("/") > -1) {
  k=h.substring(h.indexOf("/"),h.length);
  if (k.indexOf("?") > -1) k=k.substring(0,k.indexOf("?"));
  h=h.substring(0,h.indexOf("/"));
 }
 h=h.toLowerCase();
 n=h;
 if ((i=n.indexOf(":")) > -1) n=n.substring(0,i);
 for (var ii=0;ii<_uRno.length;ii++) {
  if ((i=n.indexOf(_uRno[ii].toLowerCase())) > -1 && n.length==(i+_uRno[ii].length)) { _ufno=1; break; }
 }
  // detection webmail : groupe les webmail en forçant le hostname
  if ( h.indexOf("mail") >-1 || h.indexOf("smtp") >1 || (h.indexOf("imp") >-1 && h.indexOf("free.fr") > -1)) {
      var domain = h.substring(0,h.lastIndexOf('.'));
      h="webmail "+h.substring(domain.lastIndexOf('.'),h.length) ;
  }
 if (h.indexOf("www.")==0) h=h.substring(4,h.length);
 return "utmccn=(referral)|utmcsr="+_uEC(h)+"|"+"utmcct="+_uEC(k)+"|utmcmd=referral";
}

function _uBInfo() {
 var sr="-",sc="-",ul="-",fl="-",cs="-",je=1;
 var n=navigator;
  if (top.screen) {
  sr=top.screen.width+"x"+top.screen.height;
  sc=top.screen.colorDepth+"-bit";
 } else  if (self.java) {
  var j=java.awt.Toolkit.getDefaultToolkit();
  var s=j.getScreenSize();
  sr=s.width+"x"+s.height;
 }
 if (n.language) { ul=n.language.toLowerCase(); }
 else if (n.browserLanguage) { ul=n.browserLanguage.toLowerCase(); }
 je=n.javaEnabled()?1:0;
 if (_uflash) fl=_uFlash();
 if (_ubd.characterSet) cs=_uES(_ubd.characterSet);
 else if (_ubd.charset) cs=_uES(_ubd.charset);
 return "&utmcs="+cs+"&utmsr="+sr+"&utmsc="+sc+"&utmul="+ul+"&utmje="+je+"&utmfl="+fl;
}