$(document).ready(function(){

        function slidetab() {
                $('.slide-tab .immagini').carouFredSel({
                items		: 1,
                scroll		: {
                        fx			: "crossfade"
                },
                duration	: 5000,
                direction	: "up",
                auto:{pauseDuration : 10000}
                });
        };
        
        $('#pannello-1').hide();
        $('#pannello-2').hide();
        $('#pannello-3').hide();
        $('#pannello-4').hide();
        
        $("a").livequery('click', function(event) {
                $(this).blur();
        });
        
        $(".tab-1.disattivo").livequery('click', function(event) {
        
                $(this).removeClass("disattivo").addClass("attivo");
                $('#pannello-1').fadeIn(900);
                $('#pannello-2').fadeOut(900);
                $('#pannello-3').fadeOut(900);
                $('#pannello-4').fadeOut(900);
                document.getElementById("tab-2").classList.add("disattivo");
                document.getElementById("tab-2").classList.remove("attivo");
                document.getElementById("tab-3").classList.add("disattivo");
                document.getElementById("tab-3").classList.remove("attivo");
                document.getElementById("tab-4").classList.add("disattivo");
                document.getElementById("tab-4").classList.remove("attivo");
                slidetab();
                return false;
        });

        $(".tab-1.attivo").livequery('click', function(event) {
                $(this).removeClass("attivo").addClass("disattivo");
                $('#pannello-1').fadeOut(900);
                return false;
        });
        
        $(".tab-2.disattivo").livequery('click', function(event) {
                $(this).removeClass("disattivo").addClass("attivo");
                
                $('#pannello-2').fadeIn(900);
                $('#pannello-1').fadeOut(900);
                $('#pannello-3').fadeOut(900);
                $('#pannello-4').fadeOut(900);
                
                document.getElementById("tab-1").classList.add("disattivo");
                document.getElementById("tab-1").classList.remove("attivo");
                document.getElementById("tab-3").classList.add("disattivo");
                document.getElementById("tab-3").classList.remove("attivo");
                document.getElementById("tab-4").classList.add("disattivo");
                document.getElementById("tab-4").classList.remove("attivo");
                slidetab();
                return false;
        });

        $(".tab-2.attivo").livequery('click', function(event) {
                $(this).removeClass("attivo").addClass("disattivo");
                $('#pannello-2').fadeOut(900);
                return false;
        });
        
        $(".tab-3.disattivo").livequery('click', function(event) {
                $(this).removeClass("disattivo").addClass("attivo");
                $('#pannello-3').fadeIn(900);
                $('#pannello-1').fadeOut(900);
                $('#pannello-2').fadeOut(900);
                $('#pannello-4').fadeOut(900);
                document.getElementById("tab-1").classList.add("disattivo");
                document.getElementById("tab-1").classList.remove("attivo");
                document.getElementById("tab-2").classList.add("disattivo");
                document.getElementById("tab-2").classList.remove("attivo");
                document.getElementById("tab-4").classList.add("disattivo");
                document.getElementById("tab-4").classList.remove("attivo");
                slidetab();
                return false;
        });

        $(".tab-3.attivo").livequery('click', function(event) {
                $(this).removeClass("attivo").addClass("disattivo");
                $('#pannello-3').fadeOut(900);
                return false;
        });
        
        $(".tab-4.disattivo").livequery('click', function(event) {
                $(this).removeClass("disattivo").addClass("attivo");
                $('#pannello-1').fadeOut(900);
                $('#pannello-2').fadeOut(900);
                $('#pannello-3').fadeOut(900);
                $('#pannello-4').fadeIn(900);
                document.getElementById("tab-1").classList.add("disattivo");
                document.getElementById("tab-1").classList.remove("attivo");
                document.getElementById("tab-2").classList.add("disattivo");
                document.getElementById("tab-2").classList.remove("attivo");
                document.getElementById("tab-3").classList.add("disattivo");
                document.getElementById("tab-3").classList.remove("attivo");
                slidetab();
                return false;
        });

        $(".tab-4.attivo").livequery('click', function(event) {
                $(this).removeClass("attivo").addClass("disattivo");
                $('#pannello-4').fadeOut(900);
                return false;
        });
        
        $(".rel-resort").each(function() {
                var obj = $(this);
                var obj_settings = {};
                if(obj.data("lightbox")){					
                        var jObj = jQuery.parseJSON(obj.data("lightbox").toString().replace(/'/g, '"'));
                        obj_settings = jObj;
                        obj_settings.rel = jObj.group;
                }
                                
                obj.colorbox(obj_settings);
        });
        $(".rel-ricevimenti").each(function() {
                var obj = $(this);
                var obj_settings = {};
                if(obj.data("lightbox")){					
                        var jObj = jQuery.parseJSON(obj.data("lightbox").toString().replace(/'/g, '"'));
                        obj_settings = jObj;
                        obj_settings.rel = jObj.group;
                }
                                
                obj.colorbox(obj_settings);
        });
        $(".rel-meeting").each(function() {
                var obj = $(this);
                var obj_settings = {};
                if(obj.data("lightbox")){					
                        var jObj = jQuery.parseJSON(obj.data("lightbox").toString().replace(/'/g, '"'));
                        obj_settings = jObj;
                        obj_settings.rel = jObj.group;
                }
                                
                obj.colorbox(obj_settings);
        });
        $(".rel-ristorante").each(function() {
                var obj = $(this);
                var obj_settings = {};
                if(obj.data("lightbox")){					
                        var jObj = jQuery.parseJSON(obj.data("lightbox").toString().replace(/'/g, '"'));
                        obj_settings = jObj;
                        obj_settings.rel = jObj.group;
                }
                                
                obj.colorbox(obj_settings);
        });
        
});
