$(function() {  
  $('.error').hide();  
  $(".button").click(function() {  
    // validate and process form here  
    var troubles = 0;  
    $('.error').hide();  
	var phone = $("input#phone").val();  
    if (phone == "") {  
      	$("label#phone_error").show();  
      	$("input#phone").focus();  
      	troubles++;
    }
	var name = $("input#name").val();  
    if (name == "") {  
      	$("label#name_error").show();  
      	$("input#name").focus();  
      	troubles++;
    }  

	if (troubles > 0) return false; // exit here and don't send if troubles!
      
	var dataString = 'name='+ name + '&phone=' + phone + '&business=' + $("input#business").val() + '&email=' + $("input#email").val();  
	//alert (dataString);return false;  
	$.ajax({  
	  	type: "POST",  
	  	url: "/hosted/ignition/buy-online-contact.php",  
	  	data: dataString,  
	  	success: function() {  
	    	$('#contact_form').html("<div id='result'></div>");  
	    	$('#result').html("<p><strong>Your details have been sent, thank you.</strong></p>")  
	    	.hide()  
	    	.fadeIn(1000);  
	  	}  
	});  
	return false; //stop page refresh
  });  
});
