// this function will automatically change the form action based on the property selection
// so that the page forwards to the correct booking engine URL
function setProperty(){

	var propertyVal = document.getElementById('resv_property').value;
	
	switch (propertyVal){
		case 'TCI': propertyVal = 'tci';
								break;
		case 'RBI': propertyVal = 'rbi';
								break;
		case 'SCR': propertyVal = 'scripps';
								break;
		case 'SUR': propertyVal = 'surf';
								break;
	}
	
	document.reservation.action = "https://reservations.jcresorts.com/"+propertyVal+"/availability.asp"
	
}
var x = jQuery.noConflict();
x(document).ready(function(){
	x('#resv_property').sSelect();
	x('#resv_adults').sSelect();
	x('#resv_children').sSelect();
	
	//datepicker
	x("#resv_arrive").datepicker({
		showOn: "button",
		buttonText: '',
		//buttonImage: "/wp-content/themes/SSR/images/res-bar/cal_icon.gif",
		buttonImageOnly: false,
		minDate: 0
	});
	x("#resv_leave").datepicker({
		showOn: "button",
		buttonText: '',
		//buttonImage: "/wp-content/themes/SSR/images/res-bar/cal_icon.gif",
		buttonImageOnly: false,
		minDate: 0
	});
	x("#resv_arrive").change(function() {
    test = x(this).datepicker('getDate');
    testm = new Date(test.getTime());
    testm.setDate(testm.getDate() + 1);
    x("#resv_leave").datepicker("option", "minDate", testm);
	 x("#resv_arrive").datepicker("option", "altField", '#resv_leave' );
	 x("#resv_leave").datepicker("option", "altField", testm );
	});
});
function checkAvailability()
{
  document.reservation.submit();
}
