var idInput;

function ajaxVerifMail(mail, cat, addpath){
	addpath=( addpath ? addpath : '');
	mail=( mail ? mail : '');
	cat=( cat ? cat : '');
	
	modele8PopSansLien('<div class="imageChargement"></div>');
	
	if(window.XMLHttpRequest)
	{ // Firefox 
		   xhrConn = new XMLHttpRequest(); 
	}
	else if(window.ActiveXObject)
	{ // Internet Explorer 
				try{
	                xhrConn = new ActiveXObject("Msxml2.XMLHTTP");
	            } catch (e) {
	                xhrConn = new ActiveXObject("Microsoft.XMLHTTP");
	            }
	}
		 
	if(!xhrConn)
	{ // XMLHttpRequest non supporté par le navigateur 
	   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	   xhrConn = false; 
	}

	xhrConn.onreadystatechange  = function()
	{
		try{
			 if(xhrConn.readyState  == 4)
			 {
				  if(xhrConn.status  == 200){
					if (xhrConn.responseText == '')
						{
							popClose('');
							document.getElementById('div_detail').style.display='';
							document.getElementById('buttonValider').style.display='none';
							document.location.href='#formInscription';
						}
					else
						{
							modele8PopSansLien(xhrConn.responseText,'');
						}

					window.document.body.style.cursor='default';
					/* zigouigoui */
					//ajaxRechCat(id,tempType,typeReq,valCheck);
					}
			}
		}
		catch(e){
		}
	}/*
	xhr.open(method,url, true); 
	xhr.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xhr.send(null);*/	

	complet="emailA="+mail+"&cat="+cat;
	xhrConn.open("POST", addpath + "phpAjax/getUserMail.php", true);
	xhrConn.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 	 
	xhrConn.send(complet); 	
}	

function modele8Pop(content,lien,classeCss){
	(classeCss ? classeCss=classeCss : classeCss='popContent');
	if(lien=='')
		onclickTmp="popClose('');";
	else
		onclickTmp="popClose('"+lien+"');";
	
	if(document.getElementById('popup')){
		$elt=document.getElementById('popup');
		$elt2=document.getElementById('popup2');
	}
	else{
		$elt=document.getElementById('johnny').
		$elt2=document.getElementById('jo');
	}
	
	cacheSelect('hidden');
	
	//document.location.href="#";
	//$elt.style.width=document.body.scrollWidth+50+'px';
	$elt.style.width=document.body.scrollWidth+'px';
	$elt.style.height=document.body.scrollHeight+60+'px';
	$elt.style.backgroundColor='#f6f6b0';
	//$elt2.style.width=document.body.scrollWidth+14+'px';
	$elt2.style.width=document.body.scrollWidth+'px';
	$elt2.style.height=window.screen.height-250+'px';
	//document.getElementById('popup2').style.backgroundColor='white';
	$elt2.innerHTML='<div class="popTotal"><p><input style="color:red;" type="button" value="X" onclick="'+onclickTmp+'"/></p><div class="'+classeCss+'">'+content+'</div><p><input style="color:red;" type="button" value="X" onclick="'+onclickTmp+'"/></p><div>';
}


	
	
	
	

function modele8PopSansLien(content,classeCss){
	(classeCss ? classeCss=classeCss : classeCss='');
	if(document.getElementById('popup')){
		$elt=document.getElementById('popup');
		$elt2=document.getElementById('popup2');
	}
	else{
		$elt=document.getElementById('johnny').
		$elt2=document.getElementById('jo');
	}
	
	cacheSelect('hidden');
	
	//document.location.href="#";
	//$elt.style.width=document.body.scrollWidth+50+'px';
	$elt.style.width=document.body.scrollWidth+'px';
	$elt.style.height=document.body.scrollHeight+60+'px';
	$elt.style.backgroundColor='#f6f6b0';
	//$elt2.style.width=document.body.scrollWidth+14+'px';
	$elt2.style.width=document.body.scrollWidth+'px';
	$elt2.style.height=window.screen.height-250+'px';
	//document.getElementById('popup2').style.backgroundColor='white';
	$elt2.innerHTML='<div class="popTotal"><div class="'+classeCss+'">'+content+'</div><div>';
}


	
	
	
	

function popClose(lien){ 
	if(document.getElementById('popup')){
		$elt=document.getElementById('popup');
		$elt2=document.getElementById('popup2');
	}
	else{
		$elt=document.getElementById('johnny').
		$elt2=document.getElementById('jo');
	}
	
	$elt.style.width='0px';
	$elt.style.height='0px';
	$elt.innerHTML='';
	$elt2.style.width='0px';
	$elt2.style.height='0px';
	$elt2.innerHTML='';
	
	if(lien!='')
		document.location.href=lien;
		
	cacheSelect('visible');
}


	
	
	
	

