// Xplana Request w/ Validation
// © 2009 MBS Direct
// 12.11.2009 dh

// no conflict jQuery / mootools  
// rds 20100327  1632EST  jQuery.noConflict(); 
 

jQuery(function() {
	jQuery('.error').hide();
	jQuery(".button").click(function() {
		//validate and process form
		//first hide any error messages
	jQuery('.error').hide();
	var name = document.contact.name.value;
	if (document.contact.name.value == "") {
		jQuery("label#name_error").show();
		jQuery("input#name").focus();
		return false;
	}
	var email = document.contact.email.value;
	if (document.contact.email.value == "") {
		jQuery("label#email_error").show();
		jQuery("input#email").focus();
		return false;
	}
	var phone = document.contact.phone.value;
	if (document.contact.phone.value == "") {
		jQuery("label#phone_error").show();
		jQuery("input#phone").focus();
		return false;
	}
	var orgname = document.contact.orgname.value;
	if (document.contact.orgname.value == "") {
		jQuery("label#orgname_error").show();
		jQuery("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;
	jQuery.ajax({
		type: "POST",
		url: "bin/process.php",
		data: dataString,
		success: function(){
			jQuery('#area')
				.fadeOut(500, 
					function(){
						jQuery('#area').html("<h3>Your request was sent succesfully!</h3><p>At your request we will provide you with access to a live product demo. Simply click on a Request More Information button at any time. Until then, feel free to view our trio of demonstration videos. Thank you for your interest in Xplana™.</p>");						
 					}		 
				)				
				.fadeIn(1500, 
					function(){
											
 					}
			);
			jQuery('#request-modal').animate({ height:"280px" }, 1000);
		}
	});
    return false;
	});
});
