/**
 * defaultValue - Save default value of an input value
 *	http://richardvandermeer.nl
 *	Richard van der Meer
 *
 * version 0.1		october 2009
 *
 * Built on top of the jQuery library
 *   http://jquery.com
 *
 */
(function($) {

	$.fn.defaultValue = function() {

		return this.each(function() {

			$(this).data("originalText", $(this).val());

			$(this).blur(function() {
				if ($(this).val() == "") {
					$(this).val($(this).data("originalText"));
				}
			});

			$(this).focus(function() {
				if ($(this).val() == $(this).data("originalText")) {
					$(this).val("");
				}
			});

		});

	}

})(jQuery);


// Default value voor input-velden toevoegen
$(function() {
	$("#searchField").each(function() {
		$(this).data("originalText", $(this).val());

		$(this).blur(function() {
			if ($(this).val() == "") {
				$(this).val($(this).data("originalText"));
			}
		});

		$(this).focus(function() {
			if ($(this).val() == $(this).data("originalText")) {
				$(this).val("");
			}
		});
	});
});

$.expr[':'].icontains = function(obj, index, meta, stack){
	return (obj.textContent || obj.innerText || jQuery(obj).text() || '').toLowerCase().indexOf(meta[3].toLowerCase()) >= 0;
};


// Extanet-functies
$(function() {

	$("#documents").each(function() {

		$(".documentTableContent:first").show();

		$("table.documentTable tr.title").click(function() {
			$(".documentTableContent").hide();
			$(this).next(".documents").find(".documentTableContent").show();
			document.location = "#top";
			document.location = "#title_" + $(this).attr("linkID");
		});

		$.tablesorter.defaults.widgets = ['zebra']; 
		$(".documentTableContent").tablesorter();

		$("#search form").submit(function() {

			$(".documentTable .search").removeClass("search");
			$(".documentTableContent").hide();
			$(".documentTable td:icontains('" + $("#wSearch").val() + "')").parent().addClass("search").closest(".documentTableContent").show();

			return false;
		});
	});
});