$(function() {
  $('#gallery a').lightBox();
});


$(document).ready(function(){
$('#par1').hide();
$('#par2').hide();
$("#thechoices").change(function(){
$("#" + this.value).show().siblings().hide();
});

$("#thechoices").change();
});





 $(document).ready(function() {
$('#toggleButton').click(function() {


 if ($('#toggleSection').is(":hidden"))
 {
$('#toggleSection').fadeIn("slow");
 } else {
$('#toggleSection').fadeOut("slow");
 }
 return false;
});
 });


$(document).ready(function() {
$("input[name$='nbpersonne']").click(function() {
var nbpersonne = $(this).val();

$("div.desc").hide();
$("#Nbpersonne" + nbpersonne).show();
});
});

$(document).ready(function() {
$("input[name$='typecircuit']").click(function() {
var typecircuit = $(this).val();

$("div.asc").hide();
$("#Typecircuit" + typecircuit).show();
});
});

$(document).ready(function() {
$('.defaultvalue').each(function(index, element) {
var $element = $(element);
var defaultValue = $element.val();
$element.css('background-color', '#FEE3AD');
$element.focus(function() {
var actualValue = $element.val();
if (actualValue == defaultValue) {
$element.val('');
$element.css('background-color', '#FEE3AD');
}
});
$element.blur(function() {
var actualValue = $element.val();
if (!actualValue) {
$element.val(defaultValue);
$element.css('background-color', '#FEE3AD');
}
});
});
});




$(document).ready(function(){
//Hide the tooglebox when page load
$(".togglebox").hide();
//slide up and down when click over heading 2
$("h2").click(function(){
// slide toggle effect set to slow you can set it to fast too.
$(this).next(".togglebox").slideToggle("slow");
return true;
});
});


   $('input.assurance').click(function() {
    $('input.assurance:checked').not(this).removeAttr('checked');
});
    $('input.nombre_personne').click(function() {
    $('input.nombre_personne:checked').not(this).removeAttr('checked');
});


$(document).ready(function() {
	// validate signup form on keyup and submit
	var validator = $("#resaForm").validate({
		rules: {
			nom: "required",
			prenom: "required",
			
			email: {
				required: true,
				email: true,
			},
			dateformat: "required",
			terms: "required"
		},
		messages: {
			nom: "Entrer votre nom",
			prenom: "Enter votre prénom",

			email: {
				required: "Please enter a valid email address",
				minlength: "Please enter a valid email address",
				remote: jQuery.format("{0} is already in use")
			},
			dateformat: "Choose your preferred dateformat",
			terms: " "
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
			if ( element.is(":radio") )
				error.appendTo( element.parent().next().next() );
			else if ( element.is(":checkbox") )
				error.appendTo ( element.next() );
			else
				error.appendTo( element.parent().next() );
		},
		// specifying a submitHandler prevents the default submit, good for the demo
		submitHandler: function() {
			alert("submitted!");
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
	});
	
	// propose username by combining first- and lastname
	$("#username").focus(function() {
		var firstname = $("#nom").val();
		var lastname = $("#prenom").val();
		if(firstname && lastname && !this.value) {
			this.value = firstname + "." + lastname;
		}
	});

});


$(document).ready(function() {

	//Select all anchor tag with rel set to tooltip
	$('a[rel=tooltip]').mouseover(function(e) {
		
		//Grab the title attribute's value and assign it to a variable
		var tip = $(this).attr('title');	
		
		//Remove the title attribute's to avoid the native tooltip from the browser
		$(this).attr('title','');
		
		//Append the tooltip template and its value
		$(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');		
				
		//Show the tooltip with faceIn effect
		$('#tooltip').fadeIn('500');
		$('#tooltip').fadeTo('10',0.9);
		
	}).mousemove(function(e) {
	
		//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
		$('#tooltip').css('top', e.pageY + 10 );
		$('#tooltip').css('left', e.pageX + 20 );
		
	}).mouseout(function() {
	
		//Put back the title attribute's value
		$(this).attr('title',$('.tipBody').html());
	
		//Remove the appended tooltip template
		$(this).children('div#tooltip').remove();
		
	});

});
