//FUNCTION AJAX XHR enable
function getXhr(){
			var xhr = null; 
			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; 
				} 
    return xhr;
}

function ShowThisBox(id){
	var d = document.getElementById(id);
	if(d.style.display=='block'){
		d.style.display='none';
		} else{
				d.style.display='block';
			}
	}
	
function HideThisBox(id){
//	document.getElementById(id).innerHTML='';
	document.getElementById(id).style.display='none';
	}


//IDEM A toutes les requetes ajax
function LoadPageZoom(pdf){
	ShowThisBox('ZoomBox');
	ShowThisBox('Zoom');
	var xhr = getXhr();
		xhr.onreadystatechange = function(){
			document.getElementById("ZoomTxt").innerHTML = '<img src="images/anim-roue.gif" height="96" width="96" border="0" id="loading">';
			if(xhr.readyState == 4 && xhr.status == 200){
				document.getElementById("ZoomTxt").innerHTML = xhr.responseText;
			}
		}	
	xhr.open("POST","Ajax/LoadPageZoom.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("pdf="+pdf);		
}


//IDEM A toutes les requetes ajax
function FullScreenPageZoom(){
	var viewportwidth;
 	var viewportheight;
	 if (typeof window.innerWidth != 'undefined'){
	      viewportwidth = window.innerWidth,
	      viewportheight = window.innerHeight
	 } else if(typeof document.documentElement != 'undefined'
	     && typeof document.documentElement.clientWidth !=
	     'undefined' && document.documentElement.clientWidth != 0){
	       viewportwidth = document.documentElement.clientWidth,
	       viewportheight = document.documentElement.clientHeight
	 } else {
	       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
	       viewportheight = document.getElementsByTagName('body')[0].clientHeight
	 }

	document.getElementById("ZoomTxt").style.border = "none";
	document.getElementById("Zoom").style.border = "none";
	document.getElementById("ZoomBox").style.border = "none";
	document.getElementById("ZoomTxt").style.width = viewportwidth+"px";
	document.getElementById("ZoomTxt").style.height = viewportheight +"px";
	document.getElementById("ZoomTxt").style.top = "0px";
	document.getElementById("ZoomPdf").style.width = viewportwidth+"px";
	document.getElementById("ZoomPdf").style.height = viewportheight+"px";
	document.getElementById("FullSrc").innerHTML = '<a onclick="FullScreenPageDeZoom();">Affichage normal</a>';
	}

//IDEM A toutes les requetes ajax
function FullScreenPageDeZoom(){
	document.getElementById("FullSrc").innerHTML = '<a onclick="FullScreenPageZoom();">Plein écran</a>';
	document.getElementById('ZoomTxt').style.width = '520px';
	document.getElementById('ZoomTxt').style.height = '710px';
	document.getElementById('ZoomTxt').style.top = '15px';
	document.getElementById('ZoomPdf').style.width = '520px';
	document.getElementById('ZoomPdf').style.height = '675px';	
	document.getElementById("ZoomTxt").style.border = "3px solid #333";
}


//IDEM A toutes les requetes ajax
function ClosePageZoom(){
	document.getElementById('ZoomTxt').style.width = '520px';
	document.getElementById('ZoomTxt').style.height = '710px';
	document.getElementById('ZoomTxt').style.top = '15px';
	document.getElementById('ZoomPdf').style.width = '520px';
	document.getElementById('ZoomPdf').style.height = '675px';	
	document.getElementById('ZoomTxt').innerHTML = '';
	document.getElementById('Zoom').style.display='none';
	document.getElementById('ZoomBox').style.display='none';
	}

//FUNCTION Page Suivante spec Index
function GotoPage(a){
	var xhr = getXhr();
		xhr.onreadystatechange = function(){
	//		document.getElementById('Chargement').innerHTML = '<img src="images/anim-roue.gif" height="96" width="96" border="0" id="loading">';
			if(xhr.readyState == 4 && xhr.status == 200) {
				if(xhr.responseText!=''){
				document.getElementById("CatTableAjax").innerHTML = xhr.responseText;
				} else {
				window.location.replace('login.php?a='+a);	
				}
			}
		}
	xhr.open("POST","Ajax/LoadPage.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("a="+a);		
}


//FUNCTION Page Suivante
function NextPage(a){
	var xhr = getXhr();
		xhr.onreadystatechange = function(){
			document.getElementById('CatLeftImg').innerHTML = '<img src="images/anim-roue.gif" height="96" width="96" border="0" id="loading">';
			document.getElementById('CatRightImg').innerHTML = '<img src="images/anim-roue.gif" height="96" width="96" border="0" id="loading">';
			if(xhr.readyState == 4 && xhr.status == 200) {
				document.getElementById("CatTableAjax").innerHTML = xhr.responseText;
				}
			}
	xhr.open("POST","Ajax/LoadPage.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("Nexta="+a);		
}

//FUNCTION Page Précédente
function PrevPage(a){
	var xhr = getXhr();
		xhr.onreadystatechange = function(){
			document.getElementById("CatLeftImg").innerHTML = '<img src="images/anim-roue.gif" height="96" width="96" border="0" id="loading">';
			document.getElementById("CatRightImg").innerHTML = '<img src="images/anim-roue.gif" height="96" width="96" border="0" id="loading">';
			if(xhr.readyState == 4 && xhr.status == 200){
				document.getElementById("CatTableAjax").innerHTML = xhr.responseText;
				}
			}
	xhr.open("POST","Ajax/LoadPage.php",true);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("Preva="+a);		
}