$(document).ready(function() {
	
	$("a#inline").fancybox();
	
});

function resize_map()
{
	jQuery( '#gmap-spots div div div div div div').css({'height': '120px !important', 'max-height': '120px !important' });
}

( 
	function ( $, document, undefined )
	{
		/* Extend the format for date returns on DateInput plugin */
		
		$.extend(DateInput.DEFAULT_OPTS, {
		  stringToDate: function(string) {
		    var matches;
		    if (matches = string.match(/^(\d{4,4})-(\d{2,2})-(\d{2,2})$/)) {
		      return new Date(matches[1], matches[2] - 1, matches[3]);
		    } else {
		      return null;
		    };
		  },

		  dateToString: function(date) {
		    var month = (date.getMonth() + 1).toString();
		    var dom = date.getDate().toString();
		    if (month.length == 1) month = "0" + month;
		    if (dom.length == 1) dom = "0" + dom;
		    //return date.getFullYear() + "-" + month + "-" + dom;
			return month + '/' + dom + '/' + date.getFullYear();
		  }
		});
		
		$(document).ready( 
			
			function()
			{
				
				/* Reservations Date Pickers */
				
				$('#reservations-check-in, #reservations-check-out').date_input();
				
				/* Sidebar Rotating Specials */
				if ( $('.rotating-specials').length )
				{
					$('.rotating-specials').cycle(
						{
							timeout: 6000
						}
					);
				}
				
				/* Sidebar Rotating Fall In Love */
				if ( $('#fall-in-love').length )
				{
					$('#fall-in-love').cycle(
						{
							timeout: 6000
						}
					);
				}
				
				/* Home Page Background Rotaing Images */
				
				if ( $('#background-cycle').length )
				{
					$('#background-cycle').cycle({ timeout: 8000, speed: 2500 });
				}
				
				/* Accommodations Popup */
				
				if ( $('a.accommodations-popup').length )
				{
					$('a.accommodations-popup').facebox(
						{
							opacity: 0.8,
							loadingImage: CI_THEME + '_assets/images/loading.gif',
							closeImage: CI_THEME + '_assets/images/facebox-close.png'
						}
					);
				}
				
				
				
				$('#gmap-spots').jMapping(
					{
						category_icon_options: function( category )
						{
							if ( 'the_hotel' == category )
							{
								return new google.maps.MarkerImage( 'http://chart.apis.google.com/chart?chst=d_map_xpin_icon&chld=pin_star|home|00FFFF|FF0000' );
							}
							else
							{
								return {color: '#7CDF65'};
							}
						}
					}
				);
				
				if ( $('#gmap-spots').length )
				{
					$('#map-side-bar a.map-link:first').click();
				}
				
				$('a.map-link').bind(
					'click',
					
					function()
					{
						var t = setTimeout ( 'resize_map()', 400 );
					}
				);
				
				/* Gallerys */
				
				if ( $('div.gallery dl.gallery-item').length )
				{
					$('div.gallery').children('dl.gallery-item').children('dt').children('a').lightBox(
						{
							imageLoading: CI_THEME + '_assets/images/lightbox-ico-loading.gif',
							imageBtnClose: CI_THEME + '_assets/images/lightbox-btn-close.gif',
							imageBtnPrev: CI_THEME + '_assets/images/lightbox-btn-prev.gif',
							imageBtnNext: CI_THEME + '_assets/images/lightbox-btn-next.gif',
							imageBlank: CI_THEME + '_assets/images/lightbox-blank.gif'
						}
					);
				}
			}
			
		)
	}
) ( jQuery, document );
