window.addEvent('load', function (){

	// Window Resize for Flash
	// -----------------------
	if (window.getSize().x) {
		windowheight = window.getSize().y;
		windowwidth = window.getSize().x;
		
		if ($('meet-alma') != null)
			scalediv = $('meet-alma').getSize().y;
		newheight = windowheight - 145;

		if ($('meet-alma') != null)
			$('meet-alma').setStyle('height', (Math.round(newheight)));

		window.addEvent('resize', function(newheight){
			windowheight = window.getSize().y;
			windowwidth = window.getSize().x;
			if ($('meet-alma') != null) {
				scalediv = $('meet-alma').getSize().y;
				newheight = windowheight;
				$('meet-alma').setStyle('height', newheight);
			}
		});
	}

	// Reservation Drop-Down
	// ---------------------

	if($('btn-book')) {
		$('btn-book').addEvent('click', function(){
			var form = $('book-reservation');
			var content = ($('content') == null)?$('meet-alma'):$('content');
			var wrap = $('content-wrap');

			if (form.getStyle('visibility') == 'hidden') {
				form.setStyle('visibility','visible');
				if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('8.0')) == -1) {
					content.setStyle('z-index', '-1');
					if (wrap != null)
						wrap.setStyle('z-index', '-2');
				}
			}
		});
	}

	$$('#close-form a').addEvent('click', function(){
		var form = $('book-reservation');
		var content = ($('content') == null)?$('meet-alma'):$('content');
		var wrap = $('content-wrap');
		form.setStyle('visibility','hidden');
		if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('8.0')) == -1) {
			content.setStyle('z-index', '0');
			if (wrap != null)
				wrap.setStyle('z-index', '0');
		}
	});

	// Create Calendar
	// ---------------
	
	function dateToFormat( date )
	{
		var day = date.getDate();
		if( day < 10 ){
			day = "0" + day;
		}
		
		var month = date.getMonth()+1;
		if( month < 10 ){
			month = "0" + month;
		}
		
		return month + "/" + day + "/" + date.getFullYear();
	}
	
	
	if( typeof(DatePicker) != "undefined" ){
	
	var outDate = new DatePicker('#textdateout', { 
		pickerClass: 'datepicker_vista', 
		yearPicker: false,
		toggleElements: '#dateout_selector',
		format: 'm/d/Y',
		inputOutputFormat: 'm/d/Y',
		minDate: { date: $('textdateout').value, format: 'm/d/Y' }
	});
	

	var inDate = new DatePicker('#textdatein', { 
		pickerClass: 'datepicker_vista', 
		yearPicker: false,
		toggleElements: '#datein_selector',
		format: 'm/d/Y',
		inputOutputFormat: 'm/d/Y',
		minDate: { date: $('textdatein').value, format: 'm/d/Y' },
		onSelect: function( selectedDate ){
		
			// add a day (in millisecs)
			var selectedDateNew = new Date( selectedDate.getTime() + (3600*24*1000) );
			
			$('textdateout').value = dateToFormat( selectedDateNew );
			$('textdateout').getNext().value = $('textdateout').value;
			
			outDate.initialize('#textdateout', { minDate: selectedDate } );
		}
	});
	
	}
});

