// Xplana Request w/ Validation
// © 2009 MBS Direct
// 12.11.2009 dh

$(function() {
	$('.error').hide();
	$(".button").click(function() {
		//validate and process form
		//first hide any error messages
	$('.error').hide();
	var name = document.contact.name.value;
	if (document.contact.name.value == "") {
		$("label#name_error").show();
		$("input#name").focus();
		return false;
	}
	var email = document.contact.email.value;
	if (document.contact.email.value == "") {
		$("label#email_error").show();
		$("input#email").focus();
		return false;
	}
	var phone = document.contact.phone.value;
	if (document.contact.phone.value == "") {
		$("label#phone_error").show();
		$("input#phone").focus();
		return false;
	}
	var orgname = document.contact.orgname.value;
	if (document.contact.orgname.value == "") {
		$("label#orgname_error").show();
		$("input#orgname").focus();
		return false;
	}


	var dataString = '&name='+ document.contact.name.value + '&email=' + document.contact.email.value + '&phone=' + document.contact.phone.value + '&title=' + document.contact.title.value + '&orgname='+ document.contact.orgname.value + '&orgtype=' + document.contact.orgtype.value + '&notes=' + document.contact.notes.value;
		//alert (dataString);return false;
	$.ajax({
		type: "POST",
		url: "../bin/process.php",
		data: dataString,
		success: function(){
			$('#area')
				.fadeOut(500, 
					function(){
						$('#area').html("<h3>Your request was sent succesfully!</h3><p>Thank you for your interest in Xplana. A representative will be contacting you shortly regarding the information you've requested.</p>");						
 					}		 
				)				
				.fadeIn(1500, 
					function(){
											
 					}
			);
			$('#request-modal').animate({ height:"280px" }, 1000);
		}
	});
    return false;
	});
});