var xtnv;
var xtn2;
var xtdmc;
var xtprm;
var xtdi;
var xtsite;
var xtsd;
var xtpage;
var xtdr;
var xw;
var xd;
var xtxp;
var xtdate;
var xtheureh;

function pageStat(p_uri)
{
     

      var uri = new String( p_uri );
	
      var rules = getLevel2SiteForSite();
      var xtsites = getXtsiteByLang();      
      var nodes = uri.split( "/" );
      var lang = nodes[0];

	  
	for( var j=0; j<xtsites.length; j++ )
      {
	if( xtsites [j][0] == lang )
        {
	xtsite = xtsites [j][1];

          break;
        }
      }

      
      xtnv = document;        //parent.document or top.document or document
      xtdmc  = "";
      xtprm  = "";
      xtdi = "";            //implication degree
      xtsd = getXtsd();

      xtn2 = "0";
      var rest = ""
      for( var i=0; i<rules.length; i++ )
      {
        if( uri.substring( 0, rules[i][0].length ) == rules[i][0] )
        {

          xtn2 = rules[i][1];
          rest = new String( uri.substring( rules[i][0].length ) );
          break;
        }
      }

      // TRAITEMENT DE LA PAGE D'ACCUEIL
      if(p_uri == "fr/accueil" || p_uri == "en/home") {
          xtn2 = "1";
      }

      // TRAITEMENT DE LA PAGE D'ERREUR
      if(p_uri == "error.page") {
          xtn2 = "13";
      }
      xtpage = rest.split( "/" ).join( "::" );
	  
      // FOR TESTING ONLY
      //var img = "http://test.eurelis.com/hit.xiti?s=" + xtsite + "&s2="+ xtn2 +"&p=" + xtpage + "&di=&";
      //newimage = new Image(1,1);
      //newimage.src = img;
	  
	xtdr = 30;
	xw = window;
	xd = document;

	xto_force = null;      				//to fix your own independant xtor
	xtdm = (xw.xtdmc!=null && xw.xtdmc!='') ? ";domain=" + xw.xtdmc  : "" ;
	xtnv = (xw.xtnv!=null) ? xw.xtnv : xd ;
	xtsd = (xw.xtsd!=null) ? xw.xtsd : "http://www" ;
	xtsite = (xw.xtsite!=null) ? xw.xtsite : 0;
	xtn2 = (xw.xtn2!=null) ? "&s2="+xw.xtn2 : "";
	xtp = (xw.xtpage!=null) ? xw.xtpage : "";
	xtrd = (xtsite=="redirect") ? true : false;
	xtdi = ((xw.xtdi!=null)&&(xw.xtdi!="")) ? "&di=" + xw.xtdi : "";
	xtm = (xw.xtparam!=null) ? xw.xtparam : "";

	xter = ((xw.xterr!=null)&&(xw.xterr!="")&&(xtm.indexOf("&err",0)<0)) ? "&err=" + xw.xterr : "";
	xtmc = ((xw.xtmc!=null)&&(xw.xtmc!="")&&(xtm.indexOf("&mc",0)<0)) ? "&mc=" + xw.xtmc : "";
	xtac = ((xw.xtac!=null)&&(xw.xtac!="")&&(xtm.indexOf("&ac",0)<0)) ? "&ac=" + xw.xtac : "";
	xtan = ((xw.xtan!=null)&&(xw.xtan!="")&&(xtm.indexOf("&an",0)<0)) ? "&an=" + xw.xtan : "";
	xtnp = ((xw.xtnp!=null)&&(xw.xtnp!="")&&(xtm.indexOf("&an",0)<0)) ? "&np=" + xw.xtnp : "";
	xtprm = ((xw.xtprm!=null)&&(xtm.indexOf("&x",0)<0)) ? xw.xtprm : "";
	xtm += xter+xtmc+xtac+xtan+xtnp+xtprm+xtdi;

	try {xt_rfr = top.document.referrer;}
	catch(e) {xt_rfr = xtnv.referrer; }
	xts = screen;
	xtxp = new Date();
	xtxp.setTime(xtxp.getTime()+(xtdr*1000));
	xtdate = new Date();
	xtheureh = xtdate.getTime() / (1000*3600);

	if((xtsite!=0)||(xtrd))
	{
		xtourl_rf = recupxtor("xtref");		//referrer prioritaire si dans URL
		xtourl = recupxtor("xtor");
		xto = (xto_force!=null) ? xto_force : (xtourl!=null) ? xtourl : (!xtrd) ? Getxtorcookie("xtord") : null;
		xplus = (xto==null) ? "" : "&xto="+xto;
		Xt_r = (xtourl_rf!=null) ? xtourl_rf.replace(/[<>]/g, '') : Getxtorcookie("xtref");
		if(Xt_r==null)	{	Xt_r = xt_rfr.replace(/[<>]/g, '')	}
		if (!xtrd)
		{		
			var xtnav = navigator.appName+" "+navigator.appVersion;
			var xtIE = (xtnav.indexOf('MSIE'));
			if (xtIE>=0) {xtvers = parseInt(xtnav.substr(xtIE+5));xtIE=true;}
			else {xtvers = parseFloat(navigator.appVersion);xtIE=false;}
			var xtnet=(xtnav.indexOf('Netscape') >=0);
			var xtmac=(xtnav.indexOf('Mac') >=0);
			var xtOP=(navigator.userAgent.indexOf('Opera') >=0);
			if((xtIE)&&(xtvers >=5)&&(!xtmac)&&(!xtOP)&&(!xtrd))
		 	{
		    	xd.body.addBehavior("#default#clientCaps");
		    	xtconn = '&cn=' + xd.body.connectionType;
		    	xtconn += '&ul=' + xd.body.UserLanguage;
		    	xd.body.addBehavior("#default#homePage");
		    	xthome = (xd.body.isHomePage(location.href))? '&hm=1': '&hm=0';
			   xtresr = '&re='+xd.body.offsetWidth+'x'+xd.body.offsetHeight;
		 	}
			else
			{xtconn = ''; xthome='';if(xtvers >=5){xtresr = '&re='+xw.innerWidth+'x'+xw.innerHeight;}else{xtresr =''};}
			if((xtnet)&&(xtvers >=4)||(xtOP)){var xtlang = '&lng=' + navigator.language;}
			else {if((xtIE)&&(xtvers >=4)&&(!xtOP)){var xtlang = '&lng=' +navigator.userLanguage;} else {xtlang = '';}}
					
			Xt_param = 's='+xtsite+xtn2+'&p='+xtp+'&hl='+xtdate.getHours()+'x'+xtdate.getMinutes()+'x'+xtdate.getSeconds();
			Xt_param += xplus+xtm+xtconn+xthome+xtlang;

			// DEBUG HERE
			Xt_i = '<img width="1" height="1" src="'+xtsd+'.xiti.com/hit.xiti?'+Xt_param;	
	               // var img = "http://test.eurelis.com/hit.xiti?s=" + xtsite + "&s2="+ xtn2 +"&p=" + xtpage + "&di=&";
	               // newimage = new Image(1,1);
	               // newimage.src = img;
			// DEBUG HERE

			if(xtvers>=4)
			{Xt_i+='&r='+xts.width+'x'+xts.height+'x'+xts.pixelDepth+'x'+xts.colorDepth;}
			xd.write(Xt_i+xtresr+'&ref='+Xt_r.replace(/&/g, '$')+'" >');
		}
		else
		{
			if (xto!=null) {wcookie("xtord",xto,xtxp,xtdm,1);}
			if (Xt_r!="")	{wcookie("xtref",Xt_r.replace(/&/g, '$'),xtxp,xtdm,0);}
			if(xw.xtloc!=null)	{xtnv.location=xw.xtloc;}
		}
	}
}

