var siteRoot=document.location.href.split("/").splice(0,document.location.href.split("/").length-1);
function isInt(x) {
   var y=parseInt(x);
   if (isNaN(y)) return false;
   return x==y && x.toString()==y.toString();
 } 
function startLoading() {
	document.getElementById('loading').style.display="block";	
}
function stopLoading() {
	document.getElementById('loading').style.display="none";
}
function erreurLoading() {
	alert("La requete n'a pas aboutie. Merci de reassayer.");
	stopLoading();
}
function identifyMe(login,mdp,redir) {
	startLoading();
	var login=document.getElementById('login').value;
	var mdp=document.getElementById('pass').value;
	nova.io.send({
		file:"ajax/identify.php",
		method:"POST",
		queryString:"login="+login+"&mdp="+mdp+"&redir="+redir,
		timeout:10000,
		onLoad:resultIdentify,
		onTimeout:erreurLoading
	});
}
function resultIdentify(texte) {
	myTexte=texte.split("|");
	if(myTexte[0]=="ok") {
		if(myTexte[1]!="no") {
			setCookie("idlog", myTexte[1]);
			setCookie("mdp", myTexte[2]);
		}
		document.location.href="gestion.php";
	}
	else {
		alert(texte);
		stopLoading();
	}
}
function showMe(myId) {
	myElement=document.getElementById(myId);
	myElement.style.display=(myElement.style.display=="block")?"none":"block";
}
function checkMe(myRadio) {
	var myId=myRadio.id.substr(0,myRadio.id.length-5);
	myElement=document.getElementById(myId);
	childList=myElement.parentNode.childNodes;
	for (i=0;i<childList.length;i++) {
		if (childList[i].tagName=="A") {
			childList[i].style.color="";
		}
	}
	myElement.style.color="#126F00";
}
function checkRadio(myElement) {
	document.getElementById(myElement.id+"Radio").checked='checked';
	childList=myElement.parentNode.childNodes;
	for (i=0;i<childList.length;i++) {
		if (childList[i].tagName=="A") {
			childList[i].style.color="";
		}
	}
	myElement.style.color="#126F00";	
}