/* modif YANNICK */
function ajaxRechCat(id,tempType,typeReq,valCheck){
	valCheck=( valCheck ? valCheck : '');
	tempType=( tempType ? tempType : '');
	typeReq=( typeReq ? typeReq : '');
	if(window.XMLHttpRequest)
	{ // Firefox 
		   xhrConn = new XMLHttpRequest(); 
	}
	else if(window.ActiveXObject)
	{ // Internet Explorer 
				try{
	                xhrConn = new ActiveXObject("Msxml2.XMLHTTP");
	            } catch (e) {
	                xhrConn = new ActiveXObject("Microsoft.XMLHTTP");
	            }
	}
		 
	if(!xhrConn)
	{ // XMLHttpRequest non supporté par le navigateur 
	   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	   xhrConn = false; 
	}

	xhrConn.onreadystatechange  = function()
	{
		try{
			 if(xhrConn.readyState  == 4)
			 {
				  if(xhrConn.status  == 200){
					modele8Pop(xhrConn.responseText,'#navigateur');
					window.document.body.style.cursor='default';
					}
			}
		}
		catch(e){
		}
	}/*
	xhr.open(method,url, true); 
	xhr.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xhr.send(null);*/	
	
	complet="idCatParent="+id+"&tempType="+tempType+"&typeReq="+typeReq+"&valCheck="+valCheck;
	
	xhrConn.open("POST", "../phpAjax/navigateur.php", true);
	xhrConn.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 	 
	xhrConn.send(complet); 	
}


/* modif YANNICK */
function ajaxAddCat(id,tempType,typeReq,valCheck,langid,langlib,droitpourtous){

	valCheck=( valCheck ? valCheck : '');
	tempType=( tempType ? tempType : '');
	typeReq=( typeReq ? typeReq : '');
	
	modele8PopSansLien('<div class="imageChargement"></div>');
	
	if(window.XMLHttpRequest)
	{ // Firefox 
		   xhrConn = new XMLHttpRequest(); 
	}
	else if(window.ActiveXObject)
	{ // Internet Explorer 
				try{
	                xhrConn = new ActiveXObject("Msxml2.XMLHTTP");
	            } catch (e) {
	                xhrConn = new ActiveXObject("Microsoft.XMLHTTP");
	            }
	}
		 
	if(!xhrConn)
	{ // XMLHttpRequest non supporté par le navigateur 
	   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	   xhrConn = false; 
	}

	xhrConn.onreadystatechange  = function()
	{
		try{
			 if(xhrConn.readyState  == 4)
			 {
				  if(xhrConn.status  == 200){
					//modele8Pop(xhrConn.responseText,'#navigateur');
					window.document.body.style.cursor='default';
					/* zigouigoui */
					ajaxRechCat(id,tempType,typeReq,valCheck);
					}
			}
		}
		catch(e){
		}
	}/*
	xhr.open(method,url, true); 
	xhr.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xhr.send(null);*/	
	
	complet="idCatParent="+id+"&tempType="+tempType+"&typeReq="+typeReq+"&valCheck="+valCheck+"&Langid="+langid+"&Langlib="+langlib+"&droitAll="+droitpourtous;
	xhrConn.open("POST", "../phpAjax/addcat.php", true);
	xhrConn.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 	 
	xhrConn.send(complet); 	
}	


	
	
	
	

function choixCat(id,nom){
	popClose('#navigateur');
	window.document.getElementById('idLienCat'+idInput).value=id;
	window.document.getElementById('lienExt'+idInput).value=nom;
	disable('lienExt'+idInput);
}


	
	
	
	

function disable(id){
	window.document.getElementById(id).disabled = true;
}


	
	
	
	

function enable(id){
	window.document.getElementById(id).disabled = false;
}


	
	
	
	

/* modif YANNICK */
function checkLienCat(type,identifiant,tempType,reqType,valCheck){
	valCheck=( valCheck ? valCheck : '');
	tempType=( tempType ? tempType : '');
	reqType=( reqType ? reqType : '1');
	window.document.body.style.cursor='wait';
	idInput=identifiant;
	if(type=='add'){
		ajaxRechCat('1',tempType,reqType,valCheck);
	}
	else{
		choixCat('','');
		enable('lienExt'+idInput);
		window.document.getElementById('lienExt'+idInput).focus();
		window.document.body.style.cursor='default';
	}
}


	
	
	
	

function ajaxTitreForm(id,titre){
	if(window.XMLHttpRequest)
	{ // Firefox 
		   xhrConn = new XMLHttpRequest(); 
	}
	else if(window.ActiveXObject)
	{ // Internet Explorer 
				try{
	                xhrConn = new ActiveXObject("Msxml2.XMLHTTP");
	            } catch (e) {
	                xhrConn = new ActiveXObject("Microsoft.XMLHTTP");
	            }
	}
		 
	if(!xhrConn)
	{ // XMLHttpRequest non supporté par le navigateur 
	   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	   xhrConn = false; 
	}

	xhrConn.onreadystatechange  = function()
	{
		try{
			 if(xhrConn.readyState  == 4)
			 {
				  if(xhrConn.status  == 200)
					modele8Pop(xhrConn.responseText,'');
			}
		}
		catch(e){
		}
	}/*
	xhr.open(method,url, true); 
	xhr.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xhr.send(null);*/	
	
	complet="idForm="+id+"&titre="+titre;
	
	xhrConn.open("POST", "../phpAjax/titreForm.php", true);
	xhrConn.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 	 
	xhrConn.send(complet); 	
}


	
	
	
	

function cacheSelect(type){
	var elDiv = document.getElementsByTagName("*");
	
	for (var i=0; i<elDiv.length; i++) {
		if(elDiv[i].tagName=='SELECT'){
				elDiv[i].style.visibility=type;
		}
	}
}

