function show_element(element_id) {
	var i = 0;
	do {
		i++;
		var div_element = document.getElementById("Origins_elements_" + i);
		if (div_element) {
			title_element = document.getElementById("title_Origins_elements_" + i);
			if (element_id == i) {
				  $("div#Origins_elements_" + element_id).show("slow");
				//div_element.style.display = 'block';
				//if (title_element) title_element.style.textDecoration = "underline";
				if (title_element) title_element.className = "menu_selected";
				
			}
			else {
				div_element.style.display = 'none';
				if (title_element) title_element.className = "";
				//if (title_element) title_element.style.textDecoration = "none";
			}
		}
	}
	while (div_element); 
}

function loadEventsCalendar(month, year, root) {
	$("#calendario").load(root+"eventi/nuovocalendario/mese-"+month+"/anno-"+year+"/");
}


/** 
	JCarousel
 */
function topcarousel_initCallback(carousel) {
    
    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });
    
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

function bottomcarousel_initCallback(carousel) {
    
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

// Ride the carousel...
jQuery(document).ready(function() {
   /* jQuery("#evidenze_primarie_slider").jcarousel({
        auto: 2,
        wrap: 'last',
        initCallback: toptomcarousel_initCallback,
         // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });*/
     jQuery("#evidenze_secondarie_slider").jcarousel({
        auto: 2,
        wrap: 'last',
        initCallback: bottomcarousel_initCallback
    });
});
