﻿$(function() {
		$("#js_inactif").attr('style','display: none;');
});

function getPhoto(id_photo, id_user) {
		$("#message").attr('style','display: none;');
		$.ajax({
			cache:	false,
			url:		'../wp-content/themes/objectif-terre/fonc2.php',
			type:		'POST',
			data:	({
				action : 'infosImage',
				id_photo   : id_photo,
				id_user    :  id_user
			}),
			success: function(response) {
			$('#updForm').html(response);
			$('.update').slideDown(1000, "easeInQuint");
			}
		});
}

$(function() {
	$("#update_photo").click(function(){
		$.ajax({
		cache:	false,
		url:		'../wp-content/themes/objectif-terre/fonc2.php',
		type:		'POST',
		data:	({
			action :		'updPhoto',
			id_user       : $("#id_user").val(),
			id_photo      : $("#id_photo").val(),
			description   : $("#description").val(),
			id_region     : $("#id_region").val(),
			id_licence    : $("#id_licence").val(),
			choix_licence : $('input[type=radio][name=choix_licence]:checked').attr('value')
		}),
		success:	function(response) {
			$("#message").html(response);
			$("#message").attr('style','display: block;');
			$(".update").attr('style','display: none;');
			setTimeout("location.href='http://objectif-terre-um2.fr/mes-photos/'", 1500);
		}
		});
	});
});


function deletePhoto(id_photo, id_user) {
		if(confirm("Etes-vous sûr de vouloir supprimer cette photo ?" )) 
		{
			$.ajax({
				cache:	false,
				url:		'../wp-content/themes/objectif-terre/fonc2.php',
				type:		'POST',
				data:	({
					action :		'delPhoto',
					id_photo   : id_photo,
					id_user    :  id_user
				}),
				success: function(response) {
					$("#message").html(response);
					$("#message").attr('style','display: block;');
					setTimeout("location.href='http://objectif-terre-um2.fr/mes-photos/'", 1500);
				}
			});
		}
}
