/* creates hyperlinks for table rows */
function Goto(page) {
	$("tr.highlight").click(function (event) {
		if ($(event.target).is('td')) {
			document.location.href = page;
		}
	});
}

$(document).ready(function() {
	/* faq accordion */
	$("#accordion").accordion({
		collapsible: true
	});
	
	/* auto complete the search */
	$("#autocomplete").autocomplete("/api.php", {extraParams:{section:"search"}, maxItemsToShow:20});
	
	/* striped tables and highlight */
	$("table.vacatures_table tbody tr").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
	$("table.vacatures_table tbody tr:even").addClass("even");
	$("table.vacatures_table tbody tr:odd").addClass("odd");
	
	/* automatic form submit */
	$("input.filter").click(function() {
		this.form.submit();
	});
	
	/* contact boxes */
	$("a.dialog").click(function() {
		$("#dialog_" + this.id).dialog({
			bgiframe: true,
			height: 325,
			width: 400,
			modal: true,
			resizable: false,
			draggable: false,
			close: function(ev, ui) { $(this).dialog("destroy"); }
		});
	});
	
	/* input fields with default values */
	$("input.default-value").each(function() {
		$("input.default-value").css("color", '#444444');
			var default_values = new Array();
			$(this).focus(function() {
				if (!default_values[this.id]) {
					default_values[this.id] = this.value;
				}
				if (this.value == default_values[this.id]) {
					this.value = '';
					this.style.color = '#000000';
				}
			$(this).blur(function() {
				if (this.value == '') {
					this.style.color = '#444444';
					this.value = default_values[this.id];
				}
			});
		});
	});
});