//promo-click
$( document ).ready(
	function()
	{
		var callout_item = $ ( 'div.promotion-area div.callout-item' );
		callout_item.each(
			function(index, item)
			{
				$(item).click(
					function(event)
					{
						console.log(callout_item);
						//window.open( $(item).attr('rel') );
					}
				);
			}
		);
	}
);
//calendar
$( document ).ready(
	function()
	{

 $("form.styled .date").datepicker({
        buttonImage: '/extension/nxc_tigrancholp/design/nxc_tigrancholp/images/calendar-white.png',
        buttonImageOnly: true,
        closeText: 'Close',
        dateFormat: 'MM d, yy',
        minDate: '+0',
        maxDate: '+1Y',
        showAnim: 'slideDown',
        showOn: 'both',
        showButtonPanel: true
    })


		var event_preview = $( '.events-calendar .event-preview' );
		var event_description = $( '.events-calendar .event-description' );
		var event_window = $('.events-calendar a.new_window');
		current_event = -1;
		lastTime = new Date().getTime();
		currentTime = new Date().getTime();
		if( (event_preview.length > 0) & (event_description.length > 0) & (event_preview.length == event_description.length) )
		{
			event_preview.each(
				function(index, item)
				{
					var item_rel = $(item).attr('rel');
					$(item).click(
						function(event)
						{
							if (item_rel != '' )
							{
								window.open( $(item).attr('rel'), $(event_window[index]).attr('target'));
							}
						}
					);
				}
			);
			event_description.each(
				function(index, item)
				{
					var item_rel = $(item).attr('rel');
					$(item).click(
						function(event)
						{
							if (item_rel != '' )
							{
								window.open( $(item).attr('rel'), $(event_window[index]).attr('target'));
							}
						}
					);
				}
			);
			function changeEvent(nextEvent)
			{
				
				currentTime = new Date().getTime();
				nextEvent -= 1;
				if( nextEvent == -1 )
				{
					if( ( currentTime - lastTime ) >= 5000 )
					{
						nextEvent = current_event + 1;
						if( nextEvent >= event_preview.length )
						{
							nextEvent = 0;
						}
					}
					else
					{
						nextEvent = current_event;
					}
				}
				if( current_event != nextEvent )
				{
					if( current_event != 0 )
					{
						$(event_description[current_event]).removeClass('coloredblue');
					}
					if( nextEvent != 0 )
					{
						$(event_description[nextEvent]).addClass('coloredblue');
					}
					$(event_description[current_event]).removeClass('selected');
					$(event_description[nextEvent]).addClass('selected');
					$(event_preview[current_event]).fadeOut(100);
					$(event_preview[nextEvent]).fadeIn(300);
					current_event = nextEvent;
					lastTime = new Date().getTime();
				}
				
			}
			event_description.each(
				function(index, item)
				{
					$(item).mouseenter(
						function(e)
						{
							changeEvent(index+1);
						}
					);
				}
			);
			
			setInterval( function(){changeEvent(0)}, 500 );
		}
	}
);

$( document ).ready(
	function()
	{
		$( '#ksl_resorts' ).change(
			function(e)
			{
				if( $( this ).attr( 'value' ) != "#" )
				{
					window.open( $( this ).attr( 'value' ) );
				}
			}
		);
	}
);

$( document ).ready(
	function()
	{
		var experienceButtonOpen = $( 'div.experience-btn' );
		var experienceButtonClose = $( 'div.close-experience-btn' );
		var experienceContent = $( 'div.experience' );
		var experienceCurrentStatus = false;
		if( experienceButtonOpen.length > 0 )
		{
			$( experienceButtonOpen ).click(
				function(e)
				{
					e.preventDefault();
					experienceCurrentStatus = !experienceCurrentStatus;
					if( experienceCurrentStatus )
					{
						$( experienceContent ).animate( {'left': 0}, 1000 );
					}
					else
					{
						$( experienceContent ).animate( {'left': 1200}, 1000 );
					}
				}
			);
			$( experienceButtonClose ).click(
				function(e)
				{
					e.preventDefault();
					experienceCurrentStatus = false;
					$( experienceContent ).animate( {'left': 1200}, 1000 );
				}
			);
		}
	}
);

