// repérage du navigateur
var comportementNS4 = (document.layers)? true:false;
var comportementNS6 = (document.addEventListener)? true:false;
var comportementIE = (document.all)? true:false;

window.id_article_liste = -1;
window.id_noeud_liste	= -1;

// récupération de la position de la souris ds le frame (par navigateur),
// et calcul de la position du layer à adopter
function get_position(e) {
	//alert(event.offsetX+" , "+event.offsetY+" , "+event.layerX +" , "+event.pageY);
    var decalageHor = -35;
	var decalageVert = 5;
	var TheScrollHeight=document.documentElement.scrollTop;
    if(comportementNS4) {
	window.positionX = e.pageX + decalageHor;
	window.positionY = e.pageY + TheScrollHeight;
    }
    if(comportementNS6) {
	window.positionX = e.clientX + document.body.scrollLeft + decalageHor;
	window.positionY = e.pageY;
    }
    if(comportementIE) {
	window.positionX = event.clientX + document.body.scrollLeft + decalageHor;
	window.positionY = event.clientY + document.body.scrollTop + decalageVert + TheScrollHeight;
    }   
	//alert("get_position"+window.positionY);
}

// selon le navigateur, appel de la fonction pour surveiller pour repérer les coordonnées du clic sur la page
if(comportementNS4) {
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown=get_position;
}
if(comportementNS6) {
    document.addEventListener('mousemove', get_position, true);
}
if(comportementIE) {	
	document.onmousedown=get_position;
}


// fait apparaitre le layer des listes et récupère l'article cliqué
function lister_listes( serverPath, fenetre, typeListe, ida, idl, other) {	
	//alert('ida='+ida+'&typeListe='+typeListe+'&idl='+idl+'&other='+other);	
	doit=false;
    if (comportementNS4){
		document.layers.fenetre.left=window.positionX;
		document.layers.fenetre.top= window.positionY;
		document.layers.fenetre.visibility = 'show';
		doit=true;
    }
    if (comportementIE || comportementNS6) {		
		document.getElementById(fenetre).style.left= window.positionX+'px';
		document.getElementById(fenetre).style.top= window.positionY+'px';		
		document.getElementById(fenetre).style.display="block";
		doit=true;
    }
    if(doit)
	makeRequest(serverPath,'ajax-listes-courses.php?ida='+ida+'&typeListe='+typeListe+'&idl='+idl+'&other='+other);
}

function testlogin( server_path, sLogin , sMdp, theListe, action, typeListe, ida  ){
	
	if( Veriflogin('AjaxLogin','AjaxMdp','Votre e-mail','******') ){
		//alert(server_path+', '+sLogin+', '+sMdp+', '+theListe+', '+action+', '+typeListe+', '+ida);
	 	makeRequest(server_path,'ajax-login.php?login='+sLogin+'&mdp='+sMdp+'&theListe='+theListe+'&action='+action+'&typeListe='+typeListe+'&ida='+ida);	
	}else{		
		Xpx=document.getElementById('fenetreCourses').style.left;
		Ypx=document.getElementById('fenetreCourses').style.top;
		document.getElementById('fenetreCourses').style.display="none";
	}
}

function ajoutListe( server_path, theListe, action, typeListe, ida ){
	//alert(server_path+', '+theListe+', '+action+', '+typeListe+', '+ida);
	makeRequest(server_path,'ajax-listes-courses.php?theListe='+theListe+'&action='+action+'&typeListe='+typeListe+'&ida='+ida);		
}

function ajoutListe2( server_path, theListe, action, typeListe, ida ){
	//alert('ajoutListe2:'+theListe);
	//alert('ajoutListe2:'+server_path+', '+theListe+', '+action+', '+typeListe+', '+ida);			
}

function MsgLogin(MsgInfo)
{
	document.getElementById('fenetreCourses').style.display="none";
	change_div("contenuAlerte",MsgInfo);	
	alerte("messageAlerte",364,200);
}
