function slideShow(id,speed) {
	
	//Set the opacity of all images to 0
	$('#'+id+' a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#'+id+' a:first').css({opacity: 1.0});
	

	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval("gallery('"+id+"')",speed);
	
}

function gallery(id) {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#'+id+'  a.show')?  $('#'+id+' a.show') : $('#'+id+'  a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#'+id+'  a:first') :current.next()) : $('#'+id+' a:first'));	
	
	if (  id == "gallery" )
	{
	//Get next image caption
		//var caption = next.find('img').attr('alt');
		//$(".captions").fadeOut("slow",function(){$(".captions").html(caption);});
		
	//alert(caption);
	}
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	//$('#'+id+'  .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	//$('#'+id+'  .caption').animate({opacity: 0.7},100 ).animate({height: '100px'},500 );
	
	//Display the content
	//$('#'+id+' .content').html(caption);
	//$(".captions").fadeIn("slow");	
	
}



   $(document).ready(function() {
		
		  if (window.top !== window.self) {
window.top.location = window.self.location;
}
		
		slideShow('gallery',4000);	
		
		
		$("#Gcontact input").click(function(){
		 $(this).css("color","#333");
		 if ( $(this).val() == "Nom / Prénom"  || $(this).val() == "Téléphone"  || $(this).val() == "Email" || $(this).val() == "Sujet" || 
			 $(this).val() == "Entrez votre Nom / Prénom"  || $(this).val() == "Entrez votre téléphone"  || $(this).val() == "Entrez votre email" || $(this).val() == "email incorrect" || $(this).val() == "Entrez le sujet de votre demande" 
		  )
		 {
				$(this).val("") ;
		 }
		});	 
		$("#Gcontact textarea").click(function(){
		 $(this).css("color","#333");
		 if ( $(this).val() == "Ecrivez ici votre message" || $(this).val() == "Aucune demande ?")
		 {
				$(this).val("") ;
		 } 
		 });
		 
		 
		 $("#Gcontact input").focus(function(){
		 $(this).css("color","#333");
		 if ( $(this).val() == "Nom / Prénom" ||  $(this).val() == "Téléphone"  || $(this).val() == "Email" ||  $(this).val() == "Sujet" || 
			 $(this).val() == "Entrez votre Nom / Prénom"   || $(this).val() == "Entrez votre téléphone"  || $(this).val() == "Entrez votre email" || $(this).val() == "email incorrect" || $(this).val() == "Entrez le sujet de votre demande"
		  )
		 {
				$(this).val("") ;
		 }			 
		 });
		 $("#Gcontact textarea").focus(function(){
		 $(this).css("color","#333");
		 if ( $(this).val() == "Ecrivez ici votre message" || $(this).val() == "Aucune demande ?")
		 {
				$(this).val("") ;
		 } 			 
		}); 
		 
		 
		$("#bottom_contactc").click(function(){
		
		var couleurErreur = "#FFFFFF"	
		var count = 0;
		
		if ( $("#Gnom").val() == "" || $("#Gnom").val() == "Nom / Prénom"  || $("#Gnom").val() == "Entrez votre nom / Prénom" )
		{
			$("#Gnom").css("color",couleurErreur);
			$("#Gnom").val("Entrez votre Nom / Prénom");
		}else
		{
			count++;	
		}
		
			
		
		if ( $("#Gtel").val() == "" || $("#Gtel").val() == "Téléphone" || $("#Gtel").val() == "Entrez votre téléphone")
		{
			$("#Gtel").css("color",couleurErreur);
			$("#Gtel").val("Entrez votre téléphone");
		}else
		{
			count++;	
		}			

		if ( $("#Gsujet").val() == "" || $("#Gsujet").val() == "Sujet" || $("#Gsujet").val() == "Entrez le sujet de votre demande")
		{
			$("#Gsujet").css("color",couleurErreur);
			$("#Gsujet").val("Entrez le sujet de votre demande");
		}else
		{
			count++;	
		}	
		
		if ( $("#Gemail").val() == ""  || $("#Gemail").val() == "Email" || $("#Gemail").val() == "Entrez votre email")
		{
			$("#Gemail").css("color",couleurErreur);
			$("#Gemail").val("Entrez votre email");
		}
		else
		{
			
			var verif = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,3}$/
			if (verif.exec($("#Gemail").val()) == null)
			{ 
				$("#Gemail").css("color",couleurErreur);
				$("#Gemail").val("email incorrect");	
			}
			else
			{
				count++;
			}
		}	

		if ( $("#Gdemande").val() == "" || $("#Gdemande").val() == "Ecrivez ici votre message"  || $("#Gdemande").val() == "Aucune demande ?")
		{
			$("#Gdemande").css("color",couleurErreur);
			$("#Gdemande").val("Aucune demande ?")
		}
		else
		{
			count++;	
		}	
		
		if (  count == 5 )
		{
					//alert('coucou');			
					$.post("ajaxGContact.php", { 
					   nom: $("#Gnom").val(),
					   telephone: $("#Gtel").val(),
					   email: $("#Gemail").val(),
					   sujet: $("#Gsujet").val(),
					   demande: $("#Gdemande").val()
					   },
						function(data){	
									
								if ( data == "ok" )
								{
									alert('E-mail envoyé\r\n Votre e-mail a été transmis avec succès à l\'équipe et sera traité dans les meilleurs délais.');
									
									$("#Gnom").val("Nom / Prénom");
									$("#Gtel").val("Téléphone");
									$("#Gemail").val("Email");
									$("#Gsujet").val("Sujet");
									$("#Gdemande").val("Ecrivez ici votre message");
								}
								else
								{
									alert('Une erreur est survenue... pas de panique !\r\n Il semble que le message n\'a pu ëtre delivré<br/>Reéssayez...');	
									$("#verifForm").fadeOut("fast");
								}
						 },"html" );	
		}});		
		
		
		
   });
