// JavaScript Document
jQuery(document).ready(function() {
	jQuery.noConflict();
	loadContent("eventi.php", "div#eventi_container");
    jQuery("ul#eventi li div.accordion_content").hide();
	jQuery("a.next").click(function () {	
			jQuery("div.giorni_wrapper").animate({ scrollLeft: '+=450px'}, 700 );
			jQuery("a.prev").css({ display: 'block'}); return false;
	});
	jQuery("a.prev").click(function () {	
			jQuery("div.giorni_wrapper").animate({ scrollLeft: '-=450px'}, 700 ); 
			jQuery("a.prev").css({ display: 'none'}); return false;
	});
	 
  	jQuery("ul#eventi>li>a").live("click", function() { 
      	jQuery(this).addClass("current"); 
      	var $subnav = jQuery(this).next(); 
        if($subnav.is(":visible")) {
        	$subnav.animate({height: "toggle"}, 750, "easeInOutExpo").prev().removeClass("current"); 
        } 
        if(!$subnav.is(":visible")) { 
        jQuery("ul#eventi li div.accordion_content:visible").animate({height: "toggle"}, 750, "easeInOutExpo").prev().removeClass("current"); 
        $subnav.animate({height: "toggle"}, 750, "easeInOutExpo"); 
        } 
        return false; 
    });
	
	jQuery("dl.agenda_giorni dd a").click(function() { 
      	jQuery(this).addClass("current").parent().parent().find("a").not(jQuery(this)).removeClass("current");
				loadContent(this.href, "div#eventi_container");
				return false;
		});


	jQuery("ul.legenda li a").click(function() {
      	jQuery(this).addClass("current").parent().parent().find("a").not(jQuery(this)).removeClass("current");
				loadContent(this.href, "div#eventi_container");
				return false;
		});


	});

function loadContent(path, container) {
	if(path != "")
	jQuery.ajax({	
		url: path,
		dataType: 'html',
		async: true, 
		success: function(data){
			jQuery(container).css("display", "none").html("<div class='"+container+"'>"+data+"</div>").fadeIn(300);
			jQuery("ul#eventi li div.accordion_content").hide();
		}
	});
	
}