function xtclURL(ch)
{
	return ch.replace(/%3C/g,'<').replace(/%3E/g,'>').replace(/[<>]/g,'');
}

function Getxtorcookie(nom)
{	var arg = nom + "=";
	var i = 0 ;
	while (i<xd.cookie.length)
	{var j = i + arg.length;if (xd.cookie.substring(i,j) == arg) {return valeurxtorcook(j);}
	i = xd.cookie.indexOf(" ",i) + 1;if (i==0) {break;}	}
	return null;}

function valeurxtorcook(index)
{var fin = xd.cookie.indexOf(";",index);
if (fin==-1) {fin=xd.cookie.length;};
return unescape(xtclURL(xd.cookie.substring(index,fin)));}
	
function recupxtor(param)
{
	var xturl = xtclURL(xtnv.location.search.toLowerCase().replace(/%3d/g,'='));
	xtpos = xturl.indexOf(param+"=");
	if (xtpos > 0)
	{chq = xturl.substring(1, xturl.length);mq = chq.substring(chq.indexOf(param+"="), chq.length);pos3 = mq.indexOf("&");
		if (pos3 == -1) pos3 = mq.indexOf("%26")
		if (pos3 == -1) pos3 = mq.length;
		return mq.substring(mq.indexOf("=")+1, pos3);}
	else {	return null; }
}

