$(document).ready(function() {
					
	if(undefined===window.hotelPosition){
		hotelPosition = document.getElementById('HotelCode').selectedIndex;	
	} 	
	
	$('ul#portfolio').animatedinnerfade({
		speed: 'normal',
		timeout: 10000,
		type: 'sequence',
		containerheight: '352px',
		containerwidth: '692px',
		animationSpeed: 25000,
		animationtype: 'fade',
	    controlBox: 'show',
	    controlBoxClass: 'mycontrolboxclass',
	    controlButtonsPath: 'images/slideshow',
		bgFrame: 'none',
		displayTitle: 'yes'
	});
	$("#ArrivalD").datepicker({     
		beforeShow: customRangeArrival,
		showOn: "both",     
		changeMonth: false, 
		changeYear: false, 
		mandatory: true,		
	    closeAtTop: false,		
		showAnim: "fadeIn",
		buttonImage: "/images/calendar/calendarIcon.gif",     
		buttonImageOnly: true,
	    onClose: calendarFilter
  		}).addClass("embed");
	$("#DepartureD").datepicker({     
		beforeShow: customRangeDepart,
		onClose: calendarFilter,
		showOn: "both",     
		changeMonth: false, 
		changeYear: false, 
		mandatory: true,		
	    closeAtTop: false,		
		showAnim: "fadeIn",
		buttonImage: "/images/calendar/calendarIcon.gif",     
		buttonImageOnly: true }).addClass("embed");
	$(".imageSlider .jCarouselLite").jCarouselLite({
		btnNext: ".imageSlider .next",
		btnPrev: ".imageSlider .prev",
		visible: 1,
		speed: 500,
		start: 0,
		easing: "easeinout",
		btnGo:
			[".externalControl .0", ".externalControl .1", ".externalControl .2",
			".externalControl .3", ".externalControl .4", ".externalControl .5", ".externalControl .6", ".externalControl .7", ".externalControl .8", ".externalControl .9"]
	});
	
	if(undefined===window.hotelPosition){
		hotelPosition = document.getElementById('HotelCode').selectedIndex;	
	} 	
		
	  setHotelPositionExact(hotelPosition);
	  toggleChildrenAges();
	
});

function setHotelPositionExact(position) {
	if (position > 0) { position = position + 1; }
	var selbox = document.getElementById('HotelCode');
	selbox.selectedIndex = position;
	postion = position+'';
	document.getElementById('button'+position).click();
}

function customRangeArrival(input) { 
    return {minDate: 2,
		maxDate: '+2y',
		defaultDate: +7}; 
} 
function calendarFilter(input) { 
	//alert (input);
	hotelPosition = document.getElementById('HotelCode').selectedIndex;	
	
    //alert ($("#ArrivalD").datepicker.formatDate('dd', input)); 
    testdate = jQuery.datepicker.formatDate('m/d/yy',input);
	m = parseInt(testdate.substring(0,2));
	d = parseInt(testdate.substring(3,5));
	y = (testdate.substring(6,10));
//	if (hotelPosition == 3 || hotelPosition == 7 || hotelPosition == 9) {
	//alert (y);
	//alert (d);
	//alert (m);
	//if (y==9) {
//		if (m<11) {
//			if ( (d>0 && d<32) ) {
//				alert ("You must select an arrival date starting on or after November 1, 2009 to book this resort.");
//			}
//		}
//	}
//	}

} 
function customRangeDepart(input) {
	twoDays = (addTwo($.datepicker.formatDate( "m/d/yy", $("#ArrivalD").datepicker("getDate") )));
	m = (twoDays.substring(0,2));
	d = (twoDays.substring(3,5));
	y = (twoDays.substring(6,10));
	var date = new Date(y, m - 1, d);
    return {
	  maxDate: '+2y',
	  defaultDate: date };
  } 
  
function flashPutHref()
	{
	}