// JavaScript Document

function ok_img($id_img)
{
		$rep = confirm("Etes vous sur de vouloir supprimer cette image ?");
		if($rep == true)
		{
			$url = "index.php?modeles=user&action=delete_image&id=" + $id_img;
			document.location = $url;
		}
}
	
function ok_folder($id_folder)
{
		$rep = confirm("ATTENTION ! CELA VA SUPPRIMER TOUTES LES IMAGES CONTENUES DANS CE DOSSIER ! ETES-VOUS SUR DE VOULOIR SUPPRIMER CE DOSSIER ?");
		if($rep == true)
		{
			$url = "index.php?modeles=user&action=delete_folder&id=" + $id_folder;
			document.location = $url;
		}
}

function ajax($url, $id, $function)
{
	 	var xhr; 
		try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
		catch (e) 
		{
			try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
			catch (e2) 
			{
			  try {  xhr = new XMLHttpRequest();     }
			  catch (e3) {  alert('Votre navigateur ne gère pas l\'ajax')   }
			}
		 }
	 
		xhr.onreadystatechange  = function()
		{ 
			 if(xhr.readyState  == 4)
			 {
				  if(xhr.status  == 200) 
				  	window[$function]($id, xhr.responseText);
			 }
		};
	
	   xhr.open("GET", $url,  true); 
	   xhr.send(null); 
} 

function rotate($id, $response)
{
	if($response=="ok")
	{
		$t = new Date();
		document.getElementById('img_'+$id).src+="?"+$t.getTime();
	}	
}

function changer(id, id2)
{
	var e = document.getElementById(id);
	var e2 = document.getElementById(id2);
	if(e.style.display == "none" || e.style.display == "")
	{
		e.style.display = 'table-row';
		e2.style.display = 'none';
	}
	else
	{
		e.style.display = 'none';
		e2.style.display = 'table-row';
	}
}

function check_img()
{
	var $t = document.form_suppr["id[]"].length, $i=0, $vide=true;	
	while($i<$t && $vide==true)
	{
		if(document.form_suppr["id[]"][$i].checked)
			$vide = false;
		$i++;
	}
	if(($vide==true && !isNaN($t)) || document.form_suppr["id[]"].checked==false)
	{		
		alert("Aucune image séléctionnée");
		return false;
	}
	else
	{
		return true;
	}
}