$(document).ready(function() {
	
	$(function(){   
		$('nav').find('ul').find('li').hover(
			function() { $(this).find('ul').show(); },
			function() { $(this).find('ul').hide(); }
		);
	});
	
	$('nav').find('li.link')
	.click(function(){
		var link=$(this).find('a:first').attr('href'); 
    location.href=link; 
	});
	$('#logo-head-locanda, #logo-head-taverna')
	.click(function(){
		var link=$(this).find('a:first').attr('href'); 
    location.href=link; 
	});
	  
	$('#wrap-3-index, #wrap-3').find('.wrap-box').find('.tripadvisor, .tripadvisor-eng')
	.mouseleave(function(){$(this).stop().fadeTo(500, 1)})
	.mouseenter(function(){$(this).stop().fadeTo(150, 0.7)})
	.click(function(e){
		e.preventDefault();
		window.open($(this).find("a:first").attr("href"));
		return false; 
	});
	
	$('.vini').find('a')
	.mouseleave(function(){$(this).stop().fadeTo(500, 1)})
	.mouseenter(function(){$(this).stop().fadeTo(150, 0.7)})
	;
	
	$('#lang').find('ul').find('li').find('ul').find('li')
	.mouseleave(function(){$(this).stop().fadeTo(500, 1)})
	.mouseenter(function(){$(this).stop().fadeTo(150, 0.7)})
	.click(function(){
		var link=$(this).find('a:first').attr('href'); 
    	location.href=link; 
	});
	  
	$('#wrap-1-index, #wrap-2-index')
	  .mouseleave(function(){$(this).stop().fadeTo(500, 1)})
	  .mouseenter(function(){$(this).stop().fadeTo(150, 0.8)})
	  .click(function(){
		var link=$(this).find('a:first').attr('href'); 
    	location.href=link; 
		
	  });
	  
	 $('#wrap-1-index').find('.slideshow').cycle({ 
		fx:     'scrollLeft', 
		easing: 'easeOutBounce', 
		speed: 800,
		timeout:6500,
		delay: 0
	});
		
	$('#wrap-2-index').find('.slideshow').cycle({ 
		fx:     'scrollRight', 
		easing: 'easeOutBounce', 
		speed: 800,
		timeout:6500,
		delay: 3250
	});
				
	  $('.datepicker').datepicker({ 
        buttonImage: '/static/img/calendario-small.png', 
        buttonImageOnly: true, 
        showOn: 'both' 
     }); 
		
		
	$(window).load(function() {
		$('div#makeMeScrollable').smoothDivScroll({ 
				autoScroll: 'always', 
				autoScrollDirection: 'endlessloopright', 
				autoScrollStep: 1, 
				autoScrollInterval: 30 
			});
														
	});
		
	$(window).load(function() {
		$('div.sliders').smoothDivScroll({
			autoScrollStep: 1, 
			autoScrollInterval: 1
		});														
	});
		
	$('a[rel=fbox], a[rel=fbox1], a[rel=fbox2], a[rel=fbox3], a[rel=fbox4], .fbox').fancybox({
				overlayOpacity	: 0.7,
				overlayColor	: '#99604F',
				transitionIn	: 'elastic',
				transitionOut	: 'elastic'
			});
			
			
	$('.lastminute').find('img').hide().load(function() {
			$(this).show().resize({
					maxWidth: 115,
					maxHeight: 115
				});
	});
	
	
	var $form = $('#form-small');
	$form.bind('submit', function(){
		$form = $(this);
		var url = $form.attr('action');
		
		$.fancybox.showActivity();
		
		$.ajax({
			type: "POST",
			cache: false,
			url: url,
			data: $form.serializeArray(),
			success: function(data) {
				$.fancybox({
					content: data,
					enableEscapeButton: false,						
					'transitionIn'		: 'elastic',
					'transitionOut'		: 'elastic',
					overlayColor 		:'#7C4B3D',
					width				: 875,
					height				: 485,
					autoDimensions		: false,
					showCloseButton		: true
				});
			}
		});
		
		return false;
	});	
		
		
});
