Event.observe(window,'load',function(){
	if($('localisation')){
		localisation();
	}
if($('reserver')){
		$$('input.calendrier').each( function(e){
			Event.observe(e,'focus',function(){
				date_split1 = $F('date_arrivee').split('/');
				var date_test1 = date_split1[2]+date_split1[1]+date_split1[0]
				date_split2 = $F('date_depart').split('/');
				var date_test2 = date_split2[2]+date_split2[1]+date_split2[0]
			
				if((parseInt(date_test2)-parseInt(date_test1))>0){
					$('cont_nb_nuit').show();
					var date1 = $F('date_arrivee');
					var date2 = $F('date_depart');
					var debut = temps(date1.split("/"));
					var fin = temps(date2.split("/"));
					var nb = (fin - debut) / (1000 * 60 * 60 * 24); // + " jours";
					if(Math.round(nb)<2)
					{
						$('nb_nuit').update('Soit '+Math.round(nb)+' nuit  &nbsp;('+Math.round(nb)+' night)');
					}
					else
					{
						$('nb_nuit').update('Soit '+Math.round(nb)+' nuits  &nbsp;('+Math.round(nb)+' nights)');
					}
				}else{
					$('nb_nuit').update('Erreur');
					//$('cont_nb_nuit').hide();
				}
			});									  
		});
	}
	
	if($('liste_offre')){
		$$('.a_detail').each( function(e){
			Event.observe(e,'click',function(){
				if(e.up(1).next().style.display == 'none'){
					new Effect.BlindDown(e.up(1).next(),{duration:0.5, afterFinish:
						function(){
							e.update('Fermer');	
						}
					});
				}else{
					new Effect.BlindUp(e.up(1).next(),{duration:0.5, afterFinish:
						function(){
							e.update('( En savoir plus )');	
						}
					});
				}
			});									  
		});
	}
});
Event.observe(window,'unload',function(){
	if($('localisation') || $('guide')){
		GUnload();
	}
});
var localisation = function() {
	var map = null;
	map = new GMap2($("map"));
	map.addControl(new GMapTypeControl());
	map.addControl(new GSmallMapControl());
	var baseIcon = new GIcon(G_DEFAULT_ICON);
	baseIcon.shadow = "images/commun/ombre_marker.png";
	baseIcon.shadowSize = new GSize(27, 27);
	baseIcon.iconSize = new GSize(16, 27);
	baseIcon.iconAnchor = new GPoint(8, 27);
	baseIcon.infoWindowAnchor = new GPoint(0, 0);
	var IconType = new GIcon(baseIcon);
	IconType.image = "images/commun/marker.png";
	markerOptions = {icon:IconType,clickable:false};
	var point = new GLatLng(tab_point.latitude,tab_point.longitude);
	var marker = new GMarker(point, markerOptions);
	map.setCenter(point, 17);
	map.addOverlay(marker);
};
function temps(date){
	var d = new Date(date[2], date[1] - 1, date[0]);
	return d.getTime();
}
