// JavaScript Document
var img_selected="";
$(document).ready(function() {
						   
	if ($('#pos-selecteur-photo').attr('src') != "") {
		$.ajax({
			   type:'POST',
			   data:{src:$('#pos-selecteur-photo').attr('src')},
			   dataType:'html',
			   url:"myphp/chargerPhoto.php",
			   success:function(data,status) {
				   $('#pos-afficheur-photo').html(data);
			   }
		});
	}
	
	
	$('img[name="vignette"]').hover(
			function() {
				$(this).css("border","1px solid #ff0000");
			},
			function(){
				if (this != img_selected)
				   $(this).css("border","none");
			}
	);
	
	$('img[name="vignette"]').click(function() {
		if (img_selected != "")
		   $(img_selected).css("border","none");
		 
		$(this).css("border","1px solid #ff0000");
		img_selected=this;
		$.ajax({
			   type:'POST',
			   data:{src:$(this).attr("src")},
			   dataType:'html',
			   url:"myphp/chargerPhoto.php",
			   success:function(data,status) {
				   $('#pos-afficheur-photo').html(data);
			   }
			   });
	});
	h_gauche=$('#colonne_gauche').css("height");
	h_droite=$('#colonne_droite').css("height");
	if (h_gauche > h_droite )
	  $('#colonne_droite').css("height",h_gauche);
	else
	  $('#colonne_droite').css("height",h_droite);
});

function selectionnerImage(img) {
	
}

function envoyerMessage() {
	envoie=true;
	if ($('#email').val() == "") {
		alert("Renseigner votre email");
		envoie=false;
	}
	if ($('#sujet').val() == "") {
		alert("Indiquer un sujet");
		envoie=false;
	}
	if ($('#message').val() == "") {
		alert("Tapez votre message");
		envoie=false;
	}
	
	if (envoie) {
		$.ajax( {
			type:'POST',
			data:{
				email:$('#email').val(),
				sujet:$('#sujet').val(),
				message:$('#message').val()
			},
			dataType:'text',
			url:"myphp/envoyerMessage.php",
			success:function(data,status) {
				
					$('#contact').html(data);
				
			}
		});
	}
	
}