function loadAnnu(limit,sortAnnu,typeAnnu,tag) {
	startLoading();
	var tag=(tag)?tag:"";
	//on recupere le site courant
	myForm=document.searchAnnu;
	var idSite=myForm.listeSite.value;
	if ((!typeAnnu || typeAnnu=="") && (!sortAnnu || sortAnnu=="")) {
		//on recupere le trie des annuaires
		for(i=0;i<myForm.sortAnnu.length;i++) {
			if(myForm.sortAnnu[i].checked==true) {
				sortAnnu=myForm.sortAnnu[i].value;
			}
		}
		//on recupere le type d'annuaire demande
		for(i=0;i<myForm.typeAnnu.length;i++) {
			if(myForm.typeAnnu[i].checked==true) {
				typeAnnu=myForm.typeAnnu[i].value;
			}
		}
	}
	//on regarde si un filtres est applique
	var scriptType=document.getElementById('scriptAnnu').value;
	var deepLink=document.getElementById('deepLink').value;
	var rssFeed=document.getElementById('rssFeed').value;
	var dedicatedPage=document.getElementById('dedicatedPage').value;
	var selectedTheme=document.getElementById('selectThemes').value;

	//on regarde si le tri est ignore
	var ignoreTri=(document.getElementById('ingoreTri').checked)?1:0;	
	//on sauvegarde la derniere recherche
	document.getElementById('lastSearch').value="loadAnnu('"+limit+"','"+sortAnnu+"','"+typeAnnu+"','"+tag+"')";
	nova.io.send({
		file:"ajax/loadannu.php",
		method:"POST",
		queryString:"sortAnnu="+sortAnnu+"&typeAnnu="+typeAnnu+"&idSite="+idSite+"&tag="+tag+"&limit="+limit+"&ignoreTri="+ignoreTri+"&scriptType="+scriptType+"&deepLink="+deepLink+"&rssFeed="+rssFeed+"&dedicatedPage="+dedicatedPage+"&selectedTheme="+selectedTheme,
		timeout:10000,
		onLoad:updateListAnnu,
		onTimeout:erreurLoading
	});

}
function updateListAnnu(result,args) {
	document.getElementById('updateListAnnu').innerHTML=result;
	stopLoading();
}
function showAllEtats(myElement) {
	myElement.className="changeEtatHover";	
}
function hideAllEtats(myElement) {
	myElement.className="changeEtat";
}
function changeEtat(myElement,idAnnu,etat) {
	startLoading();
	document.getElementById('currentEtat-'+idAnnu).src=myElement.src;
	writeNewEtat(idAnnu,etat);
	hideAllEtats(myParent=myElement.parentNode);
}
function writeNewEtat(idAnnu,etat) {
	startLoading();
	//on recupere le site courant
	var idSite=myForm.listeSite.value;
	nova.io.send({
		file:"ajax/writeetat.php",
		method:"POST",
		queryString:"idAnnu="+idAnnu+"&etat="+etat+"&idSite="+idSite,
		timeout:10000,
		onLoad:newEtatWrited,
		onTimeout:erreurLoading
	});
}
function newEtatWrited() {
	stopLoading();
}
function loadInfoAnnu(idAnnu) {
	startLoading();
	//on recupere le site courant
	myForm=document.searchAnnu;
	var idSite=myForm.listeSite.value;
	nova.io.send({
		file:"ajax/loadinfoannu.php",
		method:"POST",
		queryString:"idAnnu="+idAnnu+"&idSite="+idSite,
		timeout:10000,
		onLoad:annuLoaded,
		onTimeout:erreurLoading
	});
	//on stock l'id de l'annu en question dans un hiddenfield
	document.getElementById('currentSelectedAnnu').value=idAnnu;
}
function annuLoaded(result,myVar) {
	document.getElementById('right').innerHTML=result;
	stopLoading();
	getPr(document.getElementById('currentSelectedAnnu').value);
}
function showAllNote(myElement) {
	myElement.className="showNoteHover";	
}
function hideAllNote(myElement) {
	myElement.className="showNote";
}
function changeNote(note,idAnnu) {
	startLoading();
	nova.io.send({
		file:"ajax/changenote.php",
		method:"POST",
		queryString:"idAnnu="+idAnnu+"&note="+note,
		timeout:10000,
		onLoad:noteChanged,
		onTimeout:erreurLoading
	});
	document.getElementById('notePerso').innerHTML=note;
	hideAllNote(document.getElementById('showNote'));
}
function noteChanged(result) {
	document.getElementById('noteGlobale').innerHTML=result+"pts";
	stopLoading();
}
function showPopup(myId,myEffect) {
	if(document.getElementById(myId).style.display=="") {
		return false;
	}
	//on verifie que chaque popup est ferme sinon on le ferme.
	listElement=nova.dom.getElementsByAnything('popup');
	for (i=0;i<listElement.length;i++) {
		if (listElement[i].style.display!="none") {
			hidePopup(listElement[i].id);
		}
	}
	document.getElementById(myId).style.display="block";//hack IE qui peu pas recuperer les dimensions d'un element en disply:none;
	nova.dom.centerObjectOnViewport(document.getElementById(myId));
	document.getElementById(myId).style.display="none";
	if (myEffect) {
		document.getElementById(myId).style.zIndex=10;//pali un defaut des div  en relative
		nova.effects.addToQueue(nova.effects.fadeIn,document.getElementById(myId),{duration:100});
		nova.effects.queueNext();
	}
	else {
		document.getElementById(myId).style.display="block";
	}
}
function hidePopup(myId) {	
	nova.effects.addToQueue(nova.effects.fadeOut,document.getElementById(myId),{duration:100});
	nova.effects.queueNext();
}
function submitAnnu() {
	startLoading();
	var nomAnnu=document.getElementById('nomAnnu').value;
	var urlAnnu=document.getElementById('urlAnnu').value;
	var submitUrlAnnu=document.getElementById('submitUrlAnnu').value;
	var descAnnu=document.getElementById('descAnnu').value;
	var tagsAnnu=document.getElementById('tagsAnnu').value;
	nova.io.send({
		file:"ajax/addannu.php",
		method:"POST",
		queryString:"nomAnnu="+nomAnnu+"&urlAnnu="+urlAnnu+"&submitUrlAnnu="+submitUrlAnnu+"&tagsAnnu="+tagsAnnu+"&descAnnu="+descAnnu,
		timeout:10000,
		onLoad:resultSubmitAnnu,
		onTimeout:erreurLoading
	});
}
function submitAnnu2() {
	startLoading();
	var nomAnnu=document.getElementById('nomAnnu').value;
	var urlAnnu=document.getElementById('urlAnnu').value;
	var submitUrlAnnu=document.getElementById('submitUrlAnnu').value;
	var descAnnu=document.getElementById('descAnnu').value;
	var longDesc=document.getElementById('descAnnu2').value;
	var theme=document.getElementById('theTheme').value;
	var deepLink=(document.getElementById('deepLink').checked)?1:0;
	var filRss=(document.getElementById('filRss').checked)?1:0;
	var pageDedie=(document.getElementById('pageDedie').checked)?1:0;
	var typeScrypt=(document.getElementById('inputOtherScript').value!="")?document.getElementById('inputOtherScript').value:document.getElementById('scryptUsed').value;
	var email=document.getElementById('emailAnnu').value;
	var linkRetour=document.getElementById('linkRetour').value;
	
	nova.io.send({
		file:"ajax/addannu2.php",
		method:"POST",
		queryString:"nomAnnu="+nomAnnu+"&urlAnnu="+urlAnnu+"&submitUrlAnnu="+submitUrlAnnu+"&longDesc="+longDesc+"&descAnnu="+descAnnu+"&theme="+theme+"&deepLink="+deepLink+"&filRss="+filRss+"&pageDedie="+pageDedie+"&typeScrypt="+typeScrypt+"&email="+email+"&linkRetour="+linkRetour,
		timeout:10000,
		onLoad:resultSubmitAnnu,
		onTimeout:erreurLoading
	});
}
function resultSubmitAnnu(texte) {
	alert(texte);
	stopLoading();
}
function submitSite() {
	startLoading();
	var nomSite=document.getElementById('nomSite').value;
	var urlSite=document.getElementById('urlSite').value;
	nova.io.send({
		file:"ajax/addsite.php",
		method:"POST",
		queryString:"nomSite="+nomSite+"&urlSite="+urlSite,
		timeout:10000,
		onLoad:resultSubmitSite,
		onTimeout:erreurLoading
	});
	document.getElementById('nomSite').value="";
	document.getElementById('urlSite').value="";
}

