$(function() {
	var directory = {
		search_opts : function() {
			var s_mod = $('.search');
			var s_opts = s_mod.find('.search_opts').hide();
			var sh_link = $('<p class="more"><a href="#">More search options</a></p>');
			sh_link
				.insertBefore(s_opts)
				.click(function() {
					s_opts.toggle();
					$(this).toggleClass('active');
					s_mod.minHeight(Math.floor(Math.random()*21)); s_mod.find('fieldset').height('auto');
					return false;
				});
		},
		label_hint : function() {
			// note: [@attr] syntax deprecated in jQuery 1.2+, use [attr] instead
			// <http://docs.jquery.com/Release:jQuery_1.2#Selectors>
			$("label[@for]").css('cursor','pointer');
		}
	}
	$('#main_column, #left_sidebar').equalizeCols();
	directory.search_opts();
	directory.label_hint();
	setTimeout(function() {$('#left_sidebar .module').height('auto')}, 10);
});

jQuery.fn.extend({
	minHeight : function(height) {
		if ($.browser.msie && (typeof window.XMLHttpRequest != "object")) {$(this).height(height);}
		else {$(this).css('min-height', height)}
	},
	innerWrap : function(e) {
		this.each(function(index) {
			var content = $(this).html();
			$(this).empty();
			e.html(content).appendTo($(this));
		});
	},
	outerHeight : function() {
		return this[0] == window || this[0] == document ?
			this.height() :
			this.css('display') != 'none' ?
				this[0].offsetHeight :
				this.height() + (parseInt(this.css("borderTopWidth")) || 0) + (parseInt(this.css("borderBottomWidth")) || 0)
					+ (parseInt(this.css("paddingTop")) || 0) + (parseInt(this.css("paddingBottom")) || 0);
	},
	equalizeCols : function(offset) {
		var max_height = 0;
		this.each(function() {
			if ($(this).outerHeight() > max_height) {max_height = $(this).outerHeight();}
		});
		this.minHeight(max_height);
	}
});
