<!--
// Weboscope Performance - wbo_performance_rnat.js version 2.2
// Weboscope is a trademark property of weborama
// http://www.weboscope.com
// Derniere modification le  11/08/2009

////////////////////////////////
// Performance Ref Nat Class //
//////////////////////////////

/* This file is for Amaguiz */

// location
var WPERF_SERVER = ".weborama.fr";
var WPERF_PRGM = "/fcgi-bin/performance.fcgi";

function performanceRefNat()
{
    this.FID_SITE = 357581;
    // Attributs
    this.cookieSITE = 'perfvisite'+this.FID_SITE;
    this.cookieSITE_OK = 'perfvisite_OK'+this.FID_SITE;
    
    this.C_RNAT = 5041;

    this.P_AOL_FR = 10521;
    this.L_AOL_FR_HOME = 92479;

    this.P_OTHERS = 10522;
    this.L_OTHERS = 92480;
	
    this.P_GOOGLE_COM = 10523;
    this.L_GOOGLE_COM_HOME = 92481;

    this.P_GOOGLE_FR= 10524;
    this.L_GOOGLE_FR_HOME = 92482;

    this.P_LIVE_FR = 10525;
    this.L_LIVE_FR_HOME = 92483;

    this.P_MSN_FR = 10526;
    this.L_MSN_FR_HOME = 92484;

    this.P_YAHOO_FR = 10527;
    this.L_YAHOO_FR_HOME = 92487;

	this.C_USED = this.C_RNAT;
	this.P_USED = this.P_OTHERS;
	this.L_USED = this.L_OTHERS;
		
	this.NEED_PARSE_OTHERS = 1;
	
    this.cookieSITE_OK = 'perfvisite_OK'+this.FID_SITE;

    // Fonctions
    this.launchParsing = launchParsing;
    this.parseAOLFR = parseAOLFR;
    this.parseGOOGLECOM = parseGOOGLECOM;
    this.parseGOOGLEFR = parseGOOGLEFR;
    this.parseLIVEFR = parseLIVEFR;
    this.parseMSNFR= parseMSNFR;
    this.parseYAHOOFR = parseYAHOOFR;
//    this.parseOTHERS = parseOTHERS;
    this.getURL = refnatgetURL;
    this.setParseOthers = setParseOthers;
    this.execute = refnatexecute;
    this.doRequest = refnatdoRequest;
}

function setParseOthers(_VALUE)
{
	this.NEED_PARSE_OTHERS = _VALUE;	
}

function refnatexecute()
{
	if (webo_performance_rnat == 0) return 1;
	if (document.cookie.indexOf(this.cookieSITE) >= 0) return 2;

	var cur_domaine = document.location.host;
	var a_points = cur_domaine.split('.');
	if (a_points.length > 2) 
		cur_domaine = cur_domaine.substring(cur_domaine.indexOf('.')+1, cur_domaine.length);
	if (document.referrer)
	{
		this.REFERRER = document.referrer.toLowerCase();

		this.REF_DOMAIN = this.REFERRER;
		var a_div = this.REF_DOMAIN.split('/');	
		for (i = 2; i < a_div.length; ++i)
		{
			if (a_div[i].length)
			{
				this.REF_DOMAIN = a_div[i];
				i = a_div.length;
			}
		}					
		if (this.REF_DOMAIN.indexOf(cur_domaine) == -1)
		{
			if (this.launchParsing()) 
			{
				document.cookie = this.cookieSITE_OK+"=1;path=/";
				this.doRequest();
			}
		}
	}
	document.cookie = this.cookieSITE+"=1;path=/";
	return 0;
}

function launchParsing()
{
	if (this.parseAOLFR()) return 1;
	if (this.parseGOOGLECOM()) return 1;
	if (this.parseYAHOOFR()) return 1;
	if (this.parseGOOGLEFR()) return 1;
	if (this.parseLIVEFR()) return 1;
	if (this.parseMSNFR()) return 1;
//	if (this.NEED_PARSE_OTHERS) return this.parseOTHERS();	
	
	return 0;
}

function parseAOLFR()
{
	if (this.REF_DOMAIN.indexOf('.aol.fr') >= 0)
		if (this.REFERRER.indexOf('invocationtype=imagedetails') < 0)
		{ 
			myRegExp =/^http:\/\/(www\.)?(recherches?|aolrecherches?|buscador|busca|busqueda|search|aolsearch|suche)(\.aol|(\.?www)?\.netscape)(.*?)(query|q)=([^\&]+)/;
 			if (myRegExp.exec(this.REFERRER))
			{	
				this.P_USED = this.P_AOL_FR;
				this.L_USED = this.L_AOL_FR_HOME;
				return 1;
			}	
		}	
	return 0;
}

