String.prototype.trim = function() {
	a = this.replace(/^\s+/, '');
	return a.replace(/\s+$/, '');
};

function popupWindow( Page, Width, Height ){
	popWindow = window.open( Page,"popWindow","width="+(Width*1+18)+",height="+(Height*1+18)+",scrollbars=0,left="+((screen.width-Width/2))+",top="+((screen.height-Height/2))).focus();
}
function checkMail(form_name,email_field)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test( eval("document."+form_name+"."+email_field+".value" )))
		return true;
	else 
		return false;

}

function checkTelNumber(string){
	/* Accepts: 
			06 48388725
			0648388725
			06-48388725
			06 4838 8725
	*/		

	var filter1  = /^06[\s|-]{0,1}[0-9]{8}$/;
	var filter2  = /^06\s[0-9]{4}\s[0-9]{4}$/;
	if (filter1.test(string) || filter2.test(string)) return true;
	return false;

}

function Search(server_root)
{
	document.form.action=server_root+document.form.lang.value+'/'+document.form.search.value;
	document.form.submit();
}	
function validateSubscribeForm()
{
	x=document.formn;
	Fields=new Array("name", "voorname", "email", "phone");

	for(i=0;i<Fields.length;i++)
	{
		if(eval("x."+Fields[i]+".value.trim()")=="")
		{
			alert('Field that are marked with * are mandatory');
			eval("x."+Fields[i]+".focus()");
			return false;
		}
	}
	if(!checkMail('formn','email'))
	{
		alert('Invalid e-mail address');
		x.email.focus();
		return false;
	}
	if(x.phone.value.trim().length<10 || x.phone.value.trim().length>11)
	{
		alert('Invalid phone number.');
		x.phone.focus();
		return false;
	}
	x.submit();
}

function validateContactForm()
{
	x=document.contact;
	Fields=new Array("fname", "lname", "adres", "postcode", "city", "phone", "email", "note");

	for(i=0;i<Fields.length;i++)
	{
		if(eval("x."+Fields[i]+".value.trim()")=="")
		{
			alert('Field that are marked with * are mandatory');
			eval("x."+Fields[i]+".focus()");
			return false;
		}
	}

	if(x.phone.value.trim().length<10 || x.phone.value.trim().length>11)
	{
		alert('Invalid phone number.');
		x.phone.focus();
		return false;
	}
	if(!checkMail('contact','email'))
	{
		alert('Invalid e-mail address');
		x.email.focus();
		return false;
	}
	x.submit();
}
