// JavaScript Document
time1="rien";
time2="rien";
coul=0;
width=100;
height=1;
text="";
function getXhr(){
				if(window.XMLHttpRequest) // Firefox et autres
				   xhr = new XMLHttpRequest(); 
				else if(window.ActiveXObject){ // Internet Explorer 
				   try {
			                xhr = new ActiveXObject("Msxml2.XMLHTTP");
			            } catch (e) {
			                xhr = new ActiveXObject("Microsoft.XMLHTTP");
			            }
				}
				else { // XMLHttpRequest non supporté par le navigateur 
				   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
				   xhr = false; 
				} 
}



function popup(page){
	leselect="";
	text="";
		var cache=document.createElement("div");
		cache.className="cache";
		cache.id="cache";
		cache.style.width=screen.width+'px';
		cache.style.height=screen.height+'px';
		cache.onclick=function(){
			exit_popup();
			}
		document.body.appendChild(cache);
		backcoul();

		var popup=document.createElement("div");
		popup.className="popup";
		popup.id="popup";
		popup.style.top=(screen.height/2)-110+"px";
		popup.style.left=(screen.width/2)-(width/2)+"px";
		document.body.appendChild(popup);
		size2();
		pageajax(page);
		
}

function pageajax(page){
	getXhr();
					xhr.onreadystatechange = function(){
					if(xhr.readyState == 4 && xhr.status == 200){
						leselect = xhr.responseText;
						text=leselect;
					}

				}
				xhr.open("POST",'include/page_popup.php',true);
				xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				xhr.send('&id='+page);


}
function exit_popup(){
	height-=70;
	width-=140;	
	document.getElementById('popup').innerHTML="";
	document.getElementById('popup').style.height=height+"px";
	document.getElementById('popup').style.width=width+"px";
	document.getElementById('popup').style.left=(screen.width/2)-(width/2)+"px";
	document.getElementById('popup').style.top=(screen.height/2)-(height/2)-110+"px";

		if(width>140){
			time2=setTimeout("exit_popup()",50);
		}else{
			clearTimeout(time2);
			document.body.removeChild(document.getElementById('popup'));
			document.body.removeChild(document.getElementById('cache'));
			height=0;
			width=100;
		}


}
function backcoul(){
	document.getElementById('cache').style.opacity="0."+coul;
	document.getElementById('cache').style.filter="alpha(opacity="+coul+"0)";
		coul++;
		if(coul<7){
			time1=setTimeout("backcoul()",10);
		}else{
			clearTimeout(time1);
			document.getElementById('cache').style.opacity="0.7";
			document.getElementById('cache').style.filter="alpha(opacity=70)";
			coul=0;
		}
}

function size(){
	document.getElementById('popup').style.left=(screen.width/2)-(width/2)+"px";
	document.getElementById('popup').style.width=width+"px";
		width+=80;
		if(width<screen.width-250){
			time2=setTimeout("size()",10);
		}else{
			clearTimeout(time2);
			document.getElementById('popup').style.width=width+"px";
			verif_retour();
		}
}

function size2(){
	document.getElementById('popup').style.top=(screen.height/2)-(height/2)-110+"px";
	document.getElementById('popup').style.height=height+"px";
		height+=30;
		if(height<screen.height-250){
			time2=setTimeout("size2()",10);
		}else{
			clearTimeout(time2);
			document.getElementById('popup').style.height=height+"px";
			size();
			
		}
}

function verif_retour(){

		if(text==""){
			time2=setTimeout("verif_retour()",100);
		}else{
			clearTimeout(time2);
			document.getElementById('popup').innerHTML=text;
		}

}

function popup_but(val){
document.getElementById('delete').src="images/delete"+val+".gif";
}

