$(document).ready(function (){
$(".tab-nav").width($(window).width()-340)
$(".tab-nav .main").css("margin-left",$(window).width()-545);
});
$(window).resize(function () {
$(".tab-nav").width($(window).width()-340)
$(".tab-nav .main").css("margin-left",$(window).width()-545);
});

$(document).ready(function(){
$('#slide_centro').cycle({ 
cleartype:  1 ,
timeout:  5000,
speed: 800
});
});

function galleria(immagine, link, didascalia) {
$('#galleria img').remove();
$('#galleria').addClass('loading');
$('#didascalia').text(didascalia);
$('#'+link).click(function () {
var $linkselect = $('#'+link+' img');
$('#content img').css({'border' : '4px solid #DDDDDD'});
$linkselect.css({'border' : '4px solid #C6E200'});	
});
 var img = new Image();
$(img).load(function () {
$(img).hide();
$('#galleria').removeClass('loading').append(img);
$(img).fadeIn('slow');
}).error(function () {
//ERRORE
}).attr('src', immagine)
}; 


function formatText(index, panel) {
return index + "";
}

$(function () {
$('.anythingSlider').anythingSlider({
easing: "easeInOutExpo",
autoPlay: true,
delay: 3000,
startStopped: false,
animationTime: 600,
hashTags: true,
buildNavigation: false,
pauseOnHover: true,
startText: "",
stopText: "",
navigationFormatter: formatText
});
});








//SLIDE SUI PRODOTTI
$(document).ready(function(){
$('.slide_prodotti').cycle({ 
cleartype:  1 ,
timeout:  5000,
speed: 800
});
});
/**************************************************************************************************/

$(document).ready(function() {
$("#selezionato").show();
$("ul#topnav li.selezionato").css({ 'background' : '#C6E200'});
$("ul#topnav li").hover(function() {
$("ul#topnav li").css({ 'background' : '#F3F3F3'});
$("#selezionato").hide();//Hover over event on list item
$(this).css({ 'background' : '#C6E200 url(topnav_active.gif) repeat-x'}); //Add background color + image on hovered list item
$(this).find("span").show(); //Show the subnav
},function() { //on hover out...
$(this).css({ 'background' : '#F3F3F3'});//Ditch the background
$("ul#topnav li.selezionato").css({ 'background' : '#C6E200'});
$(this).find("span").hide();
$("#selezionato").show();//Hide the subnav
});
});




//QUESTO E' PER TENERE NAVIGATORE O ROBA DEL GENERE IN POSIZIONE FISSA ORA CE IL DIV INFO
/*$().ready(function() {
var $scrollingDiv = $("#info");
$scrollingDiv.css({"bottom": "40px"});		
$(window).scroll(function(){			
$scrollingDiv
.stop()
.animate({"marginTop": ($(window).scrollTop()-20) + "px"}, "fast" );			
});
$(window).resize(function(){
if($(window).height()>350)
$scrollingDiv.css({"top": $(window).height()-90+"px"});			
});		
});*/
/**************************************************************************************************/


$(document).ready(function (){
$("#ifram").width($(window).width()-60)
$("#ifram").height($(window).height()-200)
});


$(window).resize(function () {
/*if($(window).width()<960)
{
$("#modello_web").css('width', '960px');
}
else
{
$("#modello_web").css('width', '100%');
}*/
$("#ifram").width($(window).width()-60)
$("#ifram").height($(window).height()-200)
});



