﻿		function setUploadedImage(html_content) {
				
				var nb_photo = $(".block_photos_upload").length+1;
				
				//A faire seuleument si #no foto existe
				if($("#no_photo").length == 1) {
					$('#no_photo').fadeOut("slow",function(){	
						$('#no_photo').remove();
						
						//Insertion du code html caché
						$('#photos').append(html_content).hide().fadeIn();
					});
				}
				else {
					//Insertion du code html caché
					$('#photos').append(html_content).hide().fadeIn();
				}
				
				//Mise a jour de la légende
				$('#legendPhotos').empty().append("Mes Photos "+ nb_photo +"/5");
				
				
				 $(".block_photos_upload").each(function(i){
					$(this).find(".fileName").attr('name', 'photo_'+(i+1));
				});
		}
		
		$(document).ready(function() { 	
			
			//Revoir gestion du nombre
			$(".removePhoto").live("click", function(){
				
				//Recupération de l'image à supprimer
				var upload_id = $("#uploadFrame").contents().find("#upload_id").val();
				var contentPhoto = $(this).parent(".block_photos_upload");
				var fileName = contentPhoto.find(":hidden").val();
				
				//Supression de la photo
				$.post("http://"+window.location.host+"/libs/ajax/removePhoto.php", {file: fileName, upload_id: upload_id},
				   function(data){
					 //alert("Data Loaded: " +  data);
					
					//Suppression de l'affichage de la photo
					contentPhoto.fadeOut("slow",function(){
					    
						$(this).remove();
						
						var nb_photo = $(".block_photos_upload").length;
						
						if($(".block_photos_upload").length == 0) {
							//Si plus de photos afficher no photo
							$("#photos").append("<p id='no_photo'><b>Vous n'avez insérer aucune photo.</b></p>");
							nb_photo = 0;
						}						
						
						//Mise a jour de la légende
						$('#legendPhotos').empty().append("Mes Photos "+ nb_photo +"/5");	
						
						//Reactivation du formulaire de chargement
					 	$("#uploadFrame").contents().find("#errorUpload").fadeOut(function() {
							$("#uploadFrame").contents().find("#sendFile").fadeIn();
						});
						
						//Renumérotage des photos
						$(".block_photos_upload").each(function(i){
							$(this).find(".fileName").attr('name', 'photo_'+(i+1));
						});
					 }); 
				   }
				 );
			});
			
			
			//////////////////////////////////////////////// Gestion frame //////////////////////////////////////////////////
				//Nombre de photo uploader
				var nb_photo = window.parent.$(".block_photos_upload").length;
				
				if(nb_photo >= 5) {
					$('#sendFile').fadeOut(function() { 
						$("#errorUpload").fadeIn().append("<b>Vous ne pouvez plus charger de photos.</b>");
					});
				}
				
				//Affichage barre de chargement
				$('#uploadForm').submit(function() { 
					$('#errorUpload').css("display", "none");
					
					$('#sendFile').fadeOut("fast",function(){
						$('#wait').fadeIn("slow");
					});
				});
			/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		});

		
		
		
		
