function hideDisplay(reponseText)
{
	if (reponseText == 0){
		$('div.lesSpinner:visible').toggle();
		$('#spin2').toggle();
		iterateur = parseInt($("#liste_jour2").val())+1;
		$("#nbnuits").attr("value",$("#liste_jour2 li:nth-child("+iterateur+")").html());
		$("#displaySpinId").attr("value","0");
	}
	else if (reponseText == 1){
		$('div.lesSpinner:visible').toggle();
		$('#spin3').toggle();
		iterateur = parseInt($("#liste_jour3").val())+1;
		$("#nbnuits").attr("value",$("#liste_jour3 li:nth-child("+iterateur+")").html());
		$("#displaySpinId").attr("value","1");
	}
	else if (reponseText == 2){
		$('div.lesSpinner:visible').toggle();
		$('#spin1').toggle();
		iterateur = parseInt($("#liste_jour").val())+1;
		$("#nbnuits").attr("value",$("#liste_jour li:nth-child("+iterateur+")").html());
		$("#displaySpinId").attr("value","2");
	}
};
	
$(document).ready(function(){
	$(".jd_menu ul li:last-child").css({border: 'none'});
	
	// Initialisation du nombre de nuits
	//$("#nbnuits").attr("value",$("#liste_jour li:nth-child(1)").html());

	// Configuration du DatePicker
	$('.datepicker').datepicker({ 
				regional: 'fr',  
				clickInput: 'true',
				legendText: '<span class="textLegend" ><span class="textLegendRouge">'+get_trad_champ("lib_carre_vert")+'</span><br /><span class="textLegendVert">'+get_trad_champ("lib_carre_rouge")+'</span></span>',
				changeMonth: 'true', 
				changeYear: 'true', 
				dateFormat: 'dd/mm/yy', 
				minDate: 0, 
				maxDate: '+24M', 
				showOn: 'both', 
				buttonImage: 'images/home/recherche/calendrier.gif', 
				buttonImageOnly: true, 
				onSelect : function(){
								$('#divCache').load('ajax/fillinputday.php',{jour : $('#jour').val()},hideDisplay);
						   },
				beforeShowDay: disabledDate
	});

					
	// Configuration du Spinner
	$("#liste_jour").spinner( { spin : function(){
		
		iterateur = parseInt($("#liste_jour").val())+1;
		$("#nbnuits").attr("value",$("#liste_jour li:nth-child("+iterateur+")").html());
		$("#valueSpinI").attr("value",$("#liste_jour").val());

		}
	});
	
	$("#liste_jour2").spinner( { spin : function(){
		iterateur = parseInt($("#liste_jour2").val())+1;
		
		$("#nbnuits").attr("value",$("#liste_jour2 li:nth-child("+iterateur+")").html());
		$("#valueSpinI").attr("value",$("#liste_jour2").val());

	} });

	$("#liste_jour3").spinner( { spin : function(){
		
		/*if($("#valueSpinI").val()==0)
		{
			iterateur =  parseInt($("#valueSpinI").val()) +2 ;		
		}
		else
		{
			iterateur = parseInt($("#liste_jour3").val())+1;
		}
		*/
		iterateur = parseInt($("#liste_jour3").val())+1;
		$("#nbnuits").attr("value",$("#liste_jour3 li:nth-child("+iterateur+")").html());
		$("#valueSpinI").attr("value",$("#liste_jour3").val());
	} });
	$("#liste_jour").val("5");
	$("#liste_jour:hidden").toggle();
	$("#liste_jour2:hidden").toggle();
	$("#liste_jour3:hidden").toggle();
	
	$('#pays').selectbox({ maxChar:8, containerClass: 'selectbox-wrapper pays'});
	$('#region').selectbox({ maxChar:8, containerClass: 'selectbox-wrapper region'});
	$('#camping').selectbox({ maxChar:8, containerClass: 'selectbox-wrapper camping'});

	$('.moreCrit, .closeCrit').click( function(){
		$('.moreCrit').toggleClass('moreCritNeg');
		$('#top_page_search_submit2').toggleClass('top_page_search_submit2IE6');
		$('.top_page_search fieldset.bas').toggle();
		return false;
	});
	$('.container_selectbox').click( function(){
		$('.moreCrit').removeClass('moreCritNeg');
		$('.top_page_search fieldset.bas').hide();
		return false;
	});

	$(".top_page_search").cssCheckbox();
	
	tabNavGestion();
	gestionCaroussel();

	/**********************************************************/
	/*				MOTEUR RECHERCHE INTERNE				  */
	/**********************************************************/
	$("#jour").click(function() { $(this).val("");});
	
	
});



/*********************************************************/
/*					home_newsletter.tpl			*/
/*********************************************************/		
String.prototype.trim = function() { return this.replace(/^\s*(\b.*\b|)\s*$/, "$1");	}

function mandatoryText(input,fieldName){
	
	if(input.value.trim()==''||input==null){
		alert( get_trad_champ("lib_veuillez_saisir_votre") + ' ' + fieldName+'.');
		input.focus();
		return false;
	} 
	else 
	{
		return true;
	}
}
	
function submit_newsletter_home()
{
	if(!mandatoryText(document.getElementById('EMAIL_FIELD'), get_trad_champ("mail"))) {
		return false;
	}
	
	if(!checkEmail('EMAIL_FIELD'))
	{
		alert(get_trad_champ("mail_incorrect"));
		return false;
	}else{
		submit_form_newsletter(); // défini dans ajax.js
	}
}