// JavaScript Document
// Fonction permettant de créer l'extension p=? pour identifier la page dans Xiti
function webAnalytic() {
    var i;
    var params = location.search; //return everything in the URL from '?whatever=...'
	var path = window.location.pathname; //return path of the page
	var pageName;
	
	pageName = pageSearch(path); //return l'identifiant de la page
	
	if(pageName == "viewforum_"){
		pageName = pageName + themaSearch(params); //return l'identifiant de la thematique
	}
	
	xiti(pageName);
}

// Fonction permettant de retrouver le type de page à partir du nom de la page
function pageSearch (tmpPath){
	var pageIdName;
		
	switch(tmpPath) {
	case "/index.php":
		pageIdName="page_d_index";
       	break;
	case "/viewforum.php":
		pageIdName="viewforum_";
       	break;
   	case "/viewtopic.php":
		pageIdName="viewtopic";
       	break;
	case "/posting.php":
		pageIdName="posting";
       	break;
	case "/faq.php":
		pageIdName="faq";
       	break;
	case "/search.php":
		pageIdName="search";
       	break;
	case "/memberlist.php":
		pageIdName="member";
       	break;
	case "/ucp.php":
		pageIdName="user";
       	break;
   	default:
       	pageIdName="others";
       	break;
	}
	return pageIdName;
}