function resultSubmitSite(texte) {
	myTexte=texte.split('|');
	alert(myTexte[0]);
	stopLoading();
	if(myTexte[1]) {
		loadSite(myTexte[1]);
	}
}
function loadSite(idSite) {
	startLoading();
	//on garde les reglages
	//trier les annuaires
	//var myArray= new Array();
	/* probleme IE avec getByanithing */
	//myArray=nova.dom.getElementsByAnything('sortAnnu');
	
	var myArray=new Array(
	document.getElementById('sortAnnunoteRadio'),
	document.getElementById('sortAnnunomRadio'),
	document.getElementById('sortAnnudateRadio'),
	document.getElementById('sortAnnunotePersoRadio'),
	document.getElementById('sortAnnupageRankRadio')
	);
	
	for (i=0;i<myArray.length;i++) {
		if (myArray[i].checked) {
			var sSort=myArray[i].value;
		}
	}
	//afficher les annuaires
	/* probleme IE avec getByAnithing */	
	//myArray=nova.dom.getElementsByAnything('typeAnnu');
	
	var myArray=new Array(
	document.getElementById('type0Radio'),
	document.getElementById('type1Radio'),
	document.getElementById('type2Radio'),
	document.getElementById('type3Radio'),
	document.getElementById('type4Radio')
	);
	
	for (i=0;i<myArray.length;i++) {
		if (myArray[i].checked) {
			var sType=myArray[i].value;
		}
	}
	//tags
	var sTag=document.getElementById('inputTagFiltre').value;
	//l'annu selectionne
	var sIdAnnu=document.getElementById('currentSelectedAnnu').value;
	//on regarde si on ignore le tri pour la recherche par tag
	var sIgnoreTri=(document.getElementById('ingoreTri').checked)?1:0;
	//on note le type de la derniere recherche effectuee
	var sLastSearch=document.getElementById('lastSearch').value;
	document.location.href="gestion.php?idSite="+idSite+"&sSort="+sSort+"&sType="+sType+"&sTag="+sTag+"&sIdAnnu="+sIdAnnu+"&sIgnoreTri="+sIgnoreTri+"&sLastSearch="+sLastSearch;
}
function deleteSite() {
	startLoading();
	myForm=document.searchAnnu;
	var idSite=myForm.listeSite.value;
		nova.io.send({
		file:"ajax/deletesite.php",
		method:"POST",
		queryString:"idSite="+idSite,
		timeout:10000,
		onLoad:resultDeleteSite,
		onTimeout:erreurLoading
	});
}
function resultDeleteSite(texte) {
	alert(texte);
	stopLoading();
	document.location.href="gestion.php";
}
function inscriptionUser() {
	var login=document.getElementById('login').value;
	var mdp=document.getElementById('mdp').value;
	var email=document.getElementById('email').value;
	startLoading();
		nova.io.send({
		file:"ajax/inscriptionuser.php",
		method:"POST",
		queryString:"login="+login+"&mdp="+mdp+"&email="+email,
		timeout:10000,
		onLoad:resultInscriptionUser,
		onTimeout:erreurLoading
	});
}
function resultInscriptionUser(texte) {
	alert(texte);
	stopLoading();
}
function submitLostMdp() {
	startLoading();
	var emailLost=document.getElementById('emailLost').value;
	nova.io.send({
		file:"ajax/lostmdp.php",
		method:"POST",
		queryString:"emailLost="+emailLost,
		timeout:10000,
		onLoad:resultSubmitLostMdp,
		onTimeout:erreurLoading
	});
	document.getElementById('emailLost').value="";
}
function submitActiveCompte() {
	startLoading();
	var emailCompte=document.getElementById('emailCompte').value;
	nova.io.send({
		file:"ajax/activecompte.php",
		method:"POST",
		queryString:"emailCompte="+emailCompte,
		timeout:10000,
		onLoad:resultSubmitLostMdp,
		onTimeout:erreurLoading
	});
	document.getElementById('emailLost').value="";
}
function resultSubmitLostMdp(texte) {
	alert(texte);
	stopLoading();
}
function getInfoSite() {
	if(document.getElementById('developpeInfoSite').style.display=="block") {
		showMe('developpeInfoSite');
		return false;
	}
	startLoading();
	//on recupere le site courant
	myForm=document.searchAnnu;
	idSite=myForm.listeSite.value;
	nova.io.send({
		file:"ajax/infosite.php",
		method:"POST",
		queryString:"idSite="+idSite,
		timeout:10000,
		onLoad:resultGetInfoSite,
		onTimeout:erreurLoading
	});
}
function resultGetInfoSite(result) {
	document.getElementById('infoSite').innerHTML=result;
	showMe('developpeInfoSite');
	stopLoading();
}
function colorMe(myElement) {
	//on sais qu'il n'y aura qu'un seul element
	holdElement=nova.dom.getElementsByAnything('linkAnnuSelected');
	holdElement.className="linkAnnu";
	myElement.className="linkAnnuSelected";
}
//permet de switcher entrenom et url des annu
function switchAnnu() {
	allAnnu=nova.dom.getElementsByAnything('switchDomaine');
	if(allAnnu=="") {
		return false;
	}
	if (allAnnu.length>0) {
		for (i=0;i<allAnnu.length;i++) {
			allAnnu[i].style.display=(allAnnu[i].style.display=="none")?"block":"none";
		}
	}
	else{
		allAnnu.style.display=(allAnnu.style.display=="none")?"block":"none";
	}
	allAnnu=nova.dom.getElementsByAnything('switchNom');
	if (allAnnu.length>0) {
		for (i=0;i<allAnnu.length;i++) {
			allAnnu[i].style.display=(allAnnu[i].style.display=="none")?"block":"none";
		}
	}
	else{
		allAnnu.style.display=(allAnnu.style.display=="none")?"block":"none";
	}
}
function loadCloud(filtre) {
	startLoading();
	filtre=(filtre)?filtre:"";
	nova.io.send({
		file:"ajax/loadcloud.php",
		method:"POST",
		queryString:"filtre="+filtre,
		timeout:10000,
		onLoad:resultLoadCloud,
		onTimeout:erreurLoading
	});
}
function resultLoadCloud(texte) {
	document.getElementById('theCloud').innerHTML=texte;
	document.getElementById('divIgnoreTri').style.display='block';
	stopLoading();
}
function addTag(idAnnu) {
	startLoading();
	tag=document.getElementById('inputAddTag').value;	
	nova.io.send({
		file:"ajax/addtag.php",
		method:"POST",
		queryString:"tag="+tag+"&idAnnu="+idAnnu,
		idAnnu:idAnnu,
		timeout:10000,
		onLoad:resultAddTag,
		onTimeout:erreurLoading
	});
}
function resultAddTag(texte) {
	texte=texte.split("|");
	if(texte[1]) {
		loadTagForThisAnnu(texte[0]);
		alert(texte[1]);
	}
	else {
		alert(texte);
	}
	stopLoading();
}
function loadTagForThisAnnu(idAnnu){
		nova.io.send({
			file:"ajax/loadtagforthisannu.php",
			method:"POST",
			queryString:"&idAnnu="+idAnnu,		
			timeout:10000,
			onLoad:resultloadTagForThisAnnu,
			onTimeout:erreurLoading
		});
}
function resultloadTagForThisAnnu(texte) {
	document.getElementById('tagsForThisAnnu').innerHTML=texte;
}