function wcookie(p1,p2,p3,p4,fmt)
{
	p2 = (fmt==0) ? p2 : escape(p2);
	xd.cookie = p1 + "=" + p2 + ";expires=" + p3.toGMTString() + " ;path=/" + p4;
}

function linkStat(type,page,title,x1,x2,x3,x4,x5)
{

	var uri = new String( page );
	var rules = getLevel2SiteForSite();
	var xtsites = getXtsiteByLang();      
	var nodes = uri.split( "/" );
	var lang = nodes[3];
	  
    for( var j=0; j<xtsites.length; j++ )
	{
        if( rules[j][0] == lang )
        {
          xtsite = rules[j][1];
          break;
        }
    }
	
	var xtsd = getXtsd();
	
    section = "0";
    var rest = ""
    for( var i=0; i<rules.length; i++ )
      {
		if( uri.substring( 0, rules[i][0].length ) == rules[i][0] )
        {
          section = rules[i][1];
          rest = new String( uri.substring( rules[i][0].length ) );
          break;
        }
      }

      // TRAITEMENT DE LA PAGE D'ACCUEIL
      if(uri == "fr/accueil" || uri == "en/home") {
          section = "1";
      }

      // TRAITEMENT DE LA PAGE D'ERREUR
      if(uri == "error.page") {
          section = "13";
      }

      var dest = '';

      if(x1 == 'S'){
        dest = x2;
      }

      if(x1 == 'T'){
        var url = new String(x2);
        var destinations = url.split("/");
        dest = destinations[(destinations.length - 1)];
      }

	xt_img = new Image();
	xt_ajout = (type=="F") ? "" : (type=="M") ? "&a="+x1+"&m1="+x2+"&m2="+x3+"&m3="+x4+"&m4="+x5 : "&clic="+x1;

	Xt_im = xtsd+'.xiti.com/hit.xiti?s='+xtsite+'&s2='+section;
	
	// DEBUG HERE
        //Xt_im = '<img width="1" height="1" src="http://test.eurelis.com/hit.xiti?s='+xtsite+'&s2='+section;
	// DEBUG HERE
	
	xts = screen;
	xtxp = new Date();
	xtxp.setTime(xtxp.getTime()+(xtdr*1000));
	xtdate = new Date();
	xtheureh = xtdate.getTime() / (1000*3600);

	Xt_im += '&p='+dest+xt_ajout+'&hl=' + xtdate.getHours() + 'x' + xtdate.getMinutes() + 'x' + xtdate.getSeconds();
	if(parseFloat(navigator.appVersion)>=4)
	{Xt_im += '&r=' + xts.width + 'x' + xts.height + 'x' + xts.pixelDepth + 'x' + xts.colorDepth;}
	xt_img.src = Xt_im;
	if ((x2 != null)&&(x2!=undefined)&&(type=="C"))
	{ if ((x3=='')||(x3==null)) { window.location = x2} else {xfen = window.open(x2,'xfen',''); xfen.focus();}}
	else	{return;}
 
}