$(document).ready(function() {
	$("#tabsnav div").each(function(){
	    var blockId = $(this).attr("id");
	    if (blockId != ""){
	    	$(this).hide();
	    }
	});

	var activeTab = $.cookie("ALADDIN_ACTIVE_TAB");
	activeTab = activeTab ? activeTab : "tab1";
	$("#" + activeTab + "content").show();
	
	$("#tabsnav div.tabs a").each(function(i){
                $(this).removeClass("tab" + (i + 1) + "active");
                $(this).addClass("tab" + (i + 1));
	});
	
	$("#" + activeTab).removeClass(activeTab);
	$("#" + activeTab).addClass(activeTab + "active");

	$("#tabsnav div.tabs a").click(function(){
		var id = $(this).attr("id");
		$("#tabsnav div.tabs a").each(function(i){
                	$(this).removeClass("tab" + (i + 1) + "active");
                	$(this).addClass("tab" + (i + 1));
		});

                $(this).removeClass(id);
                $(this).addClass(id + "active"); 

		$("#tabsnav div").each(function(){
		    var blockId = $(this).attr("id");
		    if (blockId != ""){
		    	$(this).hide();
		    }
		});
		
		$("#" + id + "content").show();

		$.cookie("ALADDIN_ACTIVE_TAB", id, {
			expires: 0,
			path: "/"
		});
		
		return false;
	});

	hideEventTypeTabs();
	//$("#seminars").show();
	//showFirstEventTypeTabs();
	$("ul.events-list:first").show();
	$("a.event-type-changer:first").addClass("active");

	$("a.event-type-changer").click(function(){
		var id = $(this).attr("href");
		hideEventTypeTabs();
		$(id).show();
		$(this).addClass("active");
		return false;
	});

	function hideEventTypeTabs(){
		$("a.event-type-changer").each(function(){
			var id = $(this).attr("href");
			$(id).hide();
			$(this).removeClass("active");
		});
	}

});
