$(document).ready(function() {					   
	resverBar();
});

//ReservBar
function resverBar() {  
	function customRange(a) {  
		var b = new Date();  
		var c = new Date(b.getFullYear(), b.getMonth(), b.getDate());  
		if (a.id == 'DropoffDate') {  
			if ($('.pUpDate').datepicker('getDate') != null) {  
				c = $('.pUpDate').datepicker('getDate');  
				c.setDate(c.getDate()+1);
			}  
		}  
		return {  
			minDate: c 
		}  
	}
	
	$( "#PickupDate" ).datepicker({	
		altField: '#PickupWeekDate',
		altFormat: 'DD',
		changeMonth: true,
		changeYear: true, 
		beforeShow: customRange,
		maxDate: '+1y +8m +1d'
	});
	
	$( "#DropoffDate" ).datepicker({	
		altField: '#DropoffWeekDate',
		altFormat: 'DD',
		changeMonth: true,
		changeYear: true, 
		beforeShow: customRange,
		maxDate: '+1y +8m +1d'
	});

	var today = new Date();
    var curDate = (today.getMonth() + 1) + '/' + today.getDate() + '/' + today.getFullYear();
	var tomorrow = new Date();
	tomorrow.setTime(tomorrow.getTime(  ) + (1000*3600*24));
    var tmrDate = (tomorrow.getMonth() + 1) + '/' + tomorrow.getDate() + '/' + tomorrow.getFullYear();

	$("#PickupDate").val(curDate);
	$("#DropoffDate").val(tmrDate);
/**/
	$("#Adultspax").focus(function(){
		$("#adultsNum").fadeIn('fast');
		$(".adultsnumber").hover(
		  function () {
			$(this).css("background", "#F3BF5F");
		  },
		  function () {
			$(this).css("background", "");
		  }
		);
			$(".adultsnumber").click(function(event) {
			  event.preventDefault();
				$("#Adultspax").val($(this).text());
			});
	});
	$("#Adultspax").blur(function(){
		$("#adultsNum").fadeOut('fast');
	});
	
	$("#Childpax").focus(function(){
		$("#childNum").fadeIn('fast');
		$(".childsnumber").hover(
		  function () {
			$(this).css("background", "#F3BF5F");
		  },
		  function () {
			$(this).css("background", "");
		  }
		);
		  $(".childsnumber").click(function(event) {
			event.preventDefault();
			$("#Childpax").val($(this).text());
		  });
	});
	$("#Childpax").blur(function(){
		$("#childNum").fadeOut('fast');
	});
	//Dont hover in IE6/
	if (!($.browser.msie && parseInt($.browser.version) < 7)) { 
		$("#reservSubmitButton").hover(
			  function () {
				$(this).css("background", "url("+_tplDir+"/images/"+_lang+"/reserv_bar/search.gif) bottom");
			  },
			  function () {
				$(this).css("background", "url("+_tplDir+"/images/"+_lang+"/reserv_bar/search.gif) top");
			  }
		);
	}
	//
	$("#reservSubmitButton").click(function() {
	  _bookNowNew();
	});
}
