var idInput;

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

function popClose(){
	document.getElementById('popup').style.width='0px';
	document.getElementById('popup').style.height='0px';
	document.getElementById('popup').innerHTML='';
	document.getElementById('popup2').style.width='0px';
	document.getElementById('popup2').style.height='0px';
	document.getElementById('popup2').innerHTML='';
}

function ajaxRechCat(id){
	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);
					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;
	
	xhrConn.open("POST", "../phpAjax/navigateur.php", true);
	xhrConn.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 	 
	xhrConn.send(complet); 	
}

function choixCat(id,nom){
	popClose();
	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;
}

function checkLienCat(type,identifiant){
	window.document.body.style.cursor='wait';
	idInput=identifiant;
	if(type=='add'){
		ajaxRechCat('1');
	}
	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); 	
}
