function init(){

	var animating = false; //Flag to control animation, only one item can be animating at any given time.

	var switchPane = function(obj, parentDiv) {
	
		parentDiv = "#"+parentDiv; //Add the hash mark for jQuery.
		
		var currentParentHeight = $(parentDiv).height();
	
		if (!animating) {
			if (!($(obj).next().is(":visible"))) {
				animating = true;
				
				$(parentDiv + " h3.toggler").removeClass("selected");
				$(obj).addClass("selected");

				//If the element ISN'T the last toggler, or the last div.element ISN'T visible
				if (!($(parentDiv + " div.element:last").is(":visible")) && !($(parentDiv + " h3.toggler:last").is(".selected"))){
					//Set the parent div's height, and it's position to relative
					$(parentDiv).css({position: "relative", height: currentParentHeight});
	
					//Set the last toggler position to absolute and bottom to 0 so that the "accordion" runs smoothly.
					$(parentDiv + " h3.toggler:last").css({position: "absolute", bottom: 0});
				}

				$(parentDiv + " div.element:visible").slideUp(200);
				$(obj).next().slideDown(200, function(){

					animating = false;
				
					//Remove CSS attributes that may have been added above.
					$(parentDiv).css({position: "", height: ""});
					$(parentDiv + " h3.toggler:last").css({position: "", bottom: ""});
				});
			}
		}
	};

	//Initialize the content panes
	$("#secondary div.element:not(:first)").hide();
	$("#secondary h3.toggler:first").addClass("selected");
	$("#tertiary div.element:not(:first)").hide();
	$("#tertiary h3.toggler:first").addClass("selected");

	//Add event handlers
	$("h3.toggler").mouseover(function(){switchPane(this, this.parentNode.id);});
	$("h3.toggler a").focus(function(){switchPane(this.parentNode, this.parentNode.parentNode.id);});
}

$(function(){init();});
	
//Hold safari's hand
window.onload=function(){
	if ($.browser.safari) {
		init();		
	}
}