$(document).ready(function(){
	$("#full_size_img").draggable();
  });

$.fn.image = function(src, f){
   return this.each(function(){
	 $("<img />").appendTo(this).each(function(){
		this.src = src;
		this.onload = f;
	 });
   });
}

function put_image(bloc,id,type) {
	document.getElementById(bloc).innerHTML="";
	document.getElementById(bloc).style.display="none";
	if ((type != "thumb") && (type != "full")) { document.getElementById(bloc+"_titre").innerHTML = ""; document.getElementById(bloc+"_detail").innerHTML = ""; }
	$.get("./include/get_img.php", { id:id, type:type }, function(data){ 
		array_data=data.split(";;;");									 
		if (type == "thumb") {
			$("#"+bloc).image('./img/thumb_'+array_data[0],function(){
				$("#"+bloc).fadeIn("slow");
			});
		} else if (type == "full") {
			$("#full_size_img").image('./img/'+array_data[0],function(){
				$("#full_size_img").fadeIn("slow");
				document.getElementById("full_size_img").innerHTML=document.getElementById("full_size_img").innerHTML+'<a href="javascript:full_size_close();">X</a>';
			});
		} else {
			$("#"+bloc).image('./img/'+array_data[0],function(){
				$("#"+bloc).fadeIn("slow");
				document.getElementById(bloc+"_titre").innerHTML=array_data[1];
				document.getElementById(bloc+"_detail").innerHTML=array_data[2];
				document.getElementById(bloc).href="javascript:put_image('full_size_img',"+id+",'full')";
			});
		}
		//alert("Img '"+data+"' dans le bloc '"+bloc+"'");
	});
}

function full_size_close() {
	$("#full_size_img").fadeOut("fast");
}