//experience content switcher
$( document ).ready(
	function()
	{
		var experienceDescription = $( 'div.exp-media-content' );
		var experienceFirstLevel = $( 'ul.exp-main-menu>li' );
		var experienceSecondLevel = $( 'ul.exp-sub-menu li' );
		var currentFirstLevel = 0;
		var currentSecondLevel = 0;
		$( experienceFirstLevel[0] ).find('ul.exp-sub-menu').fadeIn( 100 );
		if( experienceFirstLevel.length > 0 )
		{
			experienceFirstLevel.each(
				function(indexFirst, item)
				{
					$( item ).click(
						function(e)
						{
							e.preventDefault();
						}
					);
					$( item ).mouseenter(
						function(e)
						{
							//e.preventDefault();
							if( currentFirstLevel != indexFirst )
							{
								$( experienceFirstLevel[currentFirstLevel] ).removeAttr( 'class' );
								$( experienceFirstLevel[currentFirstLevel] ).find('ul.exp-sub-menu').hide();
								$( experienceFirstLevel[indexFirst] ).attr( 'class', 'selected' );
								$( experienceFirstLevel[indexFirst] ).find('ul.exp-sub-menu').show();
								currentFirstLevel = indexFirst;
							}
						}
					);
				}
			);
			experienceSecondLevel.each(
				function(indexSecond, item)
				{
					$( item ).click(
						function(e)
						{
							e.preventDefault();
						}
					);
					$( item ).mouseenter(
						function(e)
						{
							//e.preventDefault();
							if( currentSecondLevel != indexSecond )
							{
								$( experienceDescription ).html("");
								$( 'div.media-switcher' ).hide();
								$( experienceDescription ).load( $( this ).children( 'a' ).attr( 'href' ),
									function()
									{
										
										$( experienceDescription ).show();
										if( $( 'div.exp-media-content div.exp-media div.exp-media-item' ).length > 1 )
										{
											$( 'div.media-switcher' ).show();
										}
										else
										{
											$( 'div.media-switcher' ).hide();
										}
									}
								);
								window.experienceMediaCurrentImage = 0;
								$( experienceSecondLevel[currentSecondLevel] ).removeAttr( 'class' );
								$( experienceSecondLevel[indexSecond] ).attr( 'class', 'selected' );
								currentSecondLevel = indexSecond;
							}
						}
					);
				}
			);
		}
	}
);

//experience media switcher
$( document ).ready(
	function()
	{
		mediaLastTime = 0;
		mediaCurrentTime = new Date().getTime();
		window.experienceMediaCurrentImage = 0;
		var mediaNextButton = $( 'a.switcher.next' );
		var mediaPreviousButton = $( 'a.switcher.previous' );
		if( mediaNextButton.length > 0 )
		{
			function mediaNextFunction( control )
			{
				mediaCurrentTime = new Date().getTime();
				if ( ( (mediaCurrentTime - mediaLastTime) >= 5000 ) || control == 1 )
				{
					var mediaImages = $( 'div.exp-media div.exp-media-item' );
					if( mediaImages.length > 1 )
					{
						$( mediaImages[window.experienceMediaCurrentImage] ).fadeOut( 400 );
						window.experienceMediaCurrentImage++;
						if( window.experienceMediaCurrentImage >= mediaImages.length )
						{
							window.experienceMediaCurrentImage = 0;
						}
						$( mediaImages[window.experienceMediaCurrentImage] ).fadeIn( 400 );
					}
					mediaLastTime = new Date().getTime();
				}
			}
			function mediaPreviousFunction()
			{
				mediaCurrentTime = new Date().getTime();
				
				var mediaImages = $( 'div.exp-media div.exp-media-item' );
				if( mediaImages.length > 1 )
				{
					$( mediaImages[window.experienceMediaCurrentImage] ).fadeOut( 400 );
					window.experienceMediaCurrentImage--;
					if( window.experienceMediaCurrentImage < 0 )
					{
						window.experienceMediaCurrentImage = mediaImages.length - 1;
					}
					$( mediaImages[window.experienceMediaCurrentImage] ).fadeIn( 400 );
				}
				mediaLastTime = new Date().getTime();
			}
			$( mediaNextButton ).click(
				function(event)
				{
					event.preventDefault();
					mediaNextFunction( 1 );
				}
			);
			$( mediaPreviousButton ).click(
				function(event)
				{
					event.preventDefault();
					mediaPreviousFunction();
				}
			);
			setInterval( function(){ mediaNextFunction( 0 ) }, 1000 );
		}
	}
);