$(document).ready(function(){		
$(".cover").stop().animate({top:'170px'},{queue:false,duration:160});
$(".coverm").stop().animate({top:'110px'},{queue:false,duration:160});
$(".coverbig").stop().animate({top:'290px'},{queue:false,duration:160});
				$('.boxgrid.slidedown').hover(function(){
					$(".cover", this).stop().animate({top:'-260px'},{queue:false,duration:300});
				}, function() {
					$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
				});
				$('.boxgrid.slideright').hover(function(){
					$(".cover", this).stop().animate({left:'325px'},{queue:false,duration:300});
				}, function() {
					$(".cover", this).stop().animate({left:'0px'},{queue:false,duration:300});
				});
				$('.boxgrid.thecombo').hover(function(){
					$(".cover", this).stop().animate({top:'260px', left:'325px'},{queue:false,duration:300});
				}, function() {
					$(".cover", this).stop().animate({top:'0px', left:'0px'},{queue:false,duration:300});
				});
				$('.boxgrid.peek').hover(function(){
					$(".cover", this).stop().animate({top:'190px'},{queue:false,duration:160});
				}, function() {
					$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
				});
				$('.boxgrid.captionfull').hover(function(){
					$(".coverm", this).stop().animate({top:'110px'},{queue:false,duration:160});
				}, function() {
					$(".coverm", this).stop().animate({top:'110px'},{queue:false,duration:160});
				});
					$('.boxgrid.nocaption').hover(function(){
					$(".cover", this).stop().animate({top:'150px'},{queue:false,duration:160});
				}, function() {
					$(".cover", this).stop().animate({top:'170px'},{queue:false,duration:160});
				});
				$('.boxgrid.caption').hover(function(){
					$(".cover", this).stop().animate({top:'110px'},{queue:false,duration:160});
				}, function() {
					$(".cover", this).stop().animate({top:'170px'},{queue:false,duration:160});
				});
						$('.bigboxgrid.caption').hover(function(){
					$(".coverbig", this).stop().animate({top:'240px'},{queue:false,duration:160});
				}, function() {
					$(".coverbig", this).stop().animate({top:'290px'},{queue:false,duration:160});
				});
});


$(document).ready(function() {
  $('#tab-nav-1 > ul > li > a').click(function() {
    var $parentItem = $(this).parent(),
        slideAmt = $(this).next().width(),
        direction;

    if (parseInt($parentItem.css('marginLeft'), 10) < 0) {
      direction = '+=';
      $(this).removeClass('expanded');
    } else {
      $(this).addClass('expanded');
      direction = '-=';
    }
    $parentItem
      .animate({marginLeft: direction + slideAmt}, 400);
    return false;
  });
 
});

$(document).ready(function() {
  var $topLinks2 = $('#tab-nav-2 > ul > li > a');
  $topLinks2.click(function() {
    var $parentItem = $(this).parent(),
       slideAmt = $(this).next().width(),
        direction;
    $topLinks2.removeClass('expanded');
    if (parseInt($parentItem.css('marginLeft'), 10) < 0) {
      direction = '+=';
    } else {
      $(this).addClass('expanded');
      direction = '-=';
    }
    $parentItem
      .animate({marginLeft: direction + slideAmt}, 400)
        .siblings()
        .animate({marginLeft: '0'}, 150);
    return false;
  });
});


$(document).ready(function() {
  var closeAll,
      $topLinks3 = $('#tab-nav-3 > ul > li > a');

  $('#tab-nav-3 ul ul').css('opacity', '0.7');
  
  setTabIndex();
  
  $topLinks3.click(function() {
    var $parentItem = $(this).parent(),
        slideAmt = $(this).next().width(),
        direction;
    $topLinks3.removeClass('expanded');
    if (parseInt($parentItem.css('marginLeft'), 10) < 0) {
      direction = '+=';
    } else {
      $(this).addClass('expanded');
      direction = '-=';
    }
    $parentItem
    .animate({marginLeft: direction + slideAmt}, 400)
      .siblings()
      .animate({marginLeft: '0'}, 150);
        
    setTabIndex();
    
    return false;
  });
  
  $('#tab-nav-3')
  .mouseleave(function() {
    closeAll = setTimeout(function() {
      $topLinks3.removeClass('expanded').parent().animate({marginLeft: '0'}, 150);
    }, 1000);
  }).mouseenter(function() {
    clearTimeout(closeAll);
  });

  function setTabIndex() {
    $topLinks3.each(function(index) {
      if ($(this).is('.expanded')) {
        $(this).next().find('a').removeAttr('tabIndex');
      } else {
        $(this).next().find('a').attr({tabIndex: '-1'});
      }
    });
  }

  
});

/*FANCYBOX*/
jQuery(document).ready(function() {
$("#flv1,#flv2,#flv3,#flv4,#flv5,#flv6,#flv7,#flv8,#flv9,#flv10,#flv11").fancybox({
	'width'				: 375,
		'height'			: 320,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
});

	$("#cpw").fancybox({
		'width'				: '75%',
		'height'			: '50%',
    'autoScale'     	: false,
    'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
});	
	
