$(window).load(function () {
    if ($("#slider img").size() > 1) {

        $("#slider").nivoSlider({
            effect: 'sliceDown',
            slices: 10,
            animSpeed: 400,
            pauseTime: 4500,
            startSlide: 0,
            directionNav: true,
            directionNavHide: true,
            controlNav: false,
            controlNavThumbs: false,
            controlNavThumbsFromRel: false,
            controlNavThumbsSearch: '.jpg',
            controlNavThumbsReplace: '_thumb.jpg',
            keyboardNav: true,
            pauseOnHover: false,
            manualAdvance: false,
            captionOpacity: 0.8,
            beforeChange: function () { },
            afterChange: function () { },
            slideshowEnd: function () { },
            lastSlide: function () { },
            afterLoad: function () { }
        });
    }
});

$(document).ready(function () {

    //$(document).pngFix();
    /*
    $('#30anni-cont').animate({ top: '100' }, 500, function () {
        $('#30anni').rotate({ animateTo: 360 });
    });

    var rotation = function () {
        $("#30anni").rotate({
            angle: 0,
            animateAngle: 360,
            callback: rotation
        });
    }
    */

    $("#main").scrollable({

        vertical: true,

        circular: true,

        keyboard: 'static',

        onSeek: function (event, i) {
            horizontal.eq(i).data("scrollable").focus();
        }

    }).navigator("#main_navi");

    var horizontal = $(".scrollable").scrollable({ circular: true }).navigator(".navi");


    //horizontal.eq(0).data("scrollable").focus();


    ///////////////////////////////////////////////////////////////////////////
    //$(function() {
    $('.prodotto-img-scatola').each(function () {
        $(this).hover(function () {
            $(this).stop().animate({ opacity: 1.0 }, 100);
        },
       		function () {
       		    $(this).stop().animate({ opacity: 0.80 }, 100);
       		});
    });
    //});
    ///////////////////////////////////////////////////////////////////////////

    //$(function() {
    //tabs
    $("ul.tabs").tabs("div.panes-inner");

    /*
    $('ul.tabs').click(function(){	  
    $(".toggle_container").hide(); 	
    $("h2.trigger").removeClass("active");	 
    });
    */

    $('ul.tabs').click(function () {
        //$(".panes-inner").height(400).css({}); 	

    });


    //});		

    ///////////////////////////////////////////////////////////////////////////		

    //$(function() {

    $('.backtotop').click(function () {
        $('html, body').animate({ scrollTop: 0 }, 'fast');
    });

    //});

    ///////////////////////////////////////////////////////////////////////////			  
    //$(function() {


    $(".toggle_container").hide();

    $("h2.trigger").toggle(function () {
        $(this).addClass("active");
    }, function () {
        $(this).removeClass("active");
    });

    $("h2.trigger").click(function () {
        $(this).next(".toggle_container").slideToggle("fast");


        //$(".panes-inner").height(2200).css({}); 


    });

    //});			




});


function VerificaForm() {

    var checkemail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

    if (!checkemail.test($("#email").val())) {
        alert('Inserire un indirizzo e-mail valido');
        return false;
    }
    if ($("#email").val() == "" || $("#email").val() == undefined || $("#email").val() == null) {
        alert('Inserire un mittente');
        return false;
    }
    if ($("#testo").val() == "" || $("#testo").val() == undefined || $("#testo").val() == null) {
        alert('Inserire un testo');
        return false;
    }
    if ($("#nome").val() == "" || $("#nome").val() == undefined || $("#nome").val() == null) {
        alert('Inserire un nome');
        return false;
    }
    if ($("#cognome").val() == "" || $("#cognome").val() == undefined || $("#cognome").val() == null) {
        alert('Inserire un cognome');
        return false;
    }
    if ($("#azienda").val() == "" || $("#azienda").val() == undefined || $("#azienda").val() == null) {
        alert('Inserire una azienda');
        return false;
    }
    if ($("#telefono").val() == "" || $("#telefono").val() == undefined || $("#telefono").val() == null) {
        alert('Inserire un numero di telefono');
        return false;
    }

    return true;

}


function InviaForm() {
    xmlhttpPost('Contatti.php', 'FormContatti', 'FormContattiRisultato', '<img src=img/loading.gif border=0 alt=Invio in corso...>');
}

	
///////////////////////////////////////////////////////////////////////////		   
///////////////////////////////////////////////////////////////////////////		