// Fonction permettant de retrouver la thématique du forum en fonction du paramètre f=?
function themaSearch (tmpParams){
	var checkParam = "f"; //paramètre de l'URL à tester soit f=
	var themaIdName;
	var forumXitiName = [	"Not_Defined",			//tableau contenant tout les noms des forums en fonction de l'ID f=?
						 	"Not_Defined",			
							"WWVolley__Vestiaire",	//f=2
							"Not_Defined",
							"Not_Defined",
							"WebStyleVF",			//f=5
							"Not_Defined",
							"Not_Defined",
							"Not_Defined",
							"Not_Defined",
							"ChampPro__A",			//f=10
							"Tournament",
							"ChampPro__B",
							"ChampN1",
							"ChampN2",
							"ChampN3",
							"ChampPro__F",
							"ChampR1",
							"ChampR2",
							"ChampR3",
							"ChampDpt",				//f=20
							"Not_Defined",
							"Not_Defined",
							"ChampFranceTeam",
							"Not_Defined",
							"ChampJeunes__Champ",
							"ChampJeunes__Univ",
							"Mercato__Joueur",
							"Mercato__Club",
							"ChampLoisir",
							"WWVolley__Bureau",		//f=30
							"ChampBeach",
							"LigneDeConduite",
							"Not_Defined",
							"Not_Defined",
							"Not_Defined",
							"Not_Defined",
							"Not_Defined",
							"Not_Defined",
							"ChampPro",
							"Not_Defined",			//f=40
							"Not_Defined",
							"Not_Defined",
							"Not_Defined",
							"Not_Defined",
							"ChampN2__MA",
							"ChampN2__MB",
							"ChampN2__MC",
							"ChampN2__FA",
							"ChampN2__FB",
							"ChampN2__FC",			//f=50
							"ChampR2__IDF",
							"ChampR2__PaysLoire",
							"ChampR2__RhoneAlpes",
							"ChampR2__Alsace",
							"Not_Defined",
							"Not_Defined",
							"Not_Defined",
							"ChampR1__Aquitaine",
							"ChampR1__Alsace",
							"ChampR3__IDF",			//f=60
							"ChampN3__MA",
							"ChampN3__MB",
							"ChampN3__MC",
							"ChampN3__MD",
							"ChampN3__ME",
							"ChampN3__MF",
							"ChampN3__MG",
							"ChampN3__MH",
							"ChampN3__FA",
							"ChampN3__FB",			//f=70
							"ChampN3__FC",
							"ChampN3__FD",
							"ChampN3__FE",
							"ChampN3__FF",
							"ChampN3__FG",
							"ChampN3__FH",
							"Not_Defined",
							"ChampJeunes",
							"Not_Defined",
							"Mercato",				//f=80
							"ChampN1__M",
							"ChampN1__F",
							"WWVolley",
							"Not_Defined",
							"ChampR2__Flandres",
							"ChampR1__Auvergne",
							"ChampR2__Auvergne",
							"ChampR1__Limousin",
							"ChampR1__Normandie",
							"ChampR1__Bretagne",	//f=90
							"ChampR1__MidiPyrenees",
							"ChampR1__PoitouC",
							"ChampR1__LanguedocR",
							"ChampR1__CoteAzur",
							"Not_Defined",
							"ChampR1__FrancheComte",
							"ChampR1__Lorraine",
							"ChampR1__Champagne",
							"ChampR1__Provence",
							"ChampR1__Flandres",	//f=100
							"ChampR1__IDF",
							"ChampR1__RhoneAlpes",
							"ChampR1__Bourgogne",
							"ChampR1__Centre",
							"ChampR1__PaysLoire",
							"MadeInVF",
							"ChampR2__Bretagne",
							"ChampR2__Aquitaine",
							"ChampR2__Provence",
							"ChampDpt__92",			//f=110
							"ChampDpt__69",
							"ChampDpt__95",
							"ChampDpt__94",
							"ChampDpt__93",
							"ChampDpt__29",
							"ChampDpt__67",
							"ChampDpt__59",
							"ChampJeunes__TouPtis",
							"MadeInVF__TVF",
							"ChampDpt__78",			//f=120
							"ChampDpt__85",
							"MadeInVF__Game",
							"MadeInVF__VCS",
							"ChampR2__Lorraine",
							"ChampDpt__44",
							"ChampDpt__Divers",
							"Not_Defined",
							"ChampR3__Divers",
							"ChampN2__Divers",
							"ChampN3__Divers",		//f=130
							"WWVolley__Emploi",
							"Not_Defined",
							"Not_Defined",
							"Not_Defined",
							"Not_Defined",
							"Not_Defined",
							"Not_Defined",
							"WebStyleBug",
							"MadeInVF__Mag",		//f=139
							"ChampDpt__77",			//add 2008-03-02
							"MadeInVF__Shop"];		//add 2008-03-02
    
	tmpParams = tmpParams.split('#')[0].split('?')[1].split('&'); //remove any '#' and the '?' to prevent interference when getting values
  
  	for (i = 0; (i < tmpParams.length) && (tmpParams[i].split('=')[0] != checkParam); i++); //search through the params array until we reach the end or we find a match
    
	if (i == tmpParams.length) { //name wasn't found in the URL string
        //alert("Not found!");
		themaIdName="";
    }
    else { //we found something!!
        paramValue = tmpParams[i].split('=')[1];
        paramName = tmpParams[i].split('=')[0];
        //alert(paramName + '  =  ' + paramValue);
    }
	
	//Boucle qui va retrouver le forum parcouru (ID max = 139)
	for (i=1; i<=139; i++){
		if(paramValue == i){
			themaIdName = forumXitiName[i];
		}
	}
	
	if(themaIdName == ""){
		themaIdName = "others";
	}

	return themaIdName;
}



function xiti (name) {
		Xt_param = 's=343164&p='+name;
		
		//alert("Xt_param= "+ Xt_param);
		
		try {Xt_r = top.document.referrer;}
		catch(e) {Xt_r = document.referrer; }
		Xt_h = new Date();
		Xt_i = '<img width="39" height="25" border="0" ';
		Xt_i += 'src="http://logv145.xiti.com/hit.xiti?'+Xt_param;
		Xt_i += '&hl='+Xt_h.getHours()+'x'+Xt_h.getMinutes()+'x'+Xt_h.getSeconds();
		if(parseFloat(navigator.appVersion)>=4)
			{Xt_s=screen;Xt_i+='&r='+Xt_s.width+'x'+Xt_s.height+'x'+Xt_s.pixelDepth+'x'+Xt_s.colorDepth;}
		document.write(Xt_i+'&ref='+Xt_r.replace(/[<>"]/g, '').replace(/&/g, '$')+'">');
}