//lightbox for spa package
$( document ).ready(
	function()
	{
		var spa_links = $( 'a.spa-sub-packages' );
		spa_links.each(
			function(index, item)
			{
				$( item ).click(
					function(event)
					{
						event.preventDefault();
						$( '#spa-lightbox #lightbox-content' ).html( '' );
						$( '#spa-lightbox-loader').clone().appendTo( $( '#spa-lightbox #lightbox-content' ) );
						$( '#spa-lightbox #lightbox-content #spa-lightbox-loader' ).show();
						var lbposition = $( this ).offset();
						var lbleft = lbposition.left - ($( '#spa-lightbox' ).width() / 2);
						//var lbtop = lbposition.top - ($( '#spa-lightbox' ).height() / 2);
						var lbtop = lbposition.top - 150;
						$( '#spa-lightbox' ).css( 'top', lbtop );
						$( '#spa-lightbox' ).css( 'left', lbleft );
						$( '#spa-lightbox' ).fadeIn( 300 );
						$( '#spa-lightbox #lightbox-content' ).load( $( this ).attr( 'href' ),
							function()
							{
								var lightbox_images = $( '#spa-lightbox div.lbx-images div.lbx-images-item' );
								var lightbox_images_current = 0;
								if( lightbox_images.length > 1 )
								{
									function lightbox_images_changer()
									{
										$( lightbox_images[lightbox_images_current] ).fadeOut(900);
										lightbox_images_current++;
										if( lightbox_images_current >= lightbox_images.length )
										{
											lightbox_images_current = 0;
										}
										$( lightbox_images[lightbox_images_current] ).fadeIn(900);
									}
									setInterval( lightbox_images_changer, 7000 );
								}
							}
						);
						$( 'a.lightbox-close' ).click(
							function(event)
							{
								event.preventDefault();
								$( '#spa-lightbox' ).fadeOut( 200 );
							}
						);
					}
				);
			}
		);
	}
);

//billboard-inner scroller
$( document ).ready(
	function()
	{
		var billboard_inner_item = $( 'div.billboard-inner div.billboard-inner-item' );
		var current_billboard_image = 0;
		if( billboard_inner_item.length > 1 )
		{
			function billboard_scroller()
			{
				$( billboard_inner_item[ current_billboard_image ] ).fadeOut(900);
				current_billboard_image++;
				if( current_billboard_image >= billboard_inner_item.length )
				{
					current_billboard_image = 0;
				}
				$( billboard_inner_item[ current_billboard_image ] ).fadeIn(900);
			}
			setInterval( billboard_scroller, 7000 );
		}
	}
);

//second description
$(document).ready(
	function()
	{
		var description_link = $( '#more_description_link' );
		var description_more = $( '#more_description' );
		var currentStatus = false;
		if( description_link.length > 0 )
		{
			description_link.click( function(e) 
			{
				e.preventDefault();
				if ( currentStatus )
				{
					$( description_more ).fadeOut( 300 );
					$( this ).html( '+ More details' );
					currentStatus = false;
				}
				else
				{
					$( description_more ).fadeIn( 300 );
					$( this ).html( '- More details' );
					currentStatus = true;
				}
			} );
		}
	}
);

