//Chosen

$(".chzn-select:not(#in_hotel)").chosen();

	// check availability
	var selectedhotel;
$(".chzn-select#in_hotel").chosen().change(function(e) {
		if ($(this).val() == "default") {
			$("#checkavailability").attr('disabled', true);
		} else {
			$("#checkavailability").attr('disabled', false);
			selectedhotel = $(this).val();
		}
	});
	
	$("#checkavailability").click(function() {
		switch (selectedhotel) {
			case "twobridges":
				var hotel = 'WWtwo';
				break;
			case "bedford":
				var hotel = 'WWbed';
				break;
		}
		// sort out the day/month etc.
		//02/09/2010
		var bits = $("#in_arrival").val().split('/');
		var day = bits[0];
		var month = bits[1];
		var year = bits[2];
		var nights = $("#in_nights").val();
		var rooms = $("#in_rooms").val();
		
		checkavailability_window=window.open('https://portals.uk.rezlynx.net/wwpportal/wfrmpakquery.aspx?SiteID='+hotel.toUpperCase()+'&arrdate='+day+'/'+month+'/'+year+'&non='+nights+'&norooms='+rooms,'Availability','height=800,width=1000,scrollbars=1,resizable=1');

		//document.location = 'https://portals.uk.rezlynx.net/'+hotel+'PPortal/secure/wfrmPakQueryResults.aspx?prop='+hotel.toUpperCase()+'&arrday='+day+'&arrmon='+month+'/'+year+'&non='+nights+'&ad='+adults+'&chl='+children+'&inf=0';
	});

//Fade

function slideSwitch() {
    var $active = $('#slideshow img.active');

    if ( $active.length == 0 ) $active = $('#slideshow img:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow img:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 6000 );
});









