/*
 * Toolbox initialisieren
 */
$(document).ready(function() {
	// quicksearch open by default
	$("#z35-toolbox .tool-wrapper").hide();
	/*
	$("#z35-toolbox ul li a:first").addClass("active");
	$("#z35-toolbox .tool-wrapper:first").show();
	*/
	
	// add onclick event to all tool links
	/*
	$("#z35-toolbox ul li a").click(function() {
		$("#z35-toolbox ul li a").toggleClass("active");
		$("#z35-toolbox .tool-wrapper").toggle();
		$(this).toggleClass("active");
		$("#"+$(this).attr("rel")).toggle();
		return false;
	});
	*/
	
	
	$("#z35-toolbox ul li a").click(function() {
		var source 	= $(this);
		var target 	= $('#'+$(this).attr("rel"));
		var toggled	= false;
		if ($(this).attr("rel")=="z35-toolbox-print" && $(this).attr("class")!="active") {
			window.print();
		}
		$("#z35-toolbox .tool-wrapper").each(function() {
			if ($(this).attr("id")!=target.attr("id")) {
				if ($(this).css("display") != "none") {
					if ($.browser.msie) {
    					$(this).toggle();
					} else {
						toggled = true
    					$(this).slideToggle(function() {
    						target.slideToggle();
    						source.toggleClass("active");
    					});
					}
					$("#z35-toolbox ul li a[@rel='"+$(this).attr("id")+"']").toggleClass("active");	
				}
			}
		});
		if (!toggled) { 
			if ($.browser.msie) {
				target.toggle();
			} else {
				target.slideToggle();
			}
			source.toggleClass("active");
		}
		return false;
	});
	
	
});
