var xhr = null;

currentCat = 0;



function getXhr()
{
     if(window.XMLHttpRequest)xhr = new XMLHttpRequest();
else if(window.ActiveXObject)
  {
  try{
     xhr = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e)
     {
     xhr = new ActiveXObject("Microsoft.XMLHTTP");
     }
  }
else
  {
  alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
  xhr = false;
  }
}
function ShowPage(page)
{
getXhr();
xhr.onreadystatechange = function()
    {
     if(xhr.readyState == 4 && xhr.status == 200)
     {
     document.getElementById('content').innerHTML=xhr.responseText;
     }
    }
xhr.open("GET","ajax.php?page="+page,true);
xhr.send(null);
}

/*

function ShowSS(){

				getXhr();
				// On d�fini ce qu'on va faire quand on aura la r�ponse
				xhr.onreadystatechange = function(){
					// On ne fait quelque chose que si on a tout re�u et que le serveur est ok
					if(xhr.readyState == 4 && xhr.status == 200){

						// On se sert de innerHTML pour rajouter les options a la liste

						document.getElementById('ss').innerHTML = xhr.responseText;
					}
				}

				// Ici on va voir comment faire du post
				xhr.open("POST","listeDerSS.php",true);
				// ne pas oublier �a pour le post
				xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				// ne pas oublier de poster les arguments
				// ici, l'id de l'auteur
				sel = document.getElementById('section');
				section= sel.options[sel.selectedIndex].value;

				xhr.send("Section="+section);
			}


*/
/*
function ShowIm(im, title, dat_s, dimensions, media, view) {


	document.getElementById('image').innerHTML =  '<img src="'
	+ im +'" width=700> <div>' + title + '</div><div>' + dat_s
	+ '</div><div>' + dimensions + '</div><div>' + media
	+ '</div><div>' + view + '</div>';
}
*/
function CloseWindow() {
        ww = window.open(window.location, "_self");
        ww.close();
}

function showPDFKaitou(im) {


getXhr();
xhr.onreadystatechange = function() {
	if(xhr.readyState == 4 && xhr.status == 200) { // Nous remplacons le contenu du div iris par le retour de "ajax/ajaxiris.php"
		document.getElementById('content2').innerHTML = xhr.responseText;

	}
}
xhr.open("POST","../pdfList.php",true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.send("im="+im);
}

function ShowImKaitou(im, title, dat_s, dimensions, media, view) {
	document.getElementById('image').innerHTML =  '<img src="rescale.php?image='
	+ im +'&width=800"> ';
	document.getElementById('headerdetails').innerHTML = '<div class="detailtitel">' + title + '</div>'+' <div class="detaildata">'+dat_s + '</div>'+
	' <div class="detaildata">'+dimensions + '</div>'+
                ' <div class="detaildata">'+media + '</div>'+'<div class="detaildata">' +view+'</div>';
}


/*
function showImage2(im) {
ShowImage2(im);
}


function ShowImage2(im) {
getXhr();
xhr.onreadystatechange = function() {
	if(xhr.readyState == 4 && xhr.status == 200) { // Nous remplacons le contenu du div iris par le retour de "ajax/ajaxiris.php"
		document.getElementById('limage').innerHTML = xhr.responseText;
		if(document.getElementById('limage').getElementsByTagName("a").length > 0)
			eval(document.getElementById('limage').getElementsByTagName("a")[0].getAttribute('onclick'));
	}
}
xhr.open("POST",'listeImage.php',true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.send("im="+im);
}

*/

/*

function showImageKaitou(im) {
showImageKaitou(im);
}

function showImageKaitou(im) {

getXhr();
xhr.onreadystatechange = function() {
	if(xhr.readyState == 4 && xhr.status == 200) { // Nous remplacons le contenu du div iris par le retour de "ajax/ajaxiris.php"
		document.getElementById('limage').innerHTML = xhr.responseText;
		if(document.getElementById('limage').getElementsByTagName("a").length > 0)
			eval(document.getElementById('limage').getElementsByTagName("a")[0].getAttribute('onclick'));
	}
}
xhr.open("POST",'thumbs.php',true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.send("im="+im);
}
*/

function showImageKaitou(im,startindex) {
 currentIndex = 0
currentCat =im;
document.getElementById('limage').style.top = (-15 + (currentIndex * -35)) +"px";
getXhr();
xhr.onreadystatechange = function() {
	if(xhr.readyState == 4 && xhr.status == 200) { // Nous remplacons le contenu du div iris par le retour de "ajax/ajaxiris.php"
		document.getElementById('limage').innerHTML = xhr.responseText;
		if(document.getElementById('limage').getElementsByTagName("a").length > 0){
			var str = ""+document.getElementById('limage').getElementsByTagName("a")[0].getAttribute('onclick');
			var beginP = str.indexOf("{");
			if (beginP > 0){
				eval(str.substring(beginP+1,str.length-1));
			}	else{
				eval(document.getElementById('limage').getElementsByTagName("a")[0].getAttribute('onclick'));
			}
		}
	}
}
xhr.open("POST","thumbs.php?currentIndex="+startindex,true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.send("im="+im);



}

var currentIndex = 0;
function plusThumb(){
	var arr = document.getElementById('limage').getElementsByTagName("li");
	if (((currentIndex+1) * 20) < arr.length){
		currentIndex++;
		document.getElementById('limage').style.top = (-15 + (currentIndex * -35)) +"px";
	}
}

function minThumb(){
	var arr = document.getElementById('limage').getElementsByTagName("li");
	if (currentIndex > 0){
	currentIndex--;
		document.getElementById('limage').style.top = (-15 + (currentIndex * -35)) +"px";


	}
}





function showMovieKaitou(im) {
document.getElementById('image').innerHTML = '<object width="425" height="344"><param name="movie" value="' + im
	+ '"></param><embed src="' + im + '" type="application/x-shockwave-flash" width="425" height="344"></embed></object>';


}



function modPage()
{

     document.location.href="deconnexion.php"

}
function winPopNews(id) {


open("modifier_news.php?id="+id,"Modifier","width=500,height=300,scrollbars=no")

}
function winPopAgenda(id) {


open("modifier_agenda.php?id="+id,"Modifier","width=500,height=550,scrollbars=no")

}


