$(document).ready(function() {
	//$('ul#nav').superfish({autoArrows:false});

	sfHover = function() {
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfHover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfHover\\b"), "");
			}
		}
	}
	if (window.attachEvent) window.attachEvent("onload", sfHover);

	// this function rolls up an item already displayed before the new one gets displayed
	jQuery.fn.blindSweep = function(speed, easing, callback) {
		return this.animate({height: parseInt(this.css('height')) < 50 ? 0 : 0}, speed, easing, callback);
	};

	// this function toggles the display of the clicked item's widget
	jQuery.fn.blindToggle = function(speed, easing, callback) {
		return this.animate({height: parseInt(this.css('height')) < 50 ? 150 : 0}, speed, easing, callback);
	};

	// this function slides in an item already displayed before the new one gets displayed
	jQuery.fn.sideSweep = function(speed, easing, callback) {
		return this.animate({width: parseInt(this.css('height')) < 200 ? 0 : 0}, speed, easing, callback);
	};

    jQuery.fn.sideToggle = function(speed, easing, callback) {
		return this.animate({width: parseInt(this.css('width')) < 50 ? 200 : 0}, speed, easing, callback);
	};

	$('#search_link').click(function(e) {
		e.preventDefault();
		$('#az_widget').blindSweep('slow');
		$('#links_widget').blindSweep('slow');
		$('#search_widget').sideToggle('slow');
	});
	$('#az_link').click(function(e) {
		e.preventDefault();
		$('#links_widget').blindSweep('slow');
		$('#search_widget').sideSweep('slow');
		$('#az_widget').blindToggle('slow');
	});
	$('#links_link').click(function(e) {
		e.preventDefault();
		$('#az_widget').blindSweep('slow');
		$('#search_widget').sideSweep('slow');
		$('#links_widget').blindToggle('slow');
	});
});

