/*
 * JavaScript AJAX Form Processor
 * for ELI no more - KUBE
 * DAN MURRAY <dan.murray@i-to-i.com>
 * Modified for Teach Inn - Colin May <colin.may@i-to-i.com>
 *
 */

function sendQuestionForm() {
	//var personName = document.getElementById('your_name').value.split(" ");
//	var firstName, lastName;

	if( validateForm( document.getElementById('contactForm') ) ) {

		var firstName = jQuery('#forename').val();
		var lastName = jQuery('#surname').val();

		if(document.location) {
			var userOnPage = document.location;
		} else {
			var userOnPage = "Unknown!"
		}

		jQuery('#contactFormFields').hide();
		jQuery('#contactLoading').show();

		jQuery.ajax({
		   type: "POST",
		   url: "/kube-handler.php",
		   data: "eliType=br-question&eliConfirmUrl=noredirecturl&eliForename="+firstName+"&eliSurname="+lastName+"&eliCountrycode="+jQuery('#countryCode').val()+"&eliEmail="+jQuery('#email').val()+"&site=Teach%20Inn&&eliQuestionField="+jQuery('#question').val()+"&eliUserWasOnPage="+userOnPage,
		   success: function(msg){
		     // jQuery('#contactThankyou').html(msg);

		     jQuery('#contactLoading').hide();
		     jQuery('#contactThankyou').show();
		     urchinTracker("/confirmpage" );

		   }
		 });

	}
	else {
		return false;
	}

}

function updateQuestionForm() {
	alert("Problem retrieving XML data:" + ajaxHttpUser.statusText);

	if ((ajaxHttpUser.readyState == 4)&&(ajaxHttpUser.status)) {
		if (ajaxHttpUser.status == 200) {
			document.getElementById('contactLoading').style.display='none';
			document.getElementById('contactThankyou').style.display='block';
				urchinTracker("/confirmpage" );
		}
	}
}