
$(document).ready(function(){
	//*** MAIN NAV ***//

	$('#mainnav li').mouseenter(function(){
			
		if($(this).hasClass('active') != true)
		{	
			$(this).find('a').stop(true,true).animate({'color':'white','background-color':'#09163f'},300,'easeInOutCubic');
		}
	});
	
	$('#mainnav li').mouseleave(function(){
		if($(this).hasClass('active') != true)
		{
			$(this).find('a').stop(true,true).animate({'color':'#09163f','background-color':'transparent'},300,'easeInOutCubic');
		}
	});
	
	$('.ls_accordion li').each(function(index){
		var $div = $(this).find('.accordion_content_wrapper');
		var height = $div.show().height();
		$div.attr('_height',height);
		/** IF YOU WANT TO LEAVE THE FIRST OPEN **/
		
		/*if(index != 0 || $(this).hasClass('first') == true)
		{
			$(this).addClass('opened');
			$div.css('height','0px');
			$div.hide();
		}else $div.css('height',height);
		*/
		
		/** CLOSE ALL **/
		if($(this).hasClass('opened'))
		{}
		else
		{
			$div.css('height','0px');
			$div.hide();
		}

		
		//$div.hide().css({ height : 0});
		$(this).find('a.switch').stop(true,true).click(function(){
			var $a = $(this);
			if(!$a.hasClass('pdf'))
			{
				$a.removeClass('opened');
				
				if( $div.is(':visible'))
				{	
					$div.animate({'height' : 0},800,'easeInOutCubic',function(){
							$div.hide();
							$('body').height(0);
							var wrapper_size = $('#main-wrapper').height();
							if(wrapper_size > $(document).height())
							{
								$('body').height(wrapper_size);
							}
							else $('body').height($(document).height()); 
							
						});
				}
				else 
				{
					$(this).parents('ul.ls_accordion').find('.opened').parent('li').find('.accordion_content_wrapper').animate({'height' : 0},400,'easeInOutCubic',function(){
							$(this).hide();
							$(this).parent('li').find('.opened').removeClass('opened');
						});
					$a.addClass('opened');
					var divheight = $(this).parent('li').find('.accordion_content_wrapper').attr('_height');

					$div.show().animate({'height' : divheight}, 800,'easeInOutCubic',function(){
						$('body').height(0);
						var wrapper_size = $('#main-wrapper').height();
						if(wrapper_size > $(document).height())
							{
								
								$('body').height($(document).height());
							}
							else $('body').height($(document).height());
					});
				}
			}
			}); 
				
		});
	
	$('.bt_book_now').mouseenter(function(){
		$('.bt_book_now_over').stop(true,true).fadeIn(300,'easeInOutCubic');
	});
	$('.bt_book_now').mouseleave(function(){
		$('.bt_book_now_over').stop(true,true).fadeOut(200,'easeInOutCubic');
	});
	$('.bt_read_reviews').mouseenter(function(){
		$('.bt_read_reviews_over').stop(true,true).fadeIn(300,'easeInOutCubic');
	});
	$('.bt_read_reviews').mouseleave(function(){
		$('.bt_read_reviews_over').stop(true,true).fadeOut(200,'easeInOutCubic');
	});
	
	//*** MAP ***//
	$('.big_map_content div.big_map_zone div').mouseenter(function(){
		var id = $(this).attr('id');
		$('.big_map_content .big_map_img .map_'+ id).stop(true,true).fadeIn('normal');
	
	});
	$('.big_map_content div.big_map_zone div').mouseleave(function(){
		$('.big_map_content .big_map_img div').stop(true,true).fadeOut('normal');
	});
	
	$('.small_map_content').mouseenter(function(){
		$('.active_img_container').hide();
	
	});
	$('.small_map_content').mouseleave(function(){
		$('.active_img_container').show();
	
	});
	$('.small_map_content .over_zone_container div').mouseover(function(){
		var id = $(this).attr('id');
		$('.small_map_content .over_img_container div.'+ id +'_over').stop(true,true).fadeIn('normal');
	
	});
	$('.small_map_content .over_zone_container div').mouseout(function(){
		$('.small_map_content .over_img_container div').stop(true,true).delay(200).fadeOut('normal');
	
	});
	
	/*** SELECT BOX ***/
	$('#seasons .label').change(function(){
		alert('test');
		var val = $(this).val();
		//var main = $(this).parents('.packages_rates');
		if(val == 'first')
		{
			$('#prices').find('.container .item').hide();
			$('#prices').find('.container .item[value=first]').show();
			//$(main).find('.results h3 .price').text('-');
		}
		else{
			$('#prices').find('.container .item').hide();
			$('#prices').find('.container .item[value=first]').show();
			$('#prices').find('.container .item[name="'+ val +'"]').show();
			
			//$(main).find('.results h3 .price').text('-');
		}
	});
	$('#seasons .item').click(function(){
		var main = $(this).parents('.packages_rates');
		var val = $(this).attr('_val');
		$(this).parents('.packages_rates').find('#prices .label').text('Prices');	
		$(this).parents('.packages_rates').find('#prices').find('.item').hide();
		$(this).parents('.packages_rates').find('#prices').find('.item[name="'+ val +'"]').show();
		$(main).find('.results h3 .price').text('-');
	});
	$('#prices .item').click(function(){
		var main = $(this).parents('.packages_rates');
		var val = $(this).attr('_val');
		var desc = $(this).attr('_val_desc'); 
		$(main).find('.results h3 .price').text(val);
		$(main).find('.results p').text(desc);
	});
	
	
	$('.selectbox .label').click(function(){
		if($(this).parent('.selectbox').find('.selectbox_container').is(':visible'))
		{
			$(this).parent('.selectbox').find('.selectbox_container').slideUp(500,'easeOutCubic');
		}
		else
		{
			$(this).parent('.selectbox').find('.selectbox_container').slideDown(500,'easeOutCubic');
		}
	});
	
	$('.selectbox .item').click(function(){
		var txt = $(this).text();
		var val = $(this).attr('_val');
		$(this).parents('.selectbox').find('.label').text(txt).attr('_val',val);

		$(this).parents('.selectbox_container').slideUp(500,'easeOutCubic');
	});
	
	$('.selectbox').mouseleave(function(){
		$(this).find('.selectbox_container').slideUp(500,'easeOutCubic');
	});
	
	
});