//accommodations
$( document ).ready(
	function()
	{
		var accomodation_links = $( 'div.accomodations-thumbs div.thumb a' );
		var accomodation_images = $( 'div.accomodation-preview div.accomodation-preview-item' );
		var accomodation_description = $( 'div.images-caption div.images-caption-item' );
		accomodationsLastTime = new Date().getTime();
		accomodationsCurrentTime = new Date().getTime();
		var current_accomodations_image = 0;
		if( accomodation_links.length > 0 )
		{
			function accomodationsScroller()
			{
				accomodationsCurrentTime = new Date().getTime();
				if( ( accomodationsCurrentTime - accomodationsLastTime ) >= 6000 )
				{
					$( accomodation_links[current_accomodations_image] ).find( 'span.thumb-selected' ).hide();
					$( accomodation_links[current_accomodations_image] ).find( 'span.thumb-standard' ).show();
					$( accomodation_images[current_accomodations_image] ).fadeOut( 600 );
					$( accomodation_description[current_accomodations_image] ).hide();
					
					current_accomodations_image++;
					if( current_accomodations_image >= accomodation_links.length )
					{
						current_accomodations_image = 0;
					}
					
					$( accomodation_images[current_accomodations_image] ).fadeIn( 600 );
					$( accomodation_description[current_accomodations_image] ).show();
					$( accomodation_links[current_accomodations_image] ).find( 'span.thumb-selected' ).show();
					$( accomodation_links[current_accomodations_image] ).find( 'span.thumb-standard' ).hide();
					current_accomodations_image = current_accomodations_image;
					accomodationsLastTime = new Date().getTime();
				}
			}
			accomodation_links.each(
				function(index, item)
				{
					$( item ).click(
						function(event)
						{
							event.preventDefault();
							if( current_accomodations_image != index )
							{
								$( accomodation_links[current_accomodations_image] ).find( 'span.thumb-selected' ).hide();
								$( accomodation_links[current_accomodations_image] ).find( 'span.thumb-standard' ).show();
								$( accomodation_images[current_accomodations_image] ).fadeOut( 600 );
								$( accomodation_description[current_accomodations_image] ).hide();
								$( accomodation_images[index] ).fadeIn( 600 );
								$( accomodation_description[index] ).show();
								$( this ).find( 'span.thumb-selected' ).show();
								$( this ).find( 'span.thumb-standard' ).hide();
								current_accomodations_image = index;
								accomodationsLastTime = new Date().getTime();
							}
						}
					);
					$( item ).mouseenter(
						function(event)
						{
							if( current_accomodations_image != index )
							{
								$( accomodation_links[current_accomodations_image] ).find( 'span.thumb-selected' ).hide();
								$( accomodation_links[current_accomodations_image] ).find( 'span.thumb-standard' ).show();
								$( accomodation_images[current_accomodations_image] ).fadeOut( 600 );
								$( accomodation_description[current_accomodations_image] ).hide();
								$( accomodation_images[index] ).fadeIn( 600 );
								$( accomodation_description[index] ).show();
								$( this ).find( 'span.thumb-selected' ).show();
								$( this ).find( 'span.thumb-standard' ).hide();
								current_accomodations_image = index;
								accomodationsLastTime = new Date().getTime();
							}
						}
					);
				}
			);
			setInterval( accomodationsScroller, 1000 );
		}
	}
);

//accommodations map
$( document ).ready(
	function()
	{
		
		
	}
);

//special lightbox
$( document ).ready(
	function()
	{
		//resort map
		var resort_map_link = $( 'a[rel=#open_content_in_lightbox]' );
		if( resort_map_link.length > 0 )
		{
			$( resort_map_link ).click(
				function(event)
				{
					event.preventDefault();
					$( '#spa-lightbox #lightbox-content' ).html( '' );
					$( '#spa-lightbox-loader').clone().appendTo( $( '#spa-lightbox #lightbox-content' ) );
					$( '#spa-lightbox #lightbox-content #spa-lightbox-loader' ).show();
					//var lbposition = $( this ).offset();
					//var lbleft = lbposition.left - ($( '#spa-lightbox' ).width() / 2);
					//var lbtop = lbposition.top - ($( '#spa-lightbox' ).height() / 2);
					$( '#spa-lightbox' ).css( 'top', '10px' );
					$( '#spa-lightbox' ).css( 'left', '50px' );
					$( '#spa-lightbox' ).fadeIn( 300 );
					var preloader = $( '<div id="preloader" style="display: none;"></div>' );
					var subpreloader = $( '<div class="ltb-content-new"></div>' );
					$( preloader ).appendTo( 'body' );
					$( subpreloader ).appendTo( preloader );
					$( subpreloader ).load( $( this ).attr( 'href' ),
						function()
						{
							$( '#spa-lightbox' ).css( 'width', $( '#preloader' ).width() + 50 );
							$( '#spa-lightbox #lightbox-content' ).html( $( '#preloader' ).children( 'div.ltb-content-new' ).clone() );
							//$( '#preloader' ).remove();
						}
					);
					//$( '#spa-lightbox #lightbox-content' ).load( $( this ).attr( 'href' ) );
					$( 'a.lightbox-close' ).click(
						function(event)
						{
							event.preventDefault();
							$( '#spa-lightbox' ).fadeOut( 200 );
						}
					);
				}
			);
		}
	}
);

