$(window).load(function() {
	$('#featured').orbit({
		 animation: 'fade',                  // fade, horizontal-slide, vertical-slide, horizontal-push
		 animationSpeed: 800,                // how fast animtions are
		 timer: true, 			 // true or false to have the timer
		 advanceSpeed: 4000, 		 // if timer is enabled, time between transitions 
		 pauseOnHover: false, 		 // if you hover pauses the slider
		 startClockOnMouseOut: false, 	 // if clock should start on MouseOut
		 startClockOnMouseOutAfter: 1000, 	 // how long after MouseOut should the timer start again
		 directionalNav: false, 		 // manual advancing directional navs
		 captions: false, 			 // do you want captions?
		 captionAnimation: 'fade', 		 // fade, slideOpen, none
		 captionAnimationSpeed: 800, 	 // if so how quickly should they animate in
		 bullets: false,			 // true or false to activate the bullet navigation
		 bulletThumbs: false,		 // thumbnails for the bullets
		 bulletThumbLocation: '',		 // location from this file where thumbs will be
		 afterSlideChange: function(){} 	 // empty function 
	});
	$('#featured_int').orbit({
		 animation: 'fade',                  // fade, horizontal-slide, vertical-slide, horizontal-push
		 animationSpeed: 800,                // how fast animtions are
		 timer: true, 			 // true or false to have the timer
		 advanceSpeed: 4000, 		 // if timer is enabled, time between transitions 
		 pauseOnHover: false, 		 // if you hover pauses the slider
		 startClockOnMouseOut: false, 	 // if clock should start on MouseOut
		 startClockOnMouseOutAfter: 1000, 	 // how long after MouseOut should the timer start again
		 directionalNav: false, 		 // manual advancing directional navs
		 captions: false, 			 // do you want captions?
		 captionAnimation: 'fade', 		 // fade, slideOpen, none
		 captionAnimationSpeed: 800, 	 // if so how quickly should they animate in
		 bullets: false,			 // true or false to activate the bullet navigation
		 bulletThumbs: false,		 // thumbnails for the bullets
		 bulletThumbLocation: '',		 // location from this file where thumbs will be
		 afterSlideChange: function(){} 	 // empty function 
	});
});
$(document).ready(function(){
	
	$('li.item_hover').hover(function(){
		$(this).children('ul').show();
	},function(){
		$(this).children('ul').hide();
	});
    
    $('.selectPdf select').change(function() {
        var datas = $(this).val();
        var id_prodotto = $(this).attr("id");
		var id_prodotto_topass = id_prodotto.replace("prod", "");
        //alert(id_prodotto_topass);
        if(datas!=''){
            $.post("inc/downloadPdf.php", { id:datas,id_prod:id_prodotto_topass },function(data) {	
                $('a.download').attr('href','documents/'+data);
            });
        }else{
            $('a.download').attr('href','#');
            return false;
        }
        
    });
    
    $('a.download').click(function() {
        var data = $(this).attr("href");
        if(data=='#'){
            alert('Seleziona la tipologia di prodotto');
            return false;
        }
    });
		
	$('#searchForm input[type="text"]').focus(function() {
		$(this).val("");
	});
	
	$('.products-home-imgs a').hover(function(){
		var widthLink = $(this).width();
		var posLeft = (widthLink / 2)-19;
		$(this).append('<div class="product-arrow"><img src="images/product-arrow.png" border="0"/></div>');
		$('.product-arrow',this).css("position","absolute").css("bottom","0").css("left",posLeft).show();
	},function(){
		$('.product-arrow',this).hide();
	});
	
	$("#contactForm").validate({
		rules: {
			fullname: "required",
			email: {
				required: true,
				email: true
			},
			privacy: "required"
		},
		messages: {
			fullname: "Inserisci il tuo nome e cognome",
			email: "Inserisci un indirizzo email valido",
			privacy: "Accettare i termini di utilizzo e privacy"
		}
	});
	setTimeout(addShadows, 1);
});
