jQuery.validator.addMethod('phoneNL', function(phone_number, element) {
	return this.optional(element) || phone_number.length > 9 &&
	phone_number.match(/^(\(?(0|\+31)[1-9]{1}\d{1,4}?\)?\s?\d{3,4}\s?\d{3,4})$/);
}, 'Voer een correct telefoonnummer in.');


jQuery.validator.addMethod("dateNL", function(value, element) {
		return this.optional(element) || /^\d\d?[\.\/-]\d\d?[\.\/-]\d\d\d?\d?$/.test(value);
	}, "Vul hier een geldige datum in."
);
jQuery.validator.messages.required = '<img src="' + source + 'images/form/error.gif" alt="Error..." />';
jQuery(function() {
	// show a simple loading indicator
	jQuery().ajaxStart(function() {
		$(".submit").html('<img src="' + source + 'images/form/loader.gif" alt="loading..." /> Uw formulier wordt verwerkt. Een ogenblik geduld...');
	}).ajaxStop(function() {
		//loader.hide();
	}).ajaxError(function(a, b, e) {
		throw e;
	});
	
	var v = jQuery("#form").validate({
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				target: "#form_container"
			});
		}
	});
	
	jQuery("#reset").click(function() {
		v.resetForm();
	});
});

     var browserWidth = 0;
     if (document.documentElement) {
         browserWidth = document.documentElement.offsetWidth;
     } else if (window.innerWidth && window.innerHeight) {
         browserWidth = window.innerWidth;
     }

$(function(){	/**
	 * Demo binding and preparation, no need to read this part
	 */
	//borrowed from jQuery easing plugin
	//http://gsgd.co.uk/sandbox/jquery.easing.php
	$.easing.elasout = function(x, t, b, c, d) {
	//	var s=1.70158;var p=0;var a=c;
	//	if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
	//	if (a < Math.abs(c)) { a=c; var s=p/4; }
	//	else var s = p/(2*Math.PI) * Math.asin (c/a);
	//	return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
		
		return c*(t/=d)*t*t*t + b;

	};

	$.superbox.settings = {
		closeTxt: '<img src="images/close.gif" title="Close" alt="Close">',
		loadTxt: 'Loading...',
		nextTxt: 'Next',
		prevTxt: 'Previous'
	};
	$.superbox();

	//$('#sponsors').animate({left: ( browserWidth - 220 ) +"px" },{queue: false, duration: 350});

});

$(document).ready(function(){	
	
	$("#form").validate();

});

$(window).scroll(function(){
  $('#sponsors').animate({left:  $(window).scrollLeft() +"px" },{queue: false, duration: 350});
});

function scrollPage(ID){
$.scrollTo( '#'+ID, 500, {easing:'elasout'} );
}