var img_bouton_courante="no";
var img_bouton_courante_click="img_virtuelle";
var img_lieu_courante="no";
var content_front="content1";
var content_back="content2";


$(function(){ 
	
	$(".bouton_survol").bind("mouseover", function(e){
  			
  			//alert($(this).attr("id"));
  			//if($(this)!=img_bouton_courante)
  				if(img_bouton_courante!="no")
  				{
  					$("#"+img_bouton_courante).show();
  					$("#"+img_bouton_courante+"_on").hide();
  				}
  				$("#"+$(this).attr("id")+"_on").show();
  				$("#"+$(this).attr("id")).hide();
  				
  				img_bouton_courante=$(this).attr("id");
  		});
  		
  		$(".bouton_survol_off").bind("mouseout", function(e){
  			//alert("dd");
  			if(img_bouton_courante!="no"&&img_bouton_courante!=img_bouton_courante_click)
  			{
  				$("#"+img_bouton_courante).show();
  				$("#"+img_bouton_courante+"_on").hide();
  				img_bouton_courante="no";
  			}
  		});
  		
  	
  		$("#bouton_tarifs").bind("click", function(e){
  			ajaxLoadHTML("information.php");
  			$("#"+img_bouton_courante_click+"_on").hide();
  			$("#"+img_bouton_courante_click).show();
  			$("#img_tarifs_on").show();
  			$("#img_tarifs").hide();
  			img_bouton_courante_click="img_tarifs";
  			img_bouton_courante="no";
  			return false;
  		});
  		$("#bouton_visite").bind("click", function(e){
  			ajaxLoadHTML("main.php");
  			$("#"+img_bouton_courante_click+"_on").hide();
  			$("#"+img_bouton_courante_click).show();
  			$("#img_virtuelle_on").show();
  			$("#img_virtuelle").hide();
  			img_bouton_courante_click="img_virtuelle";
  			img_bouton_courante="no";
  			return false;
  		});
  		$("#bouton_historique").bind("click", function(e){
  			ajaxLoadHTML("historique.php");
  			$("#"+img_bouton_courante_click+"_on").hide();
  			$("#"+img_bouton_courante_click).show();
  			$("#img_historique_on").show();
  			$("#img_historique").hide();
  			img_bouton_courante_click="img_historique";
  			img_bouton_courante="no";
  			return false;
  		});
  		$("#bouton_contact").bind("click", function(e){
  			
  			$("#"+content_back).html($("#contact_form").html());
  			$("#"+content_back).show("slow");
  			$("#"+content_front).hide("slow");
  			$("#"+content_back+" div form").attr("id","form_contact");
  			  			
  			var tmp=content_front
  			content_front=content_back;
			content_back=tmp;
  			
  			$("#"+img_bouton_courante_click+"_on").hide();
  			$("#"+img_bouton_courante_click).show();
  			$("#img_contact_on").show();
  			$("#img_contact").hide();
  			
  			
  			img_bouton_courante_click="img_contact";
  			img_bouton_courante="no";
  			formcontact();
  			return false;
  		});
  		
  		
  		
});

function bonmail(mailteste)

{
	var reg = new RegExp('^[a-z0-9]+([_|\.|-]{1}[a-z0-9]+)*@[a-z0-9]+([_|\.|-]­{1}[a-z0-9]+)*[\.]{1}[a-z]{2,6}$', 'i');

	if(reg.test(mailteste))
	{
		return(true);
	}
	else
	{
		return(false);
	}
}	

	function formcontact()
	{
		$("#form_contact").submit(function() {   
  		var mail=$("#form_contact input.input_text").val();	
  		if(!bonmail(mail))
  		{
  			alert("Pour que nous puissions vous r&eacute;pondre, il faut entrer une adresse e-mail valide.");
  			return false;
  		}
  		
  		s = $(this).serialize();  
    	$.ajax({ 
        type: "POST", 
        data: s, 
        dataType: "html",
        url: $(this).attr("action"), 
        success: function(html){ 
          	
           $("#"+content_front).html(html);
           
        }, 
        error: function(json){
  				alert("d");
  				}
    }); 
    return false; 
	});
	}

	function ajaxLoadHTML(req)
	{
		$.ajax({
  			type: "GET",
  			url: req,
  			dataType: "html",
  			success: function(html){
  				$("#"+content_back).html(html);
  				$("#"+content_back).show("slow");
  				$("#"+content_front).hide("slow");
  			  			
  				var tmp=content_front
  				content_front=content_back;
				content_back=tmp;
  				},
  			error: function(html){
  				
  				}
			});
	
	}


