$(document).ready(function() {
	$('.home #masthead').cycle({fx: 'fade', speed: 2000 });

	$('.photo .gallery').before('<p class="slidecontrol">&laquo; <a href="#previous%20photo" class="prev">prev</a> | <a href="#next%20photo" class="next">next</a> &raquo;</p>');
	$('.photo .gallery').cycle({fx: 'fade', prev: '.prev', next: '.next', timeout: 0, speed: 300 });
	
	$('#availability').html('<form action="https://mycrs.innpoints.com/book/book/Wizard?xtra=false" method="post" title="Reservations" target="TB_iframeContent"> \n\
		<div> \n\
			<label for="checkinDate">Check-in</label> \n\
			<br /><input type="text" value="" name="checkinDate" id="checkinDate" /> <a href="#"><img src="images/availability-cal.gif" alt="calendar date selector" width="16" height="16" border="0" id="incalimg" /></a> \n\
 \n\
			<br /><label for="checkinDate">Check-out</label> \n\
			<br /><input type="text" value="" name="checkoutDate" id="checkoutDate" /> <a href="#"><img src="images/availability-cal.gif" alt="calendar date selector" width="16" height="16" border="0" id="outcalimg" /></a> \n\
		</div> \n\
		<div> \n\
			<label for="numAdults">Guests</label> \n\
			<br /><select name="numAdults" id="numAdults"> 		 \n\
				<option>1</option> \n\
				<option>2</option> \n\
				<option>3</option> \n\
				<option>4</option> \n\
				<option>5</option> \n\
			</select> <span>adult(s) + children</span>			 \n\
		</div> \n\
		<div> \n\
			<input type="submit" name="submit" id="submit" value="check availability &raquo;" class="thickbox" title="Coachman Inn Room Availability and Reservations" alt="zblank.html?keepThis=true&amp;TB_iframe=true&amp;height=450&amp;width=750" /> \n\
		</div>	 \n\
		<input type="hidden" id="numChildren" name="numChildren" value="0" />		 \n\
		<input type="hidden" name="channelCode" value="INTERNET" /> \n\
		<input type="hidden" name="subSourceCode" value="" /> \n\
		<input type="hidden" name="restrictToRoomTypes" value="" /> \n\
		<input type="hidden" name="restrictToRatePlans" value="" /> \n\
		<input type="hidden" name="xtra" value="false" /> \n\
		<input type="hidden" name="numRooms" value="1" /> \n\
       	<input type="hidden" name="resCode"          value="" /> \n\
        <input type="hidden" name="roomTypeCode"     value="" /> \n\
        <input type="hidden" name="ratePlanCode"     value="" /> \n\
        <input type="hidden" name="extraItems"       value="" /> \n\
		<input type="hidden" name="firstName"         value="" /> \n\
		<input type="hidden" name="lastName"          value="" /> \n\
		<input type="hidden" name="address1"          value="" /> \n\
		<input type="hidden" name="address2"          value="" /> \n\
		<input type="hidden" name="countryName"       value="" /> \n\
		<input type="hidden" name="cityName"          value="" /> \n\
		<input type="hidden" name="stateName"         value="" /> \n\
		<input type="hidden" name="postalCode"        value="" /> \n\
		<input type="hidden" name="areaCode"          value="" /> \n\
		<input type="hidden" name="phone"             value="" /> \n\
		<input type="hidden" name="phoneExtension"    value="" /> \n\
		<input type="hidden" name="email"             value="" /> \n\
		<input type="hidden" name="emailConfirmation" value="" /> \n\
		<input type="hidden" name="agencyCode"        value="" /> \n\
		<input type="hidden" name="cardType"         value="" /> \n\
    	<input type="hidden" name="cardNumber"       value="" /> \n\
        <input type="hidden" name="expirationMonth"  value="0" /> \n\
        <input type="hidden" name="expirationYear"   value="0" /> \n\
		<input type="hidden" name="cardOwner"        value="" /> \n\
		<input type="hidden" name="_page" value="0" /> \n\
		<input type="hidden" id="target" name="_target1" value="" /> \n\
		<input type="hidden" name="cancelField" value="" /> \n\
		<input type="hidden" name="hotelCode" value="2504" /> \n\
	</form>');
	
	
	var makeDate = function(offset, dt) {
		if (dt) {
			var today = new Date(dt);
		} else {
			var today = new Date();
		}
		today.setDate(today.getDate()+offset); 
		var month = today.getMonth()+1;
		var year = today.getYear();
		var day = today.getDate();
		if(day<10) day = "0" + day;
		if(month<10) month= "0" + month;
		if(year<1000) year+=1900;
		return month +'/'+day+'/'+year;
	}
	
	$('#checkinDate').val(makeDate(0))
	$('#checkoutDate').val(makeDate(1))
	
	$('#checkinDate').change(function() {
		if ($('#checkinDate').val() > $('#checkoutDate').val()) {
			$('#checkoutDate')
				.val(makeDate(1, $('#checkinDate').val()));
		}
	});

	$('#checkoutDate').change(function() {
		if ($('#checkinDate').val() > $('#checkoutDate').val()) {
			$('#checkinDate')
				.val(makeDate(-1, $('#checkoutDate').val()));
		}
	});

	
	$('#checkinDate').datepicker({ mandatory: true, constrainInput: true, defaultDate: 0 });
	$('#checkoutDate').datepicker({ mandatory: true, constrainInput: true, detaultDate: +1  });
	
	$('#incalimg').click(function() {
		$('#checkinDate').datepicker('show');
		return false;
	});
	
	$('#outcalimg').click(function() {
		$('#checkoutDate').datepicker('show');
		return false;
	});
	
	tb_init('a.thickbox, area.thickbox, input.thickbox');
});

//&amp;keepThis=true&amp;TB_iframe=true&amp;height=450&amp;width=750

