//////////////////////////////////////////////////////////////////////////////////
function videojanjcl(w, h)
{
	URL='http://www.keesiedive.dds.nl/videos/Bruiloft30Mb.wmv';
	y = eval(h) + 64;
	document.writeln ('<object id="Player"');
	document.writeln ('	classid=clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6');
	document.writeln ('	standby="Loading Microsoft Windows Media Player components..."');
	document.writeln ('	type="application/x-oleobject" width="' + w + '" height="' + y + '">');
	document.writeln ('<param name="url" value="' + URL + '">');
	document.writeln ('<param name="AutoStart" value="true">');
	document.writeln ('<param name="ShowControls" value="1">');
	document.writeln ('<param name="uiMode" value="mini">');
	document.writeln ('<embed type="application/x-mplayer2"');
	document.writeln ('	pluginspage="http://www.microsoft.com/windows/windowsmedia/"');
	document.writeln ('	filename="' + URL + '"');
	document.writeln ('	src="' + URL + '"');
	document.writeln ('	Name="Player"');
	document.writeln ('	ShowControls=1');
	document.writeln ('	uiMode="mini"');
	document.writeln ('	ShowDisplay=0');
	document.writeln ('	ShowStatusBar=1');
	document.writeln ('	width="' + w + '"');
	document.writeln ('	height="' + (y + 5) + '">');
	document.writeln ('</embed>');
	document.writeln ('<p>Your browser does not support ActiveX controls<br />or your Windows Media Player is older than Series 7!!</p>');
	if(navigator.appName == "Netscape") 
	{
		document.writeln('<p>If Windows Media Player Series 7 or higher is installed, then please ugrade to <a href="http://channels.netscape.com/ns/browsers/" target="extern">Netscape 7.1 or higher</a>.</p>');
	}
	document.write ('</object>');
}

//////////////////////////////////////////////////////////////////////////////////
function Check()
{
	var errs = 0;
	// execute all element validations in reverse order, so focus gets set to the first one in error.
	errs += validateEmail	(document.forms.form.email     , 'fb_email'   , true);
	errs += validateTelnr	(document.forms.form.telefoon  , 'fb_telefoon', false);
	errs += validateZip	(document.forms.form.postcode  , 'fb_postcode', false);
	errs += validatePresent	(document.forms.form.achternaam, 'fb_achternaam');

	return (errs == 0);
}

var nbsp = 160;
var emptyString = /^\s*$/ ;
var global_valfield;		// retain valfield for timer thread

//////////////////////////////////////////////////////////////////////////////////
function trim(str)
{
	return str.replace(/^\s+|\s+$/g, '');
}

//////////////////////////////////////////////////////////////////////////////////
function setFocusDelayed()
{
	global_valfield.focus();
}

//////////////////////////////////////////////////////////////////////////////////
function setfocus(valfield)
{
	global_valfield = valfield;	// save valfield in global variable so value retained when routine exits
	setTimeout('setFocusDelayed()', 100);
}

//////////////////////////////////////////////////////////////////////////////////
function msg(fld, msgtype, message)
{
	// Setting an empty string can give problems if later set to a non-empty string, so ensure a space present.
	// For Mozilla and Opera one could simply use a space, but IE demands something more, like a non-breaking space.
	var elem = document.getElementById(fld);
	elem.firstChild.nodeValue = (emptyString.test(message) ? String.fromCharCode(nbsp) : message);
	elem.className = msgtype;				// set the CSS class to adjust appearance of message
}

//////////////////////////////////////////////////////////////////////////////////
function commonCheck (valfield, infofield, required)
{
	if (!document.getElementById) return 0;		// not available on this browser - leave validation to the server
	var elem = document.getElementById(infofield);
	if (!elem.firstChild) return 0;			// not available on this browser 
	if (elem.firstChild.nodeType != 3) return 0;	// infofield is wrong type of node (not a text_node)

	if (emptyString.test(valfield.value))
	{
		if (required)
		{
			msg (infofield, "hilite", "Verplicht veld");  
			setfocus(valfield);
			return 1;
		}
		else
		{
			msg (infofield, "totop", "");
		}
	}
	return 0;
}

//////////////////////////////////////////////////////////////////////////////////
function validatePresent (valfield, infofield)
{
	if (commonCheck (valfield, infofield, true) == 1) return 1;
	msg (infofield, "warn", "");  
	return 0;
}

//////////////////////////////////////////////////////////////////////////////////
function validateEmail (valfield, infofield, required)
{
	if (commonCheck (valfield, infofield, required) == 1) return 1;

	var tfld = trim(valfield.value);
	var email = /^[^@]+@[^@.]+\.[^@]*\w\w$/;
	if (!email.test(tfld))
	{
		msg (infofield, "hilite", "Dit is geen geldig e-mail adres");
		setfocus(valfield);
		return 1;
	}
	else
	{
		msg (infofield, "totop", "");
	}
	return 0;
}


//////////////////////////////////////////////////////////////////////////////////
function validateZip (valfield, infofield, required)
{
	if (commonCheck (valfield, infofield, required) == 1) return 1;

	var tfld = trim(valfield.value);
	var zip = /^([1-9][0-9]{3} *[a-zA-Z]{2})?$/;
	if (!zip.test(tfld))
	{
		msg (infofield, "hilite", "Dit is geen geldige postcode");
		setfocus(valfield);
		return 1;
	}
	else
	{
		msg (infofield, "totop", "");
	}
	return 0;
}

//////////////////////////////////////////////////////////////////////////////////
function validateTelnr (valfield, infofield, required)
{
	if (commonCheck (valfield, infofield, required) == 1) return 1;

	var tfld = trim(valfield.value);
	var telnr = /^([0-9]{10})?$/;
	if (!telnr.test(tfld))
	{
		msg (infofield, "hilite", "Het telefoonnummer moet uit 10 cijfers bestaan.");
		setfocus(valfield);
		return 1;
	}
	else
	{
		msg (infofield, "totop", "");
	}
	return 0;
}
