//
//	Contact FORM handling.
//
function contact_form_xmit( type, action ) {
	//
	//	Collect all form data
	//
	var POSTthis				= '';
	//
	var inputID					= 'naam';
	var objElem					= document.getElementById(inputID);
	if( objElem == null ) {
		alert('<INPUT> -' + inputID + '- not found ...');
		return;
	}
	POSTthis					+= '&' + inputID + '=' + myEscape(objElem.value);
	//
	var inputID					= 'bedrijf';
	var objElem					= document.getElementById(inputID);
	if( objElem == null ) {
		alert('<INPUT> -' + inputID + '- not found ...');
		return;
	}
	POSTthis					+= '&' + inputID + '=' + myEscape(objElem.value);
	//
	var inputID					= 'email';
	var objElem					= document.getElementById(inputID);
	if( objElem == null ) {
		alert('<INPUT> -' + inputID + '- not found ...');
		return;
	}
	POSTthis					+= '&' + inputID + '=' + myEscape(objElem.value);
	//
	var inputID					= 'onderwerp';
	var objElem					= document.getElementById(inputID);
	if( objElem == null ) {
		alert('<INPUT> -' + inputID + '- not found ...');
		return;
	}
	POSTthis					+= '&' + inputID + '=' + myEscape(objElem.value);
	//
	var inputID					= 'bericht';
	var objElem					= document.getElementById(inputID);
	if( objElem == null ) {
		alert('<INPUT> -' + inputID + '- not found ...');
		return;
	}
	POSTthis					+= '&' + inputID + '=' + myEscape(objElem.value);
	//
	//	Show we're going to do some AJAX
	var ajax_busy				= document.getElementById('ajax_busy');
	ajax_busy.style.display		= 'inline';
	//
	//	AJAX the request & POST the data with it
	var url						=	'/functions/contact/contact_form.php';
	var myAjax					=	new Ajax.Request(
										url,
										{
											method: 'post',
											parameters: POSTthis,
											onSuccess: contact_form_receive
										}
									);
}

function contact_form_receive( response ) {
	var contact_data			= response.responseText;
	var contact_check			= contact_data.substr(0,2);
	//
	//	Sown we're done with AJAX
	//
	var ajax_busy				= document.getElementById('ajax_busy');
	ajax_busy.style.display		= 'none';		// Fast(er) disappear !
	//
	//	Any errors or not?
	//
	if( contact_check != 'ok' ) {
		var error_text				= 'During filling the form, the following is detected:' + "\n" + contact_data.substr(2);
		alert(error_text);
		return;
	}
	//
	alert("\nYour message has been sent.");
	location.href				= '/';
}


function myEscape( str ) {
	str		= escape(str);
	return str;
}
