$(function(){
		   
	// Form
	$(".extract").hide();		   
	
	$(".formPadd span").click(function(){
								$(this).parent().slideUp('fast', function(){
																	$(".extract").slideDown();	   
																});		  
								
							});
	$('.topNav ul').dropDownMenu({timer: 300, parentMO: 'parent-hover', childMO: 'child-hover1'});

});

$(document).ready(function() {
    /*
    Filter zoeken 						   
    De tekst verdwijnt en als je buiten het vak klikt komt de tekst terug.
    */
    setValue(".zoekstr");

    /*
    Validate form
    */
    $("#aspnetForm").validate();
});

function submitForm() {
    if ($('#aspnetForm').valid()) { $('#aspnetForm').submit(); }
}
/*
setValue 
Onclick de waarde weghalen. En onBlur terug zetten.
@param val klasse of id van het object (.class, #id)
*/
function setValue(val) {
    $(val).click(
		function() {
		    if (this.value == this.defaultValue) this.value = '';
		}
	);
    $(val).blur(
		function() {
		    if (this.value == '') this.value = this.defaultValue;
		}
	);
}

function GoSearch() {
    var zoekstr = $("#zoek").val();
    /* 
    Alles eruit filteren behalve:
    - 0-9 (0-9)
    - a-z (a-z)
    - A-Z (A-Z)
    - Koppelstreepje (-)
    - Spaties (\s)
    Extra uitleg
    - begin met / Start regex
    - Eind met / Eind regex
    - Achter de laatste / nog een letter dus g staat voor global. Dus over hele string uitvoeren
    */
    zoekstr = zoekstr.replace(/[^0-9a-z''A-Z-\s]/g, "");

    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.aspnetForm;
    }
    /* 
    Kijken of er niet alleen een spatie over blijft      
    */
    if (zoekstr.replace(/[\s]/g, "") == '') {
        alert("U dient minimaal 1 zoekwoord in te vullen.");
    } else {
        theForm.action = "/zoek.aspx?zoek=" + zoekstr;
        theForm.submit();
    }
}

function postUrl(url) {
    document.aspnetForm.action = url;
    document.aspnetForm.submit();
}
