//hs.graphicsDir = '/images/highslide/';
hs.showCredits = false;
hs.dimmingOpacity = 0.75;
hs.align = 'center';
hs.captionEval = 'this.a.title';
hs.captionOverlay.position = 'below';
hs.transitions = ['expand', 'crossfade'];

// Add the slideshow controller
hs.addSlideshow({
	slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		className: 'text-controls',
		opacity: '0.8',
		position: 'bottom center',
		offsetX: '0',
		offsetY: '40',
		hideOnMouseOut: false
	},
	thumbstrip: {
		mode: 'horizontal',
		position: 'bottom center',
		relativeTo: 'viewport'
	}
});

hs.addSlideshow({
	slideshowGroup: 'group2',
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		className: 'text-controls',
		opacity: '0.8',
		position: 'bottom center',
		offsetX: '0',
		offsetY: '40',
		hideOnMouseOut: false
	},
	thumbstrip: {
		mode: 'horizontal',
		position: 'bottom center',
		relativeTo: 'viewport'
	}
});



	
function updateAvailabilityTable() {
	$month = jQuery('#month').val();
	$nights = jQuery('#nights').val();
	$startday = jQuery('#startday').val();
	$propref = jQuery('#propref').val();
	jQuery.get('/includes/custom/getAvailableBreaks.php', {propref: $propref, month: $month, nights: $nights, startday: $startday }, function(data) {
		jQuery('#avail-weeks-rows').html(data);
		jQuery('.booknow').click(function() {
			if (jQuery('#adults_select').val() == '') {
				alert('Please select the number of adults, children and infants coming');
			} else if ((parseInt(jQuery('#adults_select').val()) + parseInt(jQuery('#children_select').val())) > jQuery('#maxpeople').val()) {
				alert('You\'ve selected more people than the property accommodates');
			} else {
				jQuery('#startdatehid').attr('value', ($(this).attr('data-start')));
				jQuery('#todatehid').attr('value', ($(this).attr('data-end')));
				jQuery('#adults').val(jQuery('#adults_select').val());
				jQuery('#children').val(jQuery('#children_select').val());
				jQuery('#infants').val(jQuery('#infants_select').val());
				jQuery('#numpets').val(jQuery('#pets_select').val());
				jQuery('#availform').submit();
			}
		});
		jQuery('.booknow').hover( function() {
			jQuery(this).children('.book-button').html('Book Now<br /><span>Click Here</span>');
			jQuery('#booking-summary').html('<table><tr><td class="label"><strong>Arrival Date:</strong></td><td> <span id="arrivaldate_disp">07.05.2011</span></td></tr><tr><td class="label"><strong>Departure Date:</strong></td><td> <span id="departuredate_disp">14.05.2011</span></td></tr><tr><td class="label"><strong>Basic Price:</strong></td><td> &pound;<span id="basicprice_disp"></span></td></tr><tr><td class="label"><strong>Booking Fee:</strong></td><td> &pound;<span id="bookingfee_disp"></span></td></tr><tr><td class="label">&nbsp;</td><td>&nbsp;</td></tr><tr><td class="label"><strong>Total Price:</strong></td><td class="total-price-td"> &pound;<span id="totalprice_disp"></span></td></tr></table>');
			jQuery('#arrivaldate_disp').html(jQuery(this).attr('data-start'));
			jQuery('#departuredate_disp').html(jQuery(this).attr('data-end'));
			jQuery('#basicprice_disp').html(jQuery(this).attr('data-basicprice'));
			jQuery('#bookingfee_disp').html(jQuery(this).attr('data-bookingfee'));
			jQuery('#totalprice_disp').html(jQuery(this).attr('data-totalprice'));
			jQuery('#booking-summary').show();
		}, function() {
			jQuery(this).children('.book-button').html('Book This<br /><span>Click Here</span>');
			jQuery('#booking-summary').html('<span class="booking-summary-inner">Please select your holiday below by hovering over your desired dates.</span>');
		});
		
		jQuery('.unAvailSB,.unAvailEnq').hover( function() {
			jQuery('#booking-summary').html('<span class="booking-summary-inner" style="padding-top: 5px;">There are 3 and 4 night breaks available.<br /><br />Please click on this box to make your booking enquiry.</span>');
		}, function() {
			jQuery('#booking-summary').html('<span class="booking-summary-inner">Please select your holiday below by hovering over your desired dates.</span>');
		});
		
		jQuery('.unAvailCall').hover( function() {
			jQuery('#booking-summary').html('<table><tr><td class="label"><strong>Arrival Date:</strong></td><td> <span id="arrivaldate_disp">07.05.2011</span></td></tr><tr><td class="label"><strong>Departure Date:</strong></td><td> <span id="departuredate_disp">14.05.2011</span></td></tr><tr><td class="label"><strong>Basic Price:</strong></td><td> &pound;<span id="basicprice_disp"></span></td></tr><tr><td class="label"><strong>Booking Fee:</strong></td><td> &pound;<span id="bookingfee_disp"></span></td></tr><tr><td class="label">&nbsp;</td><td>&nbsp;</td></tr><tr><td class="label"><strong>Total Price:</strong></td><td class="total-price-td"> &pound;<span id="totalprice_disp"></span></td></tr></table>');
			jQuery('#arrivaldate_disp').html(jQuery(this).attr('data-start'));
			jQuery('#departuredate_disp').html(jQuery(this).attr('data-end'));
			jQuery('#basicprice_disp').html(jQuery(this).attr('data-basicprice'));
			jQuery('#bookingfee_disp').html(jQuery(this).attr('data-bookingfee'));
			jQuery('#totalprice_disp').html(jQuery(this).attr('data-totalprice'));
		}, function() {
			jQuery('#booking-summary').html('<span class="booking-summary-inner">Please select your holiday below by hovering over your desired dates.</span>');
		});
		
		jQuery('.unAvailSB').click( function() {			
			if ( jQuery(this).hasClass('deactive') ) {
				return false;
			} else {
				jQuery('#short-break-block').remove();
				jQuery('.unAvailSB .book-button-sb').removeClass('deactive');
				jQuery('.unAvailSB').removeClass('deactive');
				jQuery('.unAvailSB .book-button-sb').html('Short Breaks<br /><span>Click Here</span>');
				jQuery('.book-button-sb', this).html('Short Breaks');
				jQuery('.book-button-sb', this).addClass('deactive');
				jQuery(this).addClass('deactive');
				jQuery(this).after('<div id="short-break-block"><p><strong>Click on your preferred dates below, or <a href="http://www.freedomholidayhomes.co.uk/contact-us">Contact Us</a> if you can\'t find them.</strong><br />Short breaks are available for these dates: (3 and 4 nights shown below)</p><div id="sb-miniblock"></div><a id="short-break-block-close">CLOSE&nbsp;&nbsp;X&nbsp;</a></div>');
				var $weekdate = jQuery(this).attr('data-start');
				jQuery.get('/includes/custom/shortBreakBlock.php', {propref: $propref, month: $month, nights: $nights, startday: $startday, weekdate: $weekdate }, function(sbdata) {
				jQuery('#sb-miniblock').html(sbdata);
				});
			}
		});
		
		jQuery("#property_calendar").delegate("#short-break-block-close", "click", function(){
			jQuery('.unAvailSB .book-button-sb').removeClass('deactive');
			jQuery('.unAvailSB').removeClass('deactive');
			jQuery('.unAvailSB .book-button-sb').html('Short Breaks<br /><span>Click Here</span>');
			jQuery('#short-break-block').remove();
		});
		
	});
}




jQuery(document).ready(function() {	
	
	/***** Availability Selector *****/
	jQuery('#nights').change(function() {
		updateAvailabilityTable();
	});
	
	jQuery('#month').change(function() {
		updateAvailabilityTable();
	});
	
	jQuery('#startday').change(function() {
		updateAvailabilityTable();
	});
	
	updateAvailabilityTable();

});




