Event.observe(window, 'load', init, false);

function init()
{
	loadObservers();
} // init

function loadObservers()
{
	if ($('fname'))
	{
	/*
		$('fname').value="Michel";
		$('surname').value="Pierre";
		$('company').value="ManAct";
		$('address').value="Chaussée de Louvain, 92/1";
		$('zip').value="1320";
		$('city').value="Hamme-Mille";
		$('telephone').value="010 86 17 41";
		$('email').value="mipi@manact.net";
	*/
	}
	
	if ($('fname'))
	{
		$('fname').observe('focus', reset.bindAsEventListener($('fname')), false);
		$('surname').observe('focus', reset.bindAsEventListener($('surname')), false);
		$('function').observe('focus', reset.bindAsEventListener($('function')), false);
		$('company').observe('focus', reset.bindAsEventListener($('company')), false);
		$('address').observe('focus', reset.bindAsEventListener($('address')), false);
		$('zip').observe('focus', reset.bindAsEventListener($('zip')), false);
		$('city').observe('focus', reset.bindAsEventListener($('city')), false);
		$('telephone').observe('focus', reset.bindAsEventListener($('telephone')), false);
		$('email').observe('focus', reset.bindAsEventListener($('email')), false);
		Event.observe('registration_form', 'submit', function(event) {
			validate(event);
		});
	}
}

function validate(event)
{
	if ($F('fname') == '' || $F('fname') == 'xxxxxxx')
	{
		$('fname').value = 'xxxxxxx';
		$('fname').setStyle({fontWeight: 'bold', color:'red'});
		$('msgerror').update('incomplet/onvolledig');
		Event.stop(event);
		return;
	}
	else if ($F('surname') == '' || $F('surname') == 'xxxxxxx')
	{
		$('surname').value = 'xxxxxxx';
		$('surname').setStyle({fontWeight: 'bold', color:'red'});
		$('msgerror').update('incomplet/onvolledig');
		Event.stop(event);
		return;
	}
	else if ($F('fonction') == '' || $F('fonction') == 'xxxxxxx')
	{
		$('fonction').value = 'xxxxxxx';
		$('fonction').setStyle({fontWeight: 'bold', color:'red'});
		$('msgerror').update('incomplet/onvolledig');
		Event.stop(event);
		return;
	}
	else if ($F('company') == '' || $F('company') == 'xxxxxxx')
	{
		$('company').value = 'xxxxxxx';
		$('company').setStyle({fontWeight: 'bold', color:'red'});
		$('msgerror').update('incomplet/onvolledig');
		Event.stop(event);
		return;
	}
	else if ($F('address') == '' || $F('address') == 'xxxxxxx')
	{
		$('address').value = 'xxxxxxx';
		$('address').setStyle({fontWeight: 'bold', color:'red'});
		$('msgerror').update('incomplet/onvolledig');
		Event.stop(event);
		return;
	}
	else if ($F('zip') == '' || $F('zip') == 'xxxxxxx')
	{
		$('zip').value = 'xxxxxxx';
		$('zip').setStyle({fontWeight: 'bold', color:'red'});
		$('msgerror').update('incomplet/onvolledig');
		Event.stop(event);
		return;
	}
	else if ($F('city') == '' || $F('city') == 'xxxxxxx')
	{
		$('city').value = 'xxxxxxx';
		$('city').setStyle({fontWeight: 'bold', color:'red'});
		$('msgerror').update('incomplet/onvolledig');
		Event.stop(event);
		return;
	}
	else if ($F('telephone') == '' || $F('telephone') == 'xxxxxxx')
	{
		$('telephone').value = 'xxxxxxx';
		$('telephone').setStyle({fontWeight: 'bold', color:'red'});
		$('msgerror').update('incomplet/onvolledig');
		Event.stop(event);
		return;
	}
	else if ($F('email') == '' || $F('email') == 'xxxxxxx')
	{
		$('email').value = 'xxxxxxx';
		$('email').setStyle({fontWeight: 'bold', color:'red'});
		$('msgerror').update('incomplet/onvolledig');
		Event.stop(event);
		return;
	}
}

function reset(el)
{
	if (this.value == 'xxxxxxx')
	{
		this.value = '';
		this.setStyle({fontWeight: 'normal', color:'black'});
		$('msgerror').update('');
	}
}
