function load(url) {
	var img = new Image();
	
	$(img).load(function () {
		//$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
		$(this).hide();				
		$('#image').removeClass('loading'); 
		
		if($('#zoom').length == 0) //si le lien de zoom n'existe pas
		{
			$('#image').append(this); //on fout la photo ds la div	
		}
		else
		{
			$('#zoom').append(this); //sinon dans le lien 
		}
		$(this).fadeIn();
		
	}).error(function () {
		
		// notify the user that the image could not be loaded
	}).attr('src', url);	
	
}
 

jQuery(document).ready(function(){		 

	jQuery('input[safari]:checkbox').checkbox({cls:'jquery-safari-checkbox'});	

	jQuery(".check").click(function () //coche l'état
		{			
			var checked = jQuery(this).attr("checked");
			checked = !checked;
			var id = jQuery(this).attr("id");			
			jQuery.post("admin?p=ajax&etat", { id : id , etat : checked });
		});
	
	jQuery(".delete").click(function ()
	{
		if(!confirm("Tu confirmes ?"))
		{		
			return false;
		}
		
		var id = jQuery(this).attr("href");
		
		jQuery.post("admin?p=ajax&del_img", { id : id });
		
		jQuery("#ligne_"+id).toggle("slow");	
		
		return false;
	} );	
	
	
	jQuery(".confirm").click(function ()
	{
		if(!confirm("Tu confirmes ?"))
		{		
			return false;
		}
	});
	
	jQuery(".hide").toggle();
	
	jQuery(".cat").click(function ()
	{
		var cat = jQuery(this).attr("href");
		jQuery("#"+cat).toggle("fast");		
		return false;
	});
	
	
	jQuery(".lien_img").click(function ()
	{
		return true; 
		//ajax image anulé...
		var id = jQuery(this).attr("id");	
		jQuery("#image").html("<a href='index'> <img src='include/img/ajaxLoader.gif' /> </a>");
		
			jQuery.post('image?ajax&show_img', { id : id } , function success(data) 
			{
				var html = data.lien;
				alert(html);
				//jQuery("#image").html(html);
				document.getElementById('image').innerHTML = html;
				alert(jQuery("#image").html());
			},"json");			
		
		return false;
	});
		
	
	if(document.title.match("admin"))
	{	
		var fkey;
		var skey;
			jQuery(document).keypress(function (e)
			{
				if(e.which == 97 )
				{
					fkey = "a";	
				}
				else if(e.which == 98 & fkey == "a" && skey != "bide")
				{
					jQuery.post("admin", { admin : "oui" });
					
					window.location.reload(true); 
				}
				else
				{
					skey = "bide";
				}
			});
	}

	
	
});


function show_cat(cat)
{
	
	jQuery("#"+cat).show();		
}
