

var globalTempStr = "";

$(document).ready
(
	function()
	{
		var fixedBackgroundImg = $("div#fixed-background img");
		fixedBackgroundImg.height("auto");
		fixedBackgroundImg.width($(window).width());
		if(fixedBackgroundImg.height() < $(window).height())
		{
			fixedBackgroundImg.width("auto");
			fixedBackgroundImg.height($(window).height());
		}
		setInterval(setBgSize,500);
		function setBgSize()
		{
			fixedBackgroundImg.height("auto");
			fixedBackgroundImg.width($(window).width());
			if(fixedBackgroundImg.height() < $(window).height())
			{
				fixedBackgroundImg.width("auto");
				fixedBackgroundImg.height($(window).height());
			}
		}
		
		if($.browser.msie)
		{
			var hasFocus = null;
			$("select").mouseover(function(){
				if($(this).data("origWidth") == undefined)
				{
					$(this).data("origWidth", $(this).css("width"));
				}
				$(this).css("width", "auto");
			}).focus(function(){
				hasFocus = $(this).attr("name");
			}).blur(function(){
				if(hasFocus == $(this).attr("name"))
				{
					hasFocus = null;
				}
			
				$(this).css("width", $(this).data("origWidth"));
			}).mouseout(function(){
				if(hasFocus != $(this).attr("name"))
				{
					$(this).css("width", $(this).data("origWidth"));
				}
			});
		}
		
		$.datepicker.setDefaults($.datepicker.regional['fr']);
$.datetimebox.setDefaults({
				showOn: 'focus',
				buttonImageOnly: true,
				buttonImage: 'calendar.gif',
				buttonText: 'Calendar',
				dateFormat: 'dd/mm/yy hh:ii',
				changeYear: false,
				changeMonth: false,
				closeText: 'Confirm',
				closeImage: 'calendar_close.gif',
				timeText: 'Heure (hh:mm): ',
				prevText: 'Previous',
				nextText: 'Next',
				currentText: 'Today',
				monthNames: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin','Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
				monthNamesShort: ['Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Jun','Jui', 'Aoû', 'Sep', 'Oct', 'Nov', 'Déc'],
				dayNames: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'],
				dayNamesShort: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'],
				dayNamesMin: ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'],
				weekHeader: 'Semaine',
				firstDay: 1,
				isRTL: false,
				showMonthAfterYear: false,
				yearSuffix: '',
				constrainInput: true,
				onSelect: function (dateText) {
				document.all ?
				$(this).get(0).fireEvent("onchange")
				: $(this).change();
				}
				});		
		
		var currentArrival = "";
		var currentDeparture = "";
		
		$("select[name='without_lodging']").hide();
		$("span#other").parent().parent().hide();
		$("span#renovated_room").parent().parent().hide();
		$("span#age_of_children_1").parent().parent().hide();
		
		$("select[name='_mend_reason_of_stay_1']").change(function(evt){
			if($("select[name='"+evt.target.value+"']").val() == "0")
			{
				$("span#other").parent().parent().show();
			}
			else
			{
				$("span#other").parent().parent().hide();
			}
			if(evt.target.value == "with_lodging")
			{
				$("select[name='without_lodging']").hide();
				$("select[name='with_lodging']").show();
				$("span#type_of_room_1").parent().parent().show();
				
				
				if($("select[name='type_of_room_select_1']").val() != "095" && $("select[name='type_of_room_select_1']").val() != "096" && $("select[name='type_of_room_select_1']").val() != "098" && $("select[name='type_of_room_select_1']").val() != "100")
				{
					$("span#renovated_room").parent().parent().show();
				}
				else
				{
					$("span#renovated_room").parent().parent().hide();
				}
				
				$("span#number_of_nights").parent().parent().show();
				$("span#departure_billing_1").parent().parent().show();
			}
			else
			{
				$("select[name='without_lodging']").show();
				$("select[name='with_lodging']").hide();
				
				$("span#type_of_room_1").parent().parent().hide();
				$("span#renovated_room").parent().parent().hide();
				$("span#show_number_of_nights_cont").hide();
				$("span#number_of_nights").parent().parent().hide();
				$("span#departure_billing_1").parent().parent().hide();
			}
		});
		
		$("select[name='with_lodging']").change(function(evt){
			if(evt.target.value == "0")
			{
				$("span#other").parent().parent().show();
			}
			else
			{
				$("span#other").parent().parent().hide();
			}
		});
		
		$("select[name='without_lodging']").change(function(evt){
			if(evt.target.value == "0")
			{
				$("span#other").parent().parent().show();
			}
			else
			{
				$("span#other").parent().parent().hide();
			}
		});
		
		$("select[name='type_of_room_select_1']").change(function(evt){
			if($("select[name='type_of_room_select_1']").val() != "095" && $("select[name='type_of_room_select_1']").val() != "096" && $("select[name='type_of_room_select_1']").val() != "099" && $("select[name='type_of_room_select_1']").val() != "100")
			{
				$("span#renovated_room").parent().parent().show();
			}
			else
			{
				$("span#renovated_room").parent().parent().hide();
			}
		});
		
		$("input[name='_mend_number_of_children_1']").change(function(evt){
			if(evt.target.value > 0)
			{
				$("span#age_of_children_1").parent().parent().show();
			}
			else
			{
				$("span#age_of_children_1").parent().parent().hide();
			}
		});
		
		
		$(".datepicker").datepicker({
			minDate:0
		});
		$(".datetimebox").datetimebox({
			minDate:-1
		});
		$(".datetimebox").change(function(){
			$("div#ui-datepicker-div").hide();
			if($("input[name='departure_billing_1']").parent().parent().css("display") != "none")
			{
				calculateDateDifference();
			}
		});
		$(".datepicker").change(function(){
			calculateDateDifference();
		});
		function calculateDateDifference()
		{
			if($("input[name='departure_billing_1']").datepicker("getDate") == null || $("input[name='_mend_arrival_billing_1']").val() == "")
			{
				return;
			}
			else
			{
				var year = $("input[name='_mend_arrival_billing_1']").val().substr(6,4);
				var month = $("input[name='_mend_arrival_billing_1']").val().substr(3,2);
				var day = $("input[name='_mend_arrival_billing_1']").val().substr(0,2);
				var dep = new Date($("input[name='departure_billing_1']").datepicker("getDate"));
				var arr = new Date(year,month-1,day);
				var res = Math.ceil(dep.getTime()-arr.getTime())/(1000*60*60*24);
				if(res < 0)
				{
					alert("Votre date de départ doit être après votre date d'arrivée.					");
				}
				else
				{
					currentArrival = $("input[name='_mend_arrival_billing_1']").val();
					currentDeparture = $("input[name='departure_billing_1']").val();
					$("span#show_number_of_nights").text(res);
				}
				$("input[name='_mend_arrival_billing_1']").val(currentArrival);
				$("input[name='departure_billing_1']").val(currentDeparture);
			}
		}
		
				$(window).resize(
		function()
		{
						
			fixedBackgroundImg.height("auto");
			fixedBackgroundImg.width($(window).width());
			if(fixedBackgroundImg.height() < $(window).height())
			{
				fixedBackgroundImg.width("auto");
				fixedBackgroundImg.height($(window).height());
			}
					
		}) // end window resize event
		
				$("div.group").each(function(){
			var child = $("div.child",this);
			var thisH3 = $("h3 a",this);
			if(thisH3.attr("class") != "centre_de_therapies_naturelles")
			{
				child.hide();
			} // end if
			else
			{
				child.hide();
				child.show();
			} // end else
			if(child.attr("class") != undefined)
			{
				thisH3.click(function(evt){
					evt.preventDefault();
					$("div#leftMenu > div.group > div.child").each(function(){
						if($(this).css("display") == "block")
						{
							$(this).hide("slow");
						}
					}) // end each
					$(this).closest("div.group").find("div.child").show("slow");
				}) // end click event
			} // end if
		}) // end each
	
	
	
	var header_images_roll_pics = new Array();
	var header_images_roll_current = 1;
	var header_images_roll_next;
	var header_images_roll_totalPics = 0;
	var header_images_roll_first = true;
	$("div#gallery_header_images_roll img").each(function(){
		header_images_roll_pics.push($(this));
		if(header_images_roll_first == false){
			$(this).hide();
		}
		header_images_roll_first = false;
		header_images_roll_totalPics++;
	}); // end each
	$.fjTimer({
		interval: 5000,
		repeat: true,
		tick: function(counter, timerId)
		{
			if(header_images_roll_current < header_images_roll_totalPics)
			{
				header_images_roll_next = header_images_roll_current+1;
			}
			else
			{
				header_images_roll_next = 1;
			}
			header_images_roll_pics[header_images_roll_current-1].fadeOut(2000);
			header_images_roll_pics[header_images_roll_next-1].fadeIn(2000);
			header_images_roll_current = header_images_roll_next;
		}
	}); // end fjTimer
	} // end ready anonymous function
); // end ready event