//permet d'ajouter les liens fait par un annuaire vers notre site
function addMyLink(idAnnu) {
	startLoading();
	var idSite=myForm.listeSite.value;
	var theLink=document.getElementById('inputAddLink').value.replace(/\+/g,'*-*');
	var theLink=theLink.replace(/&/g,'*amp*');
	nova.io.send({
		file:"ajax/addmylinkforthisannu.php",
		method:"POST",
		queryString:"idAnnu="+idAnnu+"&idSite="+idSite+"&theLink="+theLink,		
		timeout:10000,
		onLoad:resultAddMyLink,
		onTimeout:erreurLoading
	});
}
function resultAddMyLink(result) {
	if (!isInt(result)) {
		alert(result);
	}
	else {
		loadMyLinksForThisAnnu(result);
	}
	document.getElementById('inputAddLink').value="";
	stopLoading();
}
function loadMyLinksForThisAnnu(idAnnu) {
		var idSite=myForm.listeSite.value;
		nova.io.send({
			file:"ajax/loadmylinksforthisannu.php",
			method:"POST",
			queryString:"&idAnnu="+idAnnu+"&idSite="+idSite,		
			timeout:10000,
			onLoad:resultloadMyLinksForThisAnnu,
			onTimeout:erreurLoading
		});
}
function resultloadMyLinksForThisAnnu(result) {
	document.getElementById('linksForThisAnnu').innerHTML=result;
}
function deleteMyLinkForThisannu(idLink,idAnnu) {
	deleteLink = confirm('Voulez vous vraiment supprimer ce lien ?')
	if (deleteLink) {
		nova.io.send({
				file:"ajax/deletemylinkforthisannu.php",
				method:"POST",
				queryString:"&idLink="+idLink+"&idAnnu="+idAnnu,		
				timeout:10000,
				onLoad:loadMyLinksForThisAnnu,
				onTimeout:erreurLoading
			});
	}
}
/*
function contactWebmaster() {
alert('Pour contacter le webmaster du site envoyez un message \u00E0 webmaster@mes-annuaires.info')
}
*/
//permet de signaler un lien mort
/*
function signalDeadLink(idAnnu) {
	startLoading();
	nova.io.send({
		file:"ajax/signaldeadlink.php",
		method:"POST",
		queryString:"&idAnnu="+idAnnu,		
		timeout:10000,
		onLoad:resultSignalDeadLink,
		onTimeout:erreurLoading
	});
}
function resultSignalDeadLink(texte) {
	alert(texte);
	stopLoading();
}*/
//permet de signaler un probleme avec un annuaire
function signalProbleme() {
	startLoading();
	var theProb=document.getElementById('areaProbleme').value;
	var idAnnu=document.getElementById('currentSelectedAnnu').value;
	nova.io.send({
		file:"ajax/signalprobleme.php",
		method:"POST",
		queryString:"&idAnnu="+idAnnu+"&theProb="+theProb,		
		timeout:10000,
		onLoad:resultSignalProbleme,
		onTimeout:erreurLoading
	});
}
//signal un probleme mais en dehors de la page gestion
function signalProbExterne(idAnnu) {
	startLoading();
	var theProb=document.getElementById('areaProbleme').value;
	nova.io.send({
		file:"../ajax/signalprobleme.php",
		method:"POST",
		queryString:"&idAnnu="+idAnnu+"&theProb="+theProb,		
		timeout:10000,
		onLoad:resultSignalProbleme,
		onTimeout:erreurLoading
	});
}
function resultSignalProbleme(texte) {
	alert(texte);
	stopLoading();
}
//permet d'afficher le code de l'image des meilleurs annuaire
function changeCodeBestAnnu() {
	idAnnu=document.getElementById('selectBestAnnu').options[document.getElementById('selectBestAnnu').selectedIndex].value;
	document.getElementById('showCode0').innerHTML='Copiez-collez le code ci-dessous sur l\'une de vos pages<br /><textarea onclick="select();"><a href="http://www.mes-annuaires.info/meilleurs-annuaires.php?idAnnu='+idAnnu+'"><img src="http://www.mes-annuaires.info/bestimg/bestannuimg.php?id='+idAnnu+'&type=0" alt="Cet annuaire fait parti des meilleurs annuaires de mes-annuaires.info" border="0" /></a></textarea>';
	document.getElementById('showImg0').innerHTML='Ce qui vous donnera l\'image suivante<br /><a href="http://www.mes-annuaires.info/meilleurs-annuaires.php?idAnnu='+idAnnu+'"><img src="http://www.mes-annuaires.info/bestimg/bestannuimg.php?id='+idAnnu+'&type=0" alt="Cet annuaire fait parti des meilleurs annuaires de mes-annuaires.info" border="0" /></a>';
	
	document.getElementById('showCode1').innerHTML='Copiez-collez le code ci-dessous sur l\'une de vos pages<br /><textarea onclick="select();"><a href="http://www.mes-annuaires.info/meilleurs-annuaires.php?idAnnu='+idAnnu+'"><img src="http://www.mes-annuaires.info/bestimg/bestannuimg.php?id='+idAnnu+'&type=1" alt="Cet annuaire fait parti des meilleurs annuaires de mes-annuaires.info" border="0" /></a></textarea>';
	document.getElementById('showImg1').innerHTML='Ce qui vous donnera l\'image suivante<br /><a href="http://www.mes-annuaires.info/meilleurs-annuaires.php?idAnnu='+idAnnu+'"><img src="http://www.mes-annuaires.info/bestimg/bestannuimg.php?id='+idAnnu+'&type=1" alt="Cet annuaire fait parti des meilleurs annuaires de mes-annuaires.info" border="0" /></a>';
}
function showFormat() {
	format=document.getElementById('format').options[document.getElementById('format').selectedIndex].value;
	listCode=nova.dom.getElementsByAnything('showCode');
	for (i=0;i<listCode.length;i++) {
		listCode[i].style.display="none";
	}
	listImg=nova.dom.getElementsByAnything('showImg');
	for (i=0;i<listImg.length;i++) {
		listImg[i].style.display="none";
	}
	document.getElementById('showImg'+format).style.display="block";
	document.getElementById('showCode'+format).style.display="block";
}
//permet d'afficher un popup avec la description de l'annu
function showDescAnnu(idAnnu) {
myElement=document.getElementById('descAnnu'+idAnnu);
thePopup=document.getElementById('popupDescAnnu');
descAnnu=myElement.innerHTML;
if (descAnnu=="") {
	return false;
}
posX=nova.dom.getDomOffset(document.getElementById('annu'+idAnnu),'left');
posY=nova.dom.getDomOffset(document.getElementById('annu'+idAnnu),'top')-38;

thePopup.innerHTML=descAnnu;
thePopup.style.display="block";
thePopup.style.left=posX+"px";
thePopup.style.top=posY+"px";
}
//cache la description
function hideDescAnnu() {
	if(document.getElementById('popupDescAnnu').style.display=="block") {
		document.getElementById('popupDescAnnu').style.display="none";
	}
}
//permet de precharger les tags
function preTag(myTag,ignoreTri) {
	document.getElementById('inputTagFiltre').value=myTag;
	document.getElementById('ingoreTri').checked=(ignoreTri==1)?true:false;
	loadCloud(myTag);
}
//recherche les backlink et les page indexees d'un annuaire
function loadStatForThisAnnu(idAnnu) {
	if (document.getElementById('statBacklink').innerHTML=="") {
	startLoading();
	nova.io.send({
		file:"ajax/loadstatannu.php?idAnnu="+idAnnu,
		method:"POST",
		queryString:"&idAnnu="+idAnnu,		
		timeout:10000,
		onLoad:resultLoadStatForThisAnnu,
		onTimeout:erreurLoading
	});
	}
}
function resultLoadStatForThisAnnu(result) {
	result=result.split("|");
	if (result[1]) {
		document.getElementById('statBacklink').innerHTML=result[0];
		document.getElementById('statIndexedPage').innerHTML=result[1];
	}
	stopLoading();
}