/*** SHOW HIDE MAP ELEMENT ***/
function show_map_element(el)
{
	$('.big_map_content div.big_map_img div').hide();
	if(el == 'villas')
	{
		$('.big_map_content div.big_map_img div.map_villas').stop(true,true).fadeIn('normal');
		
	}
	else $('.big_map_content div.big_map_img div.map_'+el).stop(true,true).fadeIn('normal');	
}
function hide_map_element(el)
{
	if(el == 'villas')
	{
		$('.big_map_content .big_map_img div.map_villas').stop(true,true).hide();
	}
	else $('.big_map_content .big_map_img div.map_'+el).stop(true,true).hide();	
}
function show_smallmap_element(el)
{
	$('.small_map_content .over_img_container').find('.'+ el +'_over').stop(true,true).fadeIn('normal');	
}
function hide_smallmap_element(el)
{
	$('.small_map_content .over_img_container').find('.'+ el +'_over').stop(true,true).fadeOut('normal');	
}

// AWARDS

function showalltext(el)
{
	$(el).parent('.accordion_content').find('.text').show();
	$(el).parent('.accordion_content').find('.exercpt').hide();
	$(el).parent('.accordion_content').find('.show').hide();
	$(el).parent('.accordion_content').find('.hide').show();
}

function hidealltext(el)
{
	$(el).parent('.accordion_content').find('.text').hide();
	$(el).parent('.accordion_content').find('.exercpt').show();
	$(el).parent('.accordion_content').find('.show').show();
	$(el).parent('.accordion_content').find('.hide').hide();
}

