function getURI()
{
	var result = '';
    var url = document.location.href;
	// remove the http://
    var urlparts = url.split('//');
	// remobe the domain
    urlparts = urlparts[1].split('/');
	// remove query string params
    var loc = 1;
    if (urlparts[0].indexOf('recette-esplus.sites-acs.net')!=-1) { loc=2;  }
    var qstring = urlparts[loc].split('?');
	if (qstring == null)
		result = '/' + urlparts[loc];
	else
	    result = '/' + qstring[0];
	return result;
}
var PLAN_PAGE = 'FR_PLAN';
var VUE_PAGE = 'FR_VUE';
var V3D_PAGE = 'FR_3D';
var estat_l1;
var estat_l2;
var estat_page;
var estat_curr_map;
var lang = "fr";

function set_estat_param()
{
	var page = getURI();
	switch (page)
	{
		case '/':
		case '/index.php':
		case '/index.htm':
		case '/index':
			// Accueil
			estat_l1 = 'ACCUEIL';
			estat_l2 = 'ACCUEIL';
			estat_page = 'ACCUEIL';
			parameter = '';
			break;
		case '/presentation':
			//presentation
			estat_l1 = 'PRESENTATION';
			estat_l2 = 'PRESENTATION';
			estat_page = 'PRESENTATION';
			parameter='';
			break;
		case '/formulaire-contact.htm':
		case '/contact':
			// Contact form
			estat_l1 = 'NOUS.CONTACTER';
			estat_l2 = 'NOUS.CONTACTER';
			estat_page = 'DEMANDE.CONTACT';
			parameter = '';
			break;
		case '/printversion.html':
			// Print
			estat_l1 = 'PRESENTATION';
			estat_l2 = 'PRESENTATION';
			estat_page = 'PRESENTATION';
			parameter = 'IMPRIMER #1';
			break;
		case '/recommendsite.htm':
			// Recommend this site
			estat_l1 = 'PRESENTATION';
                        estat_l2 = 'PRESENTATION';
                        estat_page = 'PRESENTATION';
                        parameter = 'RECOMMANDER.AMI';
                        break;
		case '/video.htm':
		case '/video':
			// Video
			estat_l1 = 'MEDIA';
			estat_l2 = 'VIDEOS';
			estat_page = 'VIDEOS';
			parameter = '';
			break;
		case '/photo.htm':
		case '/photos':
			//Photos
 			estat_l1 = 'MEDIA';
                        estat_l2 = 'PHOTOS';
                        estat_page = 'PHOTOS';
                        parameter = '';
                        break;

/*
		case '/panoramique-360.htm':
			// 360�
			estat_l1 = 'OPTIONS';
			estat_l2 = '360';
			estat_page = 'FR_E360';
			break;
		case '/flashaudio.htm':
			// Flash audio
			estat_l1 = 'OPTIONS';
			estat_l2 = 'AUDIO';
			estat_page = 'FR_AUDIO';
			break;
		case '/catalogue.htm':
			// Catalog
			estat_l1 = 'OPTIONS';
			estat_l2 = 'CATALOGUE';
			estat_page = 'FR_CATALOGUE';
			break;
*/
		case '/map.htm':
		case '/map':
		case '/plan':
		case '/zone-intervention':
			// Access map
			estat_l1 = 'NOUS.SITUER';
			estat_l2 = 'NOUS.SITUER';
			estat_page = 'PLAN';
			parameter = '';
			break;
/*
		case '/plan-vue.htm':
			// Aerial view
			estat_l1 = 'EDITORIAL';
			estat_l2 = 'VUE';
			estat_page = 'FR_VUE';
			estat_curr_map = 'FR_VUE';
			break;
		case '/itineraire.htm':
			// Itinerary
			estat_l1 = 'EDITORIAL';
			estat_l2 = 'ITI';
			estat_page = 'FR_FORM_ITINERAIRE';
			break;
		case '/plan-3D.htm':
			// 3D view
			estat_l1 = 'EDITORIAL';
			estat_l2 = 'V3D';
			estat_page = 'FR_3D';
			estat_curr_map = 'FR_3D';
			break;
		case '/info-annonceur.htm':
			// Legal mention
			estat_l1 = 'INFOS';
			estat_l2 = 'MENTIONS.LEG';
			estat_page = 'FR_MENTIONS_LEGALES';
			break;
		case '/appeler_gratuitement.htm':
			// Free call
			estat_l1 = 'CONTACT';
			estat_l2 = 'APPEL.GRATUIT';
			estat_page = 'FR_APPEL_GRATUIT';
			break;
*/
		default:
			//Activities
			estat_l1 = 'ACTIVITES';
                        estat_l2 = 'ACTIVITES';
                        estat_page = page.substring(1);
			parameter = '';
                        break;

	}
/*
	if (tag_activity != '')
	{
		estat_l1 = '(ES+)ACTIVITES';
		estat_l2 = tag_activity;
	}
*/
//alert ('page : ' + page + ' ; l1 : ' + estat_l1 + ' ; l2 : ' + estat_l2 + ' ; page : ' + estat_page + ' ; tag_activity : ' + tag_activity);
}
/*
function submitStat()
{
	var xmlhttp;
	if (window.XMLHttpRequest)
  	{
  		// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
  	}
	else if (window.ActiveXObject)
  	{
  		// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	else
  	{
  		alert("Your browser does not support XMLHTTP!");
		return;
  	}
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
  		{
  			// Get data from the server's response
			alert('Stats submitted successfully');
  		}
		else
		{
			alert('Stats submit failed: ' + xmlhttp.readyState + ' Text: ' + xmlhttp.responseText);
		}
	}
	var statUrl = 'http://www.pagesjaunes.fr/plusdeservices/Partenaire.do?ServicePartenaire=ESPLUS&niveau2=' + estat_l1 + '&niveau3=' + estat_l2 + '&Page=' + estat_page;
	xmlhttp.open("GET",statUrl,true);
	xmlhttp.send(null);
}	
*/
function submitStat()
{
    var statUrl = 'http://www.pagesjaunes.fr/plusdeservices/Partenaire.do?ServicePartenaire=PVI&niveau1=' + lang + '&niveau2=(PVI)' + estat_l1 + '&niveau3=' + estat_l2 + '&Page=' + estat_page;
//alert(statUrl);
    var head= document.getElementsByTagName('head')[0];
    var script= document.createElement('script');
    script.type= 'text/javascript';
    script.src= statUrl;
    head.appendChild(script);
}

function switchVueWrap(vue)
{
	switch (vue)
	{
		case 'Photo':
			/*
			if (estat_page == 'Carto')
				estat_page = 'FR_VUEPLAN';
			else if (estat_page == '3D')
				estat_page = 'FR_VUE3D';
			*/
			estat_page = 'PLAN';
			break;
		case 'Carto':
			/*
			if (estat_page == 'Photo')
				estat_page = 'FR_PLANVUE';
			else if (estat_page == '3D')
				estat_page = 'FR_PLAN3D';
			*/
			estat_page = 'VUES';
			break;
		case 'Hybrid':
			/*
			if (estat_page == 'Carto')
		                estat_page = 'FR_3DPLAN';
			else if (estat_page == 'Photo')
				estat_page = 'FR_3DVUE';
			*/
			estat_page = "MIXTE";
			break;
	}
	switchVue(vue);
	submitStat();
}
set_estat_param();
//submitStat();

