$(document).ready(
	function() {

		//
		// BEGIN dropdowns
		$("#nav").superfish({
			hoverClass: 'sfhover',
			delay: 250,
			animation: {opacity:'show'},
			speed: 'fast'
		});
		// END dropdowns
		//

		// BEGIN toggling row info content
		// $("#toggle_addl_options").bind('click', toggle_addl_options);
		// END toggling row info content
		
		// BEGIN opening external resource URLs in new window
		/*
		$("a[@href^=http]").each(
			function(){
				if(this.href.indexOf(location.hostname) == -1) { 
					$(this).attr('target', '_blank');
				}
			}
		);
		*/

		$("a[href^='http:']:not([href*='" + window.location.host + "'][target='_blank'])").live('click', function(){
			$(this).attr('target','_blank');
		});
		// END opening external resource URLs in new window
		
		$("#finding-aid").treeview({
			animated: "fast",
			collapsed: true,
			control: "#finding-aid-controls",
			persist: "location",
			unique: false
		});
		
	}
);

var toggle_addl_options = function(e) {
	var targetContent = $("#addl_search_options");
	if (targetContent.css("display") == "none") {
		targetContent.slideDown(200);
		$(this).attr("class","");
		$("#addl_search_options select").attr("disabled","");
	} else {
		targetContent.slideUp(200);
		$(this).attr("class","closed");
		$("#addl_search_options select").attr("disabled","disabled");
	}
	return false;
};