HMBook = {
	
	booking_id:169,
	
	init:function(){
		$( 'form.banner input:text' ).datepicker
		(
			{
				'showOn':'both',
				'buttonImage':'/sites/miramar-bournemouth.com/themes/hotelmiramar/img/icon_calendar.gif',
				'buttonImageOnly':true,
				'minDate':new Date(),
				'dateFormat': 'd MM yy'
			}
		);
	},
	
	Book:function(){
		var date_arrive = $( 'form.banner input:text[name=date_arrive]' ).datepicker( 'getDate' );
		var date_depart = $( 'form.banner input:text[name=date_depart]' ).datepicker( 'getDate' );

		if( date_arrive == null || date_depart == null ){
			alert( 'You must choose an arrival date and a departure date' );
		} else {
			if( date_arrive >= date_depart ){
				alert( 'Your arrival date must be before your departure date' );
			} else {
				// Calculate number of nights
				var nights = Math.floor( ( date_depart - date_arrive ) / ( 1000 * 60 * 60 * 24 ) );
				var url = 'http://www.welcome-online.net/connect.asp?id=' + this.booking_id + '&mode=dates&arrival_day=' + date_arrive.getDate() + '&arrival_month=' + (date_arrive.getMonth() + 1) + '&arrival_year=' +  date_arrive.getFullYear() +  '&no_of_nights=' + nights;
				document.location.href = url;
			}
		}
	},
	GoToBooking:function(){
		var url = 'http://www.welcome-online.net/connect.asp?id=' + this.booking_id + '&mode=dates';
		document.location.href = url;
	},
	GoToEnquiry:function(){
		var url = '\contact.html';
		document.location.href = url;
	}
	
}
$(document).ready
	(
		HMBook.init
	);

