/* reconnaitre les moteurs de recherche du marche français avec Google Analytics
  Auteur : Olivier Vit, http://www.feuilledunet.info/
  version 1.5, juin 2009
  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 ou url re-ecrite)
  1.3
  - MS IE 6 n'aime pas les accents dans les commentaires !
  1.4
  - detection des webmails pour les grouper comme affluent specifique
  1.5
  - mise a jour des moteurs et ajout de bing.com 
  - zimbra comme webmail
  - validation jslint.org du code javascript
  1.6
  - changements mineurs

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.feuilledunet.info/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] = "myway"; _uOkw[w] = "searchfor"; w+=1 ;
_uOsr[w] = "mysearch"; _uOkw[w] = "searchfor"; w+=1 ;
_uOsr[w] = "need2find"; _uOkw[w] = "searchfor"; w+=1 ;
_uOsr[w] = "netscape"; _uOkw[w] = "query"; w+=1 ;
_uOsr[w] = "netscape"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "search.dmoz"; _uOkw[w] = "search"; w+=1 ;
_uOsr[w] = "babylon"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "excite"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "toile"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "hotbot"; _uOkw[w] = "query"; w+=1 ;
_uOsr[w] = "vivisimo"; _uOkw[w] = "query"; w+=1 ;
_uOsr[w] = "virgilio"; _uOkw[w] = "qs"; w+=1 ;
_uOsr[w] = "accoona"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "dir.com"; _uOkw[w] = "req"; w+=1 ;
_uOsr[w] = "clusty"; _uOkw[w] = "query"; w+=1 ;

_uOsr[w] = "kartoo"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "ujiko"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "search1-2.free"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "search2-2.free"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "search.free"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "mozbot"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "copernic"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "ixquick"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "scroogle"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "sfr.fr"; _uOkw[w] = "masque"; w+=1 ;
_uOsr[w] = "infospace"; _uOkw[w] = "masque"; w+=1 ;

_uOsr[w] = "ethicle"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "conduit"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "delicious"; _uOkw[w] = "p"; w+=1 ;
_uOsr[w] = "hooseek"; _uOkw[w] = "recherche"; w+=1 ;
_uOsr[w] = "ask"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "lycos"; _uOkw[w] = "query"; w+=1 ;
_uOsr[w] = "cuil"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "cluuz"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "yougoo"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "yauba"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "voila"; _uOkw[w] = "rdata"; w+=1 ;
_uOsr[w] = "voila"; _uOkw[w] = "kw"; w+=1 ;
_uOsr[w] = "aol"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "aol"; _uOkw[w] = "query"; w+=1 ;
_uOsr[w] = "exalead"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "alice"; _uOkw[w] = "qs"; w+=1 ;
_uOsr[w] = "hakia"; _uOkw[w] = "q"; w+=1 ;
_uOsr[w] = "lo.st"; _uOkw[w] = "x_query"; w+=1 ;
_uOsr[w] = "bing"; _uOkw[w]="q"; w+=1 ;
_uOsr[w] = "search.yahoo"; _uOkw[w]="p"; w+=1 ;
_uOsr[w] = "books.google"; _uOkw[w]="dq"; w+=1 ;
_uOsr[w] = "news.google"; _uOkw[w]="q"; w+=1 ;
_uOsr[w] = "video.google"; _uOkw[w]="d"; w+=1 ;
_uOsr[w] = "images.google"; _uOkw[w]="q"; w+=1 ;
_uOsr[w] = "translate.google"; _uOkw[w]="q"; w+=1 ;
_uOsr[w] = "directory.google"; _uOkw[w]="q"; w+=1 ;
_uOsr[w] = "blogsearch.google"; _uOkw[w]="q"; w+=1 ;
_uOsr[w] = "groups.google"; _uOkw[w]="q"; w+=1 ;
_uOsr[w] = "maps.google"; _uOkw[w]="q"; w+=1 ;
_uOsr[w] = "m.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("zimbra") >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;
}
