$.fn.tggl = function() {
	var lock = 0;
	return this.click(function() {
		var $this = $(this);
		var $icon = $this.find("span.ui-icon:first");
		var options = {};
		var id = $this.attr("id");
		if (lock == 0) {
			$.post("php/menue_session.php", { id: id });
			if($icon.is('.ui-icon-triangle-1-e')) {
				$icon.removeClass("ui-icon-triangle-1-e").addClass("ui-icon-triangle-1-s");
				$this.find("ul:first").show("blind", options, 300);
			} else { 
				$icon.removeClass("ui-icon-triangle-1-s").addClass("ui-icon-triangle-1-e");
				$this.find("ul:first").hide("blind", options, 300);
			}
		}
		lock = 1;
		setTimeout(function(){ lock = 0; }, 100);
	});
};

$(function() {
	$(".treebrowser").find("li").add(".pagebar").find("li").click(function(ev) {
		var id = ev.target.id;
		if (id.substr(0,1) == "p") {
			var pid = id.substr(2,(id.length-2))
			window.location.href = "Seite-"+pid;
		}
	}); 
	
	$('.lightbox a').lightBox();
	
	$(".treebrowser").find("ul > li").tggl();
	
	hihglight();
});