/*
 * Created by Giuseppe Migliozzi.
 * User: gmigliozzi
 * Date: 13/04/11
 * Time: 15.29
 * To change this template use File | Settings | File Templates.
 */


// vars 
var menu_position = $('#header').offset();
 

// scripting
function bug_ie7(){	
	
	 $('.sx').css('display','block');
	 $(".su").trigger('mouseenter'); 
	 $(".intro").css('margin-top','-2px'); 
	 $("#testo").css('margin-top','-2px'); 
		

}


	$(window).load(function() {
		if(jQuery.browser.version == "7.0"){
		bug_ie7();
		}
		
		
	});
	
	

$(document).ready(function() {
	
	
	if($(window).width()<1113) {
		$('#award').css('display','none');	
	}
	
	$(window).resize(function(){
		
		if($(window).width()<1113) {
			$('#award').css('display','none');	
		}
		if($(window).width()>1113) {
			$('#award').css('display','block');	
		}
	})	;

			
	$('#paging_container7').pajinate({
		num_page_links_to_display : 3,
		items_per_page : 3,

        nav_label_first : '',
		nav_label_last : '',
		nav_label_prev : '<',
		nav_label_next : '>',
        item_container_id : '.alt_content',
		nav_panel_id : '.alt_page_navigation'
});

$('.first_link').css('display','none');
$('.last_link').css('display','none');		
	
	
	if(jQuery.browser.version == "8.0"){
		
		$('#single_bottom a .apri_info_tobimova').css('margin-top','-7px');	
		}
	
$('#loading').css('display','none'); // let's goooo!
$('#main_container').css('display','block');


var $menu_fill = $('#menu_fill');	
if ($.browser.mozilla || $.browser.safari || jQuery.browser.version == "9.0") {
 	Cufon.replace('#paging_container7 .pagination, .paginator, #menu div._1',{ fontFamily: 'Neue_LT' ,  hover: true });
	Cufon.replace('#box-home #main_sx h5, , #testo_1, #testo_2, #main-home-botton div.center div.bottom_home_location div.dx div.location p.intro_location, #main-home-botton.guestbook div.center p, #main-home-botton div.center span, #single_bottom p,#single_bottom_cantina p, .sx h4, #main_dx div.titofferta h3',{ fontFamily: 'HelveticaLT' ,  hover: false });
	Cufon.replace('.tasto a, #main_dx h2, #main_dx div.data, #main_dx div.testo, div.msg, #contact_form',{ fontFamily: 'Gill' ,  hover: false });
	Cufon.replace('#info, #footer_2_dx,  #testo .parte_1,#testo_cantina .parte_1, #box_pressarea_sx .infopressarea',{ fontFamily: 'Neue' ,  hover: false });
	Cufon.replace('#footer_2_sx',{ fontFamily: 'Neue' ,  hover: true });

  } else if (jQuery.browser.version == "8.0" || jQuery.browser.version == "7.0" || jQuery.browser.version == "6.0"){
	 	Cufon.replace('#menu div._1',{ fontFamily: 'Neue_LT' ,  hover: true });
		Cufon.replace('#box-home #main_sx h5, .sx h4, #main_dx div.titofferta h3 ',{ fontFamily: 'HelveticaLT' ,  hover: false });
		Cufon.replace('#info, #footer_2_dx',{ fontFamily: 'Neue' ,  hover: false });
		Cufon.replace('#footer_2_sx',{ fontFamily: 'Neue' ,  hover: true });

		Cufon.replace('#main_dx h2, #main_dx div.data',{ fontFamily: 'Gill' ,  hover: false });
		$('#menu').css('margin-left','192px');

  
  }


menu_position = $('#header').offset();
$menu_fill.css('width', Math.ceil(menu_position.left+10));
$menu_fill.css('margin-left', -parseInt($menu_fill.css('width')));


// bug IE 7




//$( ".datepicker" ).datepicker();
// preload spa
	

	// sound
$(".play").click(function () {
     var sound;
        sound = $('.jp-play-bar').attr('sound');
        if(sound==1){
            $('.jp-play-bar').attr('sound',0);
            sound = 0;
        } else if(sound==0){
            $('.jp-play-bar').attr('sound',1);
            sound = 1;
        }


        $.ajax({
		type:	"GET",
		url:	"/default/index/sound/",
		data:	"sound="+sound,
		complete: function (data, stato) {

            }
        });
});

sound();
	
	
	
	
	

	
	// fonts

    $("#fw").easySlider();
    
 
   
// pezzotto dei bordi sul menu
    
    
    
    $('#menu ._1:first').mouseenter(function() {
    	$('#menu_bordo').addClass('menu_bordo_first');
    	$('#menu_bordo').removeClass('disabled2');
    	if(jQuery.browser.version == "7.0"){
    		$('#menu_bordo').css('margin-left','-748px');	
    		
    	}
    	if($('#menu ._1:last a').attr('href') == '/en/contatti' && jQuery.browser.version == "7.0") {
    		
    		$('#menu_bordo').css('margin-left','-743px');		
    	}

    });
    $('#menu ._1:first').mouseleave(function() {
    	$('#menu_bordo').addClass('disabled2');
    	$('#menu_bordo').removeClass('menu_bordo_first');

    });
    $('#menu ._1:last').mouseenter(function() {
    	
    	if($('#menu ._1:last a').attr('href') == '/en/contatti') {
    		$('#menu_bordo').addClass('menu_bordo_last_en');
    		if(jQuery.browser.version == "7.0"){
        		$('#menu_bordo').css('margin-left','0px');	
        		
        	}
        } else {
        	$('#menu_bordo').addClass('menu_bordo_last');
        	if(jQuery.browser.version == "7.0"){
        		$('#menu_bordo').css('margin-left','0px');	
        		
        	}
        	
        	
        }
    	$('#menu_bordo').removeClass('disabled2');

    });
    $('#menu ._1:last').mouseleave(function() {
    	$('#menu_bordo').addClass('disabled2');
    	if($('#menu ._1:last a').attr('href') == '/en/contatti') {
    		$('#menu_bordo').removeClass('menu_bordo_last_en');	
        } else {
        	$('#menu_bordo').removeClass('menu_bordo_last');	
        	
        }
    
    });


    


    // per animare i blocchi in home page
$(".giu").mouseenter(function() {
        var id = $(this).attr('foto');
        var $target =  $("#" + id).children('.foto');
        var $selector = $(this).children('.foto');
       
   $selector.removeClass('block');
    
    if(!$target.hasClass('block')) {
    	
    
    	$target.stop(false,false).animate({
        height: 0
    }, 800, 'easeOutQuint', function () {
    	$target.addClass('disabled2')

    });
        
    	 $selector.stop(false, false).animate({
        height: 140, marginTop:-140
    }, 800, 'easeOutQuint');
    		$target.addClass('block');
    }




});
$(".su").mouseenter(function() {

    var id = $(this).attr('foto');
    var $target =  $("#" + id).children('.foto');
    var $selector = $(this).children('.foto');
    
    $selector.removeClass('block');

    if(!$target.hasClass('block'))
    {
    	
    	
        $selector.removeClass('disabled2');
        $selector.stop(false, false).animate({
        height: 140
    }, 800, 'easeOutQuint');
        
        $target.stop(false, false).animate({
        height: 0, marginTop:0
    }, 800, 'easeOutQuint');
        $target.addClass('block'); 
    }
});



 





// chef e tobimava slide





$(".chef a").toggle(function (){

	$(this).children('.apri_info').delay(100).fadeOut(500,'easeOutQuint');
	$(this).children('.apri_info_tobimova').delay(100).fadeOut(500,'easeOutQuint');
	
	if ($.browser.mozilla || $.browser.safari || jQuery.browser.version == "9.0") {
		$(this).prev().prev().fadeOut(500,'easeOutQuint');
		$(this).prev().delay(500).fadeIn(800,'easeOutQuint');
		
		$(this).parent().parent().prev().delay(550).animate({
	        height:427
	    }, 1400, 'easeInOutQuint');
		
		$(this).parent().delay(550).animate({
	        height:427
	    }, 1400, 'easeInOutQuint');
		
		  } else if (jQuery.browser.version == "8.0" || jQuery.browser.version == "7.0" || jQuery.browser.version == "6.0"){
			  $(this).prev().prev().delay(300).fadeOut(1,'easeOutQuint');
				$(this).prev().delay(300).fadeIn(1,'easeOutQuint');
				
				$(this).parent().parent().prev().delay(302).animate({
			        height:427
			    }, 1400, 'easeInOutQuint');
				
				$(this).parent().delay(302).animate({
			        height:427
			    }, 1400, 'easeInOutQuint');
		  }
	

	
	

	$('#gallerychef').nivoSlider({
			effect:'fold',
	        directionNav:true,
	        directionNavHide:false,
	        controlNav:false,
	        pauseTime:6000,
	        prevText: '',
	        nextText: ''

	    });
	
	$(this).children('.chiudi_info').delay(800).fadeIn(500,'easeOutQuint');
	$('#gallerychef').data('nivoslider').start();

    return false;
 },function () {
	 $(this).children('.chiudi_info').delay(100).fadeOut(100,'easeOutQuint');
	 

	 if ($.browser.mozilla || $.browser.safari || jQuery.browser.version == "9.0") {
		 $(this).prev().delay(1500).fadeOut(400,'easeOutQuint');
		 $(this).prev().prev().delay(1900).fadeIn(500,'easeOutQuint');
	 } else if (jQuery.browser.version == "8.0" || jQuery.browser.version == "7.0" || jQuery.browser.version == "6.0"){
		 $(this).prev().delay(1500).fadeOut(1,'easeOutQuint');
		 $(this).prev().prev().delay(1500).fadeIn(1,'easeOutQuint');
		  
		  }
	 

	 $(this).parent().parent().prev().delay(200).animate({
        height:184
    }, 1400, 'easeInOutQuint');
	 
	 $(this).parent().parent().prev().delay(200).animate({
	        height:184
	        }, 1400, 'easeInOutQuint');
	    	$(this).parent().delay(200).animate({
	            height:184
	            }, 1400, 'easeInOutQuint');

	 $('#gallerychef').data('nivoslider').stop();
	

	 $(this).children('.apri_info').delay(2000).fadeIn(500,'easeOutQuint');
	 $(this).children('.apri_info_tobimova').delay(2000).fadeIn(500,'easeOutQuint');


 return false;
 });


 
 
 
    
$().UItoTop({ easingType: 'easeOutQuart' });




$(".cantina a").toggle(function (){

	$(this).children('.apri_info').delay(100).fadeOut(500,'easeOutQuint');
	$(this).children('.apri_info_tobimova').delay(100).fadeOut(500,'easeOutQuint');
	
	if ($.browser.mozilla || $.browser.safari || jQuery.browser.version == "9.0") {
		$(this).prev().prev().fadeOut(500,'easeOutQuint');
		$(this).prev().delay(500).fadeIn(800,'easeOutQuint');
		
		$(this).parent().parent().prev().delay(550).animate({
	        height:427
	    }, 1400, 'easeInOutQuint');
		
		$(this).parent().delay(550).animate({
	        height:427
	    }, 1400, 'easeInOutQuint');
		
		  } else if (jQuery.browser.version == "8.0" || jQuery.browser.version == "7.0" || jQuery.browser.version == "6.0"){
			  $(this).prev().prev().delay(300).fadeOut(1,'easeOutQuint');
				$(this).prev().delay(300).fadeIn(1,'easeOutQuint');
				
				$(this).parent().parent().prev().delay(302).animate({
			        height:427
			    }, 1400, 'easeInOutQuint');
				
				$(this).parent().delay(302).animate({
			        height:427
			    }, 1400, 'easeInOutQuint');
		  }
	

	
	

	$('#gallerycantina').nivoSlider({
			effect:'fold',
	        directionNav:true,
	        directionNavHide:false,
	        controlNav:false,
	        pauseTime:6000,
	        prevText: '',
	        nextText: ''

	    });
	
	$(this).children('.chiudi_info').delay(800).fadeIn(500,'easeOutQuint');
	$('#gallerycantina').data('nivoslider').start();

    return false;
 },function () {
	 $(this).children('.chiudi_info').delay(100).fadeOut(100,'easeOutQuint');
	 

	 if ($.browser.mozilla || $.browser.safari || jQuery.browser.version == "9.0") {
		 $(this).prev().delay(1500).fadeOut(400,'easeOutQuint');
		 $(this).prev().prev().delay(1900).fadeIn(500,'easeOutQuint');
	 } else if (jQuery.browser.version == "8.0" || jQuery.browser.version == "7.0" || jQuery.browser.version == "6.0"){
		 $(this).prev().delay(1500).fadeOut(1,'easeOutQuint');
		 $(this).prev().prev().delay(1500).fadeIn(1,'easeOutQuint');
		  
		  }
	 

	 $(this).parent().parent().prev().delay(200).animate({
        height:184
    }, 1400, 'easeInOutQuint');
	 
	 $(this).parent().parent().prev().delay(200).animate({
	        height:184
	        }, 1400, 'easeInOutQuint');
	    	$(this).parent().delay(200).animate({
	            height:184
	            }, 1400, 'easeInOutQuint');

	 $('#gallerycantina').data('nivoslider').stop();
	

	 $(this).children('.apri_info').delay(2000).fadeIn(500,'easeOutQuint');
	 $(this).children('.apri_info_tobimova').delay(2000).fadeIn(500,'easeOutQuint');


 return false;
 });


 
 
 
    



});






