
							



$(document).ready(function(){

	if($('#header').length && !$.browser.msie){

		$('#logo-bg').fadeIn('slow',function(){
			$('#logo-bg').fadeOut('slow');
		})

		
		if($('#carousel').length){
			$('#carousel').goCarousel();
		}
		
	}
	
    // Menu stile
    $('#menu_top').menu();
	
   // Liste fancybox
    $(".fancybox-list").fancyboxList();
    $(".mycarousel").fancyboxList();
				
    // Liste fancybox
    $("a.fancybox").fancybox();

    // Link fancybox
    $("a.fancybox-iframe").fancybox({
        'zoomSpeedIn': 500,
        'zoomSpeedOut': 500,
        'speedIn': 600,
        'speedOut': 200,
        'autoScale': false,
        'type': 'iframe',
        'width': 640,
        'height': $(window).height()*0.85
    });




	if($('.marque').length){	

/* 	$('.marque').vTicker({
           speed: 800,
           pause: 7500,
           showItems: 2,
           animation: ' ',
           mousePause: true
          });	
*/
		  
	} 
});





// -- Plugin menu stili ----------------------------------------------------- //

(function($){
    $.fn.menu = function() {

        return this.each(function() {

            $(this).find('li').each(function(){

                var $container = $(this);
                var $trigger = $container.children('a');
                var $menu = $container.children('ul');

                if($menu.length == 0)
                    return true

                $menu.mouseover(function(){
                    $container.data('hover', true);
                }).mouseout(function(){
                    $container.data('hover', false);
                }).css({'display': 'none'});

                $trigger.click(function(event){
                    event.preventDefault();
                    event.stopPropagation();

                    // Chiusura menu
                    if($container.data('open')){
                        $menu.css('display', 'none');
                        $(document).unbind('click.menu');
                        $container.data('open', false);

                    // Apertura menu
                    }else{
                        $menu.fadeIn(200);
                        $container.data('open', true);
                        $(document).bind('click.menu', function(){
                            if(!$container.data('hover')){
                                $menu.css('display', 'none');
                                $(document).unbind('click.menu');
                                $container.data('open', false);
                            }
                        });
                    }
                });
            });
        });
    };
})(jQuery);





// -- Plugin Liste Fancybox ------------------------------------------------- //

(function($){
    $.fn.fancyboxList = function(config) {
        var counter = 0;
        return this.each(function() {
            counter++;
            $(this).find('a').each(function(){
                $(this).attr('rel', 'fancybox-list-'+counter);
                $(this).fancybox(config);
            });
        });
    };
})(jQuery);
	

// -- jCarousel ------------------------------------------------- //

function mycarousel_initCallback(carousel)
		// documentation http://sorgalla.com/projects/jcarousel/
		{
		    // Disable autoscrolling if the user clicks the prev or next button.
		    carousel.buttonNext.bind('click', function() {
		        carousel.startAuto(0);
		    });
		
		    carousel.buttonPrev.bind('click', function() {
		        carousel.startAuto(0);
		    });
		
		    // Pause autoscrolling if the user moves with the cursor over the clip.
		    carousel.clip.hover(function() {
		        carousel.stopAuto();
		    }, function() {
		        carousel.startAuto();
		    });
		};
		
		jQuery(document).ready(function() {
			if(jQuery('.mycarousel').length)
		    jQuery('.mycarousel').jcarousel({
		        auto: 1,
		        wrap: 'circular',
				animation: 2500,
				scroll: 1,
				easing: 'swing', // VAR: easeOutBack, easeOutElastic, swing, linear
				buttonNextHTML: null,
				buttonPrevHTML: null,
		        initCallback: mycarousel_initCallback
		    });
		});

