function labelInInputClick(el, defaultString) {
	if ($(el).val() == defaultString) {
		$(el).val('')
	}
}

function labelInInputBlur(el, defaultString) {
	if ($(el).val() == '') {
		$(el).val(defaultString);
	}
}

(function($) {
	$.fn.stabs = function(options) {
		var options = $.extend({
			selectedClass: "active",
			selected: 0
		}, options);

		$(this).find("a").click(function() {
			$(this).parents("ul:first").find("li").removeClass(options.selectedClass);

			$(this).parents("ul:first").find("a").each(function(i, el) {
				$($(el).attr("href")).hide();
			});
			$(this).parents("li:first").addClass(options.selectedClass);
			$($(this).attr("href")).show();
			return false;
		});

		$(this).find("a:eq("+options.selected+")").click();
	};
})(jQuery);

$(document).ready(function() {
	$("a.lightbox").fancybox({
		overlayOpacity: 0.6,
		speedIn: 100,
		speedOut: 100,
		type: "image",
		titlePosition: "inside",
		// hack for flash in the background... Take a look at wmode transparent?
		onStart: function() {
			$("object").hide();
		},
		onClosed: function() {
			$("object").show();
		}
	});

	$("table.hoverable tr").hover(function() {
		$(this).toggleClass("hover");
	}, function() {
		$(this).toggleClass("hover");
	});

	$(".switch input:checkbox").click(function() {
		var $target = $($(this).attr("rel"));
		if (!$target.size()) {
			alert("SWITCH: Unknown target");
			return false;
		}

		if ($(this).attr("checked")) {
			$target.slideDown("fast");
		} else {
			$target.slideUp("fast");
		}
	});

	$(".switch input:checkbox").each(function(i, checkbox) {
		if (!$(checkbox).attr("checked")) {
			$($(this).attr("rel")).hide();
		}
	});
});