/** forum **/
//suivre un message
function followThisTopic(idMembre,idTopic,follow) {
	nova.io.send({
		file:"../ajax/forum/followtopic.php",
		method:"POST",
		queryString:"idMembre="+idMembre+"&idTopic="+idTopic+"&follow="+follow,		
		timeout:10000,
		onLoad:followThisTopicResult,
		onTimeout:erreurLoading
	});
}
function followThisTopicResult(result) {
	result=result.split("|");
	if (result[1]) {
		alert(result[0]);
		document.getElementById('followTopic').innerHTML=result[1];
	}
	else {
		alert(result);
	}
}
function getPr(idAnnu,theSource) {
	//variante pour les ficheannus
	var urlPage=(theSource=="ficheAnnu")?"../ajax/getpr.php":"ajax/getpr.php";
	nova.io.send({
		file:urlPage,
		method:"POST",
		queryString:"idAnnu="+idAnnu,		
		onLoad:getPrResult,
		onTimeout:erreurLoading
	});
}
function getPrResult(result) {
	//console.log('result='+result)
	result=result.split("|");
	document.getElementById('imgPr').src=result[1];
	document.getElementById('imgPr').alt=result[0];
}
function loadCommentForThisAnnu(idAnnu) {
	startLoading();
	nova.io.send({
		file:"ajax/loadcomment.php",
		method:"POST",
		queryString:"&idAnnu="+idAnnu,		
		timeout:10000,
		onLoad:resultLoadCommentForThisAnnu,
		onTimeout:erreurLoading
	});
}
function resultLoadCommentForThisAnnu(result) {
	document.getElementById('commentForThisAnnu').innerHTML=result;
	stopLoading();
}
function addComment(idAnnu,idUser) {
	startLoading();
	theComment=document.getElementById('newComment').value;
	nova.io.send({
		file:"ajax/addcomment.php",
		method:"POST",
		queryString:"idAnnu="+idAnnu+"&theComment="+theComment+"&idUser="+idUser,		
		timeout:10000,
		onLoad:addCommentResult,
		onTimeout:erreurLoading
	});
}
function addCommentResult(result) {
	stopLoading();
	result=result.split("|");
	loadCommentForThisAnnu(result[0]);
	alert(result[1]);
}
//signal un commentaire abusif
function signalAbusePost(idComment) {
	startLoading();
	nova.io.send({
		file:"ajax/abusepost.php",
		method:"POST",
		queryString:"idComment="+idComment,		
		timeout:10000,
		onLoad:signalAbusePostResult,
		onTimeout:erreurLoading
	});
}
function signalAbusePostResult(result) {
	alert(result);
	stopLoading();
}
//permet de remplir le champ tag avec le tag clique
function addToInputTag(theTag) {
	myInput=document.getElementById('tagsAnnu');
	holdContent=myInput.value;
	newContent=(holdContent)?theTag+","+holdContent:theTag;
	myInput.value=newContent;
}
//on enregistre le referer dans la bdd
function saveThisReferer(theReferer,ipVisiteur) {
	if(theReferer!="") {
		nova.io.send({
			file:"http://"+siteRoot[2]+"/ajax/savethisreferer.php",
			method:"POST",
			queryString:"theReferer="+theReferer+"&ipVisiteur="+ipVisiteur,		
			onLoad:saveThisRefererResult,
			onTimeout:erreurLoading
		});			
	}
}
function saveThisRefererResult(result) {
	
}
//gestion des cookies
function setCookie(nom, valeur, expiration) {
	document.cookie = nom + "=" + escape(valeur) + ((expiration == null) ? "" : ("; expires=" + expiration.toGMTString()));
}
function getCookie(nom) {
	var recherche = nom+ "=";
	if (document.cookie.length > 0) { 
		offset = document.cookie.indexOf(recherche) ;
		if (offset != -1) { // si le cookie existe
			offset += recherche.length;
			// position du début
			fin = document.cookie.indexOf(";",offset) ;
			// position de la fin 
			if (fin == -1) 
				fin= document.cookie.length;
			return unescape(document.cookie.substring(offset, fin));
		} 
	}
}