//lightbox for golf course
$( document ).ready(
	function()
	{
		var spa_links = $( 'a[rel=#golf_course]' );
		spa_links.each(
			function(index, item)
			{
				$( item ).click(
					function(event)
					{
						event.preventDefault();
						$( '#spa-lightbox #lightbox-content' ).html( '' );
						$( '#spa-lightbox-loader').clone().appendTo( $( '#spa-lightbox #lightbox-content' ) );
						$( '#spa-lightbox #lightbox-content #spa-lightbox-loader' ).show();
						var lbposition = $( this ).offset();
						//var lbleft = lbposition.left - ($( '#spa-lightbox' ).width() / 2);
						//var lbtop = lbposition.top - ($( '#spa-lightbox' ).height() / 2);
						var lbleft = lbposition.left - 250;
						var lbtop = lbposition.top - 500;
						$( '#spa-lightbox' ).css( 'top', lbtop );
						$( '#spa-lightbox' ).css( 'left', lbleft );
						$( '#spa-lightbox' ).css( 'width', 500 );
						$( '#spa-lightbox' ).fadeIn( 300 );
						$( '#spa-lightbox #lightbox-content' ).load( $( this ).attr( 'href' ),
							function()
							{
								var lightbox_links = $( '#spa-lightbox div.golf-course-navigator li' );
								var lightbox_images = $( '#spa-lightbox div.golf-course-content-item' );
								var lightbox_images_current = 0;
								if( lightbox_links.length > 1 )
								{
									function lightbox_images_changer( new_images )
									{
										if( lightbox_images_current != new_images )
										{
											$( lightbox_images[lightbox_images_current] ).hide();
											$( lightbox_links[lightbox_images_current] ).removeAttr( 'class' );
											lightbox_images_current = new_images;
											$( lightbox_images[lightbox_images_current] ).fadeIn(400);
											$( lightbox_links[lightbox_images_current] ).attr( 'class', 'selected' );
										}
									}
									lightbox_links.each(
										function(index, item)
										{
											$( item ).click(
												function(event)
												{
													event.preventDefault();
													lightbox_images_changer( index );
												}
											);
										}
									);
								}
							}
						);
						$( 'a.lightbox-close' ).click(
							function(event)
							{
								event.preventDefault();
								$( '#spa-lightbox' ).fadeOut( 200 );
							}
						);
					}
				);
			}
		);
	}
);

//email sign-up
$( document ).ready(
	function()
	{
		var email_signup_form = $( 'div.sign-up input' );
		if( email_signup_form.length > 0 )
		{
			$( email_signup_form ).click(
				function(event)
				{
					event.preventDefault();
					window.open( 'http://echo.bluehornet.com/clients/rancholaspalmas/survey.htm' );
				}
			);
		}
	}
);

//accommodations map room
$( document ).ready(
	function()
	{
		var accommodations_map_first = $( 'div.accomodations_map ul.map-level1>li' );
		var accommodations_map_second = $( 'div.accomodations_map ul.map-level2>li' );
		var accommodations_map_description = $( 'div.accomodations_map div.map-description' );
		var map_areas = $( 'div.accomodations_map map area' );
		var accommodations_map_rooms = $( 'div.accomodations_map div.map-content-item' );
		var accommodations_map_rooms_sorted = Array();
		accommodations_map_rooms.each(
			function(index, item)
			{
				var currentIndex = $( item ).attr('rel');
				accommodations_map_rooms_sorted[currentIndex] = $( item );
			}
		);

		window.accommodations_map_current_room = 0;
		window.accommodations_map_current_groop_room = 0;
		
		window.map_current_first = -1;
		window.map_current_second = -1;
		
		accommodations_map_first.each(
			function(index, item)
			{
				$( item ).click(
					function(event)
					{
						event.preventDefault();
					}
				);
				$( item ).mouseenter(
					function(event)
					{
						event.preventDefault();
						if( window.map_current_first != index )
						{
							if( window.map_current_first != -1 )
							{
								$( accommodations_map_first[window.map_current_first] ).removeClass( 'selected' );
								$( accommodations_map_first[window.map_current_first] ).children( 'ul.map-level2' ).fadeOut( 50 );
							}
							window.map_current_first = index;
							$( accommodations_map_first[window.map_current_first] ).addClass( 'selected' );
							$( accommodations_map_first[window.map_current_first] ).children( 'ul.map-level2' ).fadeIn( 100 );
							$( accommodations_map_second ).removeClass( 'selected' );
						}
					}
				);
			}
		);
		
		function hardcode_zone_never_do_it2()
		{
			var dal = 80;
			if( window.map_current_second  == 0 )
			{
				window.accommodations_map_current_groop_room = 0;
				accommodations_map_rooms_sorted[9].delay(dal * 1).fadeIn( 300 );
				accommodations_map_rooms_sorted[11].delay(dal * 2).fadeIn( 300 );
				accommodations_map_rooms_sorted[15].delay(dal * 3).fadeIn( 300 );
				accommodations_map_rooms_sorted[17].delay(dal * 4).fadeIn( 300 );
				accommodations_map_rooms_sorted[19].delay(dal * 5).fadeIn( 300 );
				accommodations_map_rooms_sorted[21].delay(dal * 6).fadeIn( 300 );
				accommodations_map_rooms_sorted[23].delay(dal * 7).fadeIn( 300 );
				accommodations_map_rooms_sorted[25].delay(dal * 8).fadeIn( 300 );
				accommodations_map_rooms_sorted[27].delay(dal * 9).fadeIn( 300 );
				accommodations_map_rooms_sorted[29].delay(dal * 10).fadeIn( 300 );
				accommodations_map_rooms_sorted[31].delay(dal * 11).fadeIn( 300 );
			}
			// Plaza Rooms
			if( window.map_current_second  == 1 )
			{
				window.accommodations_map_current_groop_room = 1;
				accommodations_map_rooms_sorted[1].delay(dal * 1).fadeIn( 300 );
				accommodations_map_rooms_sorted[2].delay(dal * 2).fadeIn( 300 );
				accommodations_map_rooms_sorted[3].delay(dal * 3).fadeIn( 300 );
				accommodations_map_rooms_sorted[4].delay(dal * 4).fadeIn( 300 );
				accommodations_map_rooms_sorted[5].delay(dal * 5).fadeIn( 300 );
			}
			// Lakeview Rooms
			if( window.map_current_second  == 2 )
			{
				window.accommodations_map_current_groop_room = 2;
				accommodations_map_rooms_sorted[6].delay(dal * 1).fadeIn( 300 );
				accommodations_map_rooms_sorted[8].delay(dal * 2).fadeIn( 300 );
				accommodations_map_rooms_sorted[30].delay(dal * 3).fadeIn( 300 );
				accommodations_map_rooms_sorted[32].delay(dal * 4).fadeIn( 300 );
			}
			// Poolside Rooms
			if( window.map_current_second  == 3 )
			{
				window.accommodations_map_current_groop_room = 3;
				accommodations_map_rooms_sorted[10].delay(dal * 1).fadeIn( 300 );
				accommodations_map_rooms_sorted[12].delay(dal * 2).fadeIn( 300 );
				accommodations_map_rooms_sorted[14].delay(dal * 3).fadeIn( 300 );
				accommodations_map_rooms_sorted[16].delay(dal * 4).fadeIn( 300 );
				accommodations_map_rooms_sorted[24].delay(dal * 5).fadeIn( 300 );
				accommodations_map_rooms_sorted[26].delay(dal * 6).fadeIn( 300 );
				accommodations_map_rooms_sorted[28].delay(dal * 7).fadeIn( 300 );
			}
			if( window.map_current_second  == 4 )
			{
				window.accommodations_map_current_groop_room = 4;
				accommodations_map_rooms_sorted[1].delay(dal * 1).fadeIn( 300 );
				accommodations_map_rooms_sorted[4].delay(dal * 2).fadeIn( 300 );
				accommodations_map_rooms_sorted[6].delay(dal * 3).fadeIn( 300 );
				accommodations_map_rooms_sorted[10].delay(dal * 4).fadeIn( 300 );
			}
			if( window.map_current_second  == 5 )
			{
				window.accommodations_map_current_groop_room = 5;
				accommodations_map_rooms_sorted[21].delay(dal * 1).fadeIn( 300 );
				accommodations_map_rooms_sorted[23].delay(dal * 2).fadeIn( 300 );
				accommodations_map_rooms_sorted[25].delay(dal * 3).fadeIn( 300 );
				accommodations_map_rooms_sorted[27].delay(dal * 4).fadeIn( 300 );
			}
			if( window.map_current_second  == 6 )
			{
				window.accommodations_map_current_groop_room = 6;
				accommodations_map_rooms_sorted[30].delay(dal * 1).fadeIn( 300 );
			}
		}
		
		accommodations_map_second.each(
			function(index, item)
			{
				$( item ).mouseenter(
					function(event)
					{
						event.preventDefault();
						if( window.map_current_second != index )
						{
							if( window.map_current_second != -1 )
							{
								$( accommodations_map_second[window.map_current_second] ).removeClass( 'selected' );
							}
							window.map_current_second = index;
							//Vista room
							$( accommodations_map_rooms ).fadeOut( 200 );
							hardcode_zone_never_do_it2();
							$( 'div.accomodations_map div.map-description' ).fadeIn( 300 );
							$( accommodations_map_description ).load( $( accommodations_map_second[window.map_current_second] ).children( 'a' ).attr( 'href' ) );
						}
					}
				);
			}
		);
		
		if( map_areas.length > 0 )
		{
			
			
			function hardcode_zone_never_do_it( current_room )
			{
				// Vista Rooms
				if( window.map_current_first == 1 )
				{
					$( accommodations_map_first[1] ).children( 'ul.map-level2' ).fadeOut( 50 );
				}
				if( (current_room == 9) || (current_room == 11) || (current_room == 15) || (current_room == 17) || (current_room == 19) || (current_room == 21) || (current_room == 23) || (current_room == 25) || (current_room == 27) || (current_room == 29) || (current_room == 31) )
				{
					
					if( window.map_current_second != 0 || window.map_current_first == 1 )
					{
						window.map_current_first = 0;
						window.map_current_second = 0;
						$( accommodations_map_first ).removeAttr( 'class' );
						$( accommodations_map_first[0] ).attr( 'class',	'selected' );
						$( accommodations_map_first[0] ).children( 'ul.map-level2' ).fadeOut( 50 );
						$( accommodations_map_first[0] ).children( 'ul.map-level2' ).fadeIn( 100 );
						$( accommodations_map_second ).removeAttr( 'class' );
						$( accommodations_map_second[0] ).attr( 'class',	'selected' );
					}
				}
				// Plaza Rooms
				if( (current_room == 1) || (current_room == 2) || (current_room == 3) || (current_room == 4) || (current_room == 5) )
				{
					
					if( window.map_current_second != 1 || window.map_current_first == 1 )
					{
						window.map_current_first = 0;
						window.map_current_second = 1;
						$( accommodations_map_first ).removeAttr( 'class' );
						$( accommodations_map_first[0] ).attr( 'class',	'selected' );
						$( accommodations_map_first[0] ).children( 'ul.map-level2' ).fadeOut(50);
						$( accommodations_map_first[0] ).children( 'ul.map-level2' ).fadeIn( 100 );
						$( accommodations_map_second ).removeAttr( 'class' );
						$( accommodations_map_second[1] ).attr( 'class',	'selected' );
					}
				}
				// Lakeview Rooms
				if( (current_room == 6) || (current_room == 8) || (current_room == 30) || (current_room == 32) )
				{
					
					if( window.map_current_second != 2 || window.map_current_first == 1 )
					{
						window.map_current_first = 0;
						window.map_current_second = 2;
						$( accommodations_map_first ).removeAttr( 'class' );
						$( accommodations_map_first[0] ).attr( 'class',	'selected' );
						$( accommodations_map_first[0] ).children( 'ul.map-level2' ).fadeOut(50);
						$( accommodations_map_first[0] ).children( 'ul.map-level2' ).fadeIn( 100 );
						$( accommodations_map_second ).removeAttr( 'class' );
						$( accommodations_map_second[2] ).attr( 'class',	'selected' );
					}
				}
				// Poolside Rooms
				if( (current_room == 10) || (current_room == 12) || (current_room == 14) || (current_room == 16) || (current_room == 24) || (current_room == 26) || (current_room == 28) )
				{
					
					if( window.map_current_second != 3 || window.map_current_first == 1 )
					{
						window.map_current_first = 0;
						window.map_current_second = 3;
						$( accommodations_map_first ).removeAttr( 'class' );
						$( accommodations_map_first[0] ).attr( 'class',	'selected' );
						$( accommodations_map_first[0] ).children( 'ul.map-level2' ).fadeOut( 50 );
						$( accommodations_map_first[0] ).children( 'ul.map-level2' ).fadeIn( 100 );
						$( accommodations_map_second ).removeAttr( 'class' );
						$( accommodations_map_second[3] ).attr( 'class',	'selected' );
					}
				}
			}
			
			map_areas.each(
				function(index, item)
				{
					$( item ).mouseenter(
						function(event)
						{
							var current_room = $( this ).attr( 'href' ).substring(1);
							hardcode_zone_never_do_it( current_room );
							
							$( accommodations_map_rooms ).fadeOut( 200 );
							window.accommodations_map_current_room = current_room;
							$( accommodations_map_rooms_sorted[window.accommodations_map_current_room] ).fadeIn( 300 );
						}
					);
				}
			);
			
			accommodations_map_rooms.each(
				function(index, item)
				{
					$( item ).mouseleave(
						function(event)
						{
							//$( accommodations_map_rooms ).fadeOut( 200 );
						}
					);
				}
			);
			
			/*map_areas.each(
				function(index, item)
				{
					$( item ).mouseenter(
						function(event)
						{
							event.preventDefault();
							var current_room = $( this ).attr( 'href' ).substring(1);
							hardcode_zone_never_do_it( current_room );
							$( 'div.accomodations_map div.map-description' ).fadeIn( 300 );
							$( 'div.accomodations_map div.map-description' ).load( map_areas_url + current_room  );
							
							$( accommodations_map_rooms ).fadeOut( 200 );
							window.accommodations_map_current_room = current_room;
							$( accommodations_map_rooms_sorted[window.accommodations_map_current_room] ).fadeIn( 300 );
						}
					);
				}
			);*/
			
			/*map_areas.each(
				function(index, item)
				{
					$( item ).click(
						function(event)
						{
							event.preventDefault();
							var current_room = $( this ).attr( 'href' ).substring(1);
							hardcode_zone_never_do_it( current_room );
							$( 'div.accomodations_map div.map-description' ).fadeOut( 200,
								function()
								{
									$( 'div.accomodations_map div.map-description' ).html( '' );
								}
							);
							$( 'div.accomodations_map div.map-description' ).fadeIn( 300 );
							$( 'div.accomodations_map div.map-description' ).load( map_areas_url + current_room  );
							
							$( accommodations_map_rooms ).fadeOut( 200 );
							window.accommodations_map_current_room = current_room;
							$( accommodations_map_rooms_sorted[window.accommodations_map_current_room] ).fadeIn( 300 );
						}
					);
				}
			);*/
			/*accommodations_map_rooms.each(
				function(index, item)
				{
					$( item ).click(
						function(event)
						{
							event.preventDefault();
							var current_room = $( this ).attr( 'rel' );
							hardcode_zone_never_do_it( current_room );
							$( 'div.accomodations_map div.map-description' ).fadeOut( 200,
								function()
								{
									$( 'div.accomodations_map div.map-description' ).html( '' );
								}
							);
							$( 'div.accomodations_map div.map-description' ).fadeIn( 300 );
							$( 'div.accomodations_map div.map-description' ).load( map_areas_url + current_room  );
							
							$( accommodations_map_rooms ).fadeOut( 200 );
							window.accommodations_map_current_room = current_room;
							$( accommodations_map_rooms_sorted[window.accommodations_map_current_room] ).fadeIn( 300 );
						}
					);
				}
			);*/
			
			accommodations_map_rooms.each(
				function(index, item)
				{
					$( item ).mouseover(
						function(event)
						{
							event.preventDefault();
							var current_room = $( this ).attr( 'rel' );
							hardcode_zone_never_do_it( current_room );
							hardcode_zone_never_do_it2();
							$( 'div.accomodations_map div.map-description' ).fadeIn( 300 );
							//$( 'div.accomodations_map div.map-description' ).load( map_areas_url + current_room  );
							$( 'div.accomodations_map div.map-description' ).load( $( accommodations_map_second[window.map_current_second] ).find( 'a' ).attr( 'href' )  );
							//$( accommodations_map_rooms ).fadeOut( 200 );
							window.accommodations_map_current_room = current_room;
							$( accommodations_map_rooms_sorted[window.accommodations_map_current_room] ).fadeIn( 300 );
						}
					);
				}
			);
		}
	}
);
//default callendar date
$( document ).ready(
	function()
	{
		var myDate=new Date();
		$( '#checkin-input' ).attr( 'value', (myDate.getMonth() + 1) +'/' + myDate.getDate() + '/' + myDate.getFullYear() );
		myDate.setDate( myDate.getDate() + 1 );
		$( '#checkout-input' ).attr( 'value', (myDate.getMonth() + 1) + '/' + myDate.getDate() + '/' + myDate.getFullYear() );
	}
);
//images preloader
var image_preloader = $( '<img></img>' ).attr( 'src', 'extension/nxc_tigrancholp/design/nxc_tigrancholp/images/exp-close-hover.gif' );
var image_preloader2 = $( '<img></img>' ).attr( 'src', 'extension/nxc_tigrancholp/design/nxc_tigrancholp/images/experience-btn-hover_bg.png' );