function parseGOOGLECOM()
{
	if (this.REF_DOMAIN.indexOf('.google.com') >= 0)
	{ 
		myRegExp =/^http:\/\/www\.google(.*?)(\?|&)q=([^\&]+)/;
		if (myRegExp.exec(this.REFERRER))
		{
			this.P_USED = this.P_GOOGLE_COM;
			this.L_USED = this.L_GOOGLE_COM_HOME;
			return 1;
		}	
	}	
	return 0;
}

function parseGOOGLEFR()
{
	if (this.REF_DOMAIN.indexOf('.google.fr') >= 0)
	{ 
		myRegExp =/^http:\/\/www\.google(.*?)(\?|&)q=([^\&]+)/;
		if (myRegExp.exec(this.REFERRER))
		{
			this.P_USED = this.P_GOOGLE_FR;
			this.L_USED = this.L_GOOGLE_FR_HOME;
			return 1;
		}	
	}	
	return 0;
}

function parseLIVEFR()
{
	if (this.REF_DOMAIN.indexOf('.live.') >= 0)
	{ 
		myRegExp =/^http:\/\/(uk\.search|search|search2?)\.(msn|live)(.*?)q=([^\&]+)/;
		if (myRegExp.exec(this.REFERRER))
		{
			this.P_USED = this.P_LIVE_FR;
			this.L_USED = this.L_LIVE_FR_HOME;
			return 1;
		}	
	}	
	return 0;
}

function parseMSNFR()
{
	if ((this.REF_DOMAIN.indexOf('.msn.fr') >= 0) || ((this.REF_DOMAIN.indexOf('.bing.') >= 0) && (this.REFERRER.indexOf('mkt=fr-fr') >= 0)))
	{ 
		myRegExp =/^http:\/\/(uk\.search|search|search2?)\.(msn|live)(.*?)q=([^\&]+)/;
		if (myRegExp.exec(this.REFERRER))
		{
			this.P_USED = this.P_MSN_FR;
			this.L_USED = this.L_MSN_FR_HOME;
			return 1;
		}	
		myRegExp =/^http:\/\/www\.bing\.com(.*?)(\?|&)q=([^\&]+)/;
		if (myRegExp.exec(this.REFERRER))
		{
			this.P_USED = this.P_MSN;
			this.L_USED = this.L_MSN_HOME;
			return 1;
		}		
	}	
	return 0;
}

function parseYAHOOFR()
{
	if (this.REF_DOMAIN.indexOf('fr.search.yahoo') >= 0)
	{
		myRegExp =/^http:\/\/[^\/]*\.?search\.yahoo\.com\/(.*?)p=([^\&]+)/;
		if (myRegExp.exec(this.REFERRER))
		{	
			this.P_USED = this.P_YAHOO_FR;
			this.L_USED = this.L_YAHOO_FR_HOME;	
			return 1;
		}	
	}	
	return 0;
}

function parseOTHERS()
{
	if (this.REF_DOMAIN.length)
	{
		this.REFERRER = "?Q="+escape(this.REF_DOMAIN);
		return 1;
	}
	return 0;
}

function refnatgetURL()
{
    var wbs_da = new Date();
    wbs_da = parseInt(wbs_da.getTime()/1000 - 60*wbs_da.getTimezoneOffset());
    
    // Connection type auto detection : HTTP ou HTTPS
    var WEBO_CONNEXION = (location.protocol == 'https:')?"https://amaguiz.solution":"http://amaguiz.solution";
        
    var wbs_arg = WEBO_CONNEXION + WPERF_SERVER + WPERF_PRGM + "?ID=" + this.FID_SITE + "&RN=1&A=1&T=E&W=1";
    wbs_arg += "&C=" + this.C_USED + "&P=" + this.P_USED + "&L=" + this.L_USED;
    wbs_arg += "&URL=http%3A%2F%2Fstatic.weborama.fr%2Fimages%2Ftransp.gif";
    wbs_arg += "&RND=" + wbs_da;    
    wbs_arg += "&NREF="+escape(this.REFERRER);

    return wbs_arg;
}

function refnatdoRequest()
{
    if (parseInt(navigator.appVersion) >= 3)
	{
	    webo_compteur = new Image(1,1);
	    webo_compteur.src = this.getURL();
	}
    else
	{
	    document.write("<img src='" + this.getURL() + "' border='0' height='1' width='1' alt=''>");
	}
}

////////////////////////////////////
// Weboscope performance Ref Nat ON /OFF //
//////////////////////////////////

webo_performance_rnat = 1;

//-->




