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 validateContactForm()
{

	x=document.contact;
	Fields=new Array("letters", "last_name", "email");

	for(i=0;i<Fields.length;i++)
	{

		if(eval("x."+Fields[i]+".value.trim()")=="")
		{

			al='De volgende velden moeten ingevuld worden c.q. correct ingevuld worden:\n';
			for(j=0;j<Fields.length;j++)
			{
				if(eval("x."+Fields[j]+".value.trim()")=="")
					switch(Fields[j])
					{
						case "letters": al=al+' *  Voorletters\n'; break;
						case "last_name": al=al+' *  Achternaam\n'; break;
						case "email": al=al+' *  E-mailadres\n'; break;
						default:  break;
					}
			}

			alert(al);
			eval("x."+Fields[i]+".focus()");
			return false;
		}
	}
	if(x.ocupation[5].checked && x.ocupation_text.value.trim()=="")
	{
		alert('Vul a.u.b uw beroep in.');
		x.ocupation_text.focus();
		return false;
	}
	if(!checkMail('contact','email'))
	{
		alert('Ongeldig e-mail adres');
		x.email.focus();
		return false;
	}

	x.submit();

}
function changeImage(){
	   if (document.all){
	      document.images.image.style.filter="blendTrans(duration=2)";
	      document.images.image.style.filter="blendTrans(duration=crossFadeDuration)";
	      document.images.image.filters.blendTrans.Apply();
	   }
	   document.images.image.src = preLoad[j].src;
		var alink = document.getElementById("alink");
	   if (alink) {
			if (preLoad[j].link !="") {
				alink.onclick = preLoad[j].link;
				alink.href =preLoad[j].link;
			}
			else {
				alink.onclick = "showImg('"+ preLoad[j].big +"')";
				alink.href ="javascript:showImg('"+preLoad[j].big+"')";
			}
			alink.title=preLoad[j].alt;

		}
	   if(preLoad[j].speed != 0) slideShowSpeed = preLoad[j].speed*1000;
	   else slideShowSpeed = 5000;

	   if (document.all){
	      document.images.image.filters.blendTrans.Play();
	   }
	   j = j + 1;
	   if (j > (p-1)) j=0;
	   t = setTimeout('changeImage()', slideShowSpeed);
}
function showImg(val)
{


	if (val){
		var imgw = 0, imgh = 0;
		var img = new Image();
		img.onload = function () {
			var winl = (screen.width)/2;
			var wint = (screen.height)/2;
			imgw = this.width;
			imgh =  this.height;
			popwin = window.open("hurks",null,'toolbar=no,menubar=no, resizable=0 , width='+imgw+', height='+imgh+', status=no, dialog=yes');
			popwin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
			popwin.document.write('<HTML><HEAD><TITLE>Hurks</TITLE></HEAD><BODY STYLE="margin:0px;padding:0px">');
			popwin.document.write('<IMG ID="popupimg" BORDER="0" SRC="'+val+'" />');
			popwin.moveTo(winl - (imgw/2), wint - (imgh/2));
			popwin.document.write('</BODY></HTML>');
			};
		img.src = val;

	}
}
