var AmbiantClass = new Class
(
	{
		initialize: function()
		{
			this.setEvents();
		},
		setEvents: function()
		{
			var oBtnCheckDealer = $('btnCheckDealer');
			
			if(oBtnCheckDealer) 
			{
				oBtnCheckDealer.removeEvents();
				oBtnCheckDealer.addEvent('click', this.checkPostcode.create({bind : this}));
			}			
		},

		checkPostcode: function (oEvent)
		{
			var oBtn = $(oEvent.target);
			var oForm = $(oBtn.get('rel'));
			
			var sPostcode = $('postcodeValue').value;
			
			postcodeRegex = /^[0-9]{4} ?[a-zA-Z]{2}$/;
			//postcodeRegex = new RegExp('#^[0-9]{4} ?[a-zA-Z]{2}$#');
			if( !sPostcode.match( postcodeRegex ) )
			{
				$('postcodeValue').value = 'Onjuiste Postcode';
				return false;
			}
			else
			{
				oForm.send();
			}
		}
	}
);

AmbiantInit = function()
{
	AmbiantObj = new AmbiantClass();
}

var AmbiantObj;

window.addEvent('domready', AmbiantInit);

		