$(document).ready(function() {   

	
	$("span.bestel a").click(function() {
		$(".bestelform").slideToggle(400);
		return false;
	});
	
	$.validator.addMethod('datum', function (value) {
		if (value != "") {
	  	return /^((((0?[1-9])|([1][012]))[ -/]((0?[1-9])|([12]\d)|(3[01])))|(((0?[1-9])|([12]\d)|(3[01])))[ -/]((0?[1-9])|([1][012])))[ -/](\d{1,4})$/.test(value);
		} else {
			return true;
		}
	}, 'Geen geldige datum. dd-mm-jjjj');

	$.validator.addMethod('postcode', function (value) {
		if (value != "") {
	  	return /^([1-9][0-9]{3}[ ]?[a-zA-Z]{2})?$/.test(value);
		} else {
			return true;
		}
	}, 'Geen geldige postcode. 1111AB');	
	
});

	function resizeImages(element,maxwidth,maxheight) {
	
		$(element).each(function() {
			var width = $(this).attr("width");
			var height = $(this).attr("height");
			if (height > maxheight) {
				width = ((width / height) * maxheight);
				height = maxheight;
			}
			if (width > maxwidth) {
				height = ((height / width) * maxwidth);
				width = maxwidth;
			}
			$(this).attr({ width: width, height: height }).width(width).height(height);
		});	
	
	}
	
	function resizeImage(element,maxwidth,maxheight) {

		var width = $(element).attr("width");
		var height = $(element).attr("height");
		//alert("width: " + width + " , height: " + height);
		if (height > maxheight) {
			width = ((width / height) * maxheight);
			height = maxheight;
		}
		if (width > maxwidth) {
			height = ((height / width) * maxwidth);
			width = maxwidth;
		}
		$(element).attr({ width: width, height: height }).width(width).height(height);
	
	}
