jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        initCallback: mycarousel_initCallback,
        buttonNextHTML:null,
        buttonPrevHTML:null,
        wrap:"both",
        scroll:4
    });
    jQuery('#mycarousel_opere').jcarousel({
        initCallback: mycarousel_opere_initCallback,
        buttonNextHTML:null,
        buttonPrevHTML:null,
        wrap:"both",
        scroll:4
    });
    //box_hover();
    inner_box_hover();
    inner_box_click();
}); 

function box_hover (){
    jQuery('#collezioni').hover(
        function(){
            console.log("in");
            jQuery('#mycarousel-collezioni-prev').fadeIn();
            jQuery('#mycarousel-collezioni-next').fadeIn();
        },
        function(){
            console.log("out");
            jQuery('#mycarousel-collezioni-prev').fadeOut();
            jQuery('#mycarousel-collezioni-next').fadeOut();
        }
    );

    jQuery('#opere_evidenza').hover(
        function(){
            jQuery('#mycarousel-opere-prev').fadeIn();
            jQuery('#mycarousel-opere-next').fadeIn();
        },
        function(){
            jQuery('#mycarousel-opere-prev').fadeOut();
            jQuery('#mycarousel-opere-next').fadeOut();
        }
    );
}

function inner_box_click(){
    jQuery('.opera').click(
        function(){
           splitted_id = (this.id).split('_'); 
           inv = splitted_id[2];
           document.location.href='/'+inv;
        }
    );
    jQuery('.collezione').click(
        function(){
           collection = (this.id);
           document.location.href=collection;
        }
    );
    jQuery('.indice').click(
        function(){
            document.location.href='/'+this.id+'.php';
        }
    );
}

function inner_box_hover(){
    jQuery('.inner_box').hover(
        function(){
            jQuery(this).next().css({color:'#FFB300'});
        },
        function(){
            jQuery(this).next().css({color:'white'});
        }
    );
    jQuery('.box_title').hover(
        function(){
            jQuery(this).css({color:'#FFB300'});
        },
        function(){
            jQuery(this).css({color:'white'});
        }
    );
}

function mycarousel_initCallback(carousel) {
    jQuery('#mycarousel-collezioni-next').bind('click', function() {
        carousel.next();
        return false;
    });
    jQuery('#mycarousel-collezioni-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};
function mycarousel_opere_initCallback(carousel) {
    jQuery('#mycarousel-opere-next').bind('click', function() {
        carousel.next();
        return false;
    });
    jQuery('#mycarousel-opere-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};


