	function regProcess(url, vars){
		$.post(
			url, 
			vars,
			function(xmlResponse){
    			root = xmlResponse.getElementsByTagName('root');			
				response = xmlResponse.getElementsByTagName('response')[0].childNodes[0].nodeValue;
				if(response == 'true'){
					$('#contactForm')[0].reset();
					$('#contactForm').css('display', 'none');
					$('#confirm').css('display', 'block');
					$('#confirm').html('<br/>Thank You.<br/>Your message has been sent successfully.');
					
					$('#message').html('');
					$('#contactForm input, #contactForm select, #contactForm textarea').each(function(){
						$(this).attr('disabled', '');
					});
				}
				else if(response == 'false'){
					$('#message').html('Processing error... Please try again later.');
					$('#contactForm input, #contactForm select, #contactForm textarea').each(function(){
						$(this).attr('disabled', '');
					});
				}
			}, 
			"xml"
		);
	}
	$(document).ready(function(){
		$('#submitButton').click(function(){
			var regexp = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
			
			if($('#name').val().replace(/\s+/g,'').length == 0){
				alert('Please enter your name');
				$('#name').focus();
			}
			else if($('#email').val().replace(/\s+/g,'').length == 0){
				alert('Please enter your email');
				$('#email').focus();
			}
			else if($('#email').val().search(regexp) == -1)
			{
				alert('Please enter a valid email address ! ');
				$('#email').focus();
			}	
			else if($('#comments').val().replace(/\s+/g,'').length == 0){
				alert('Please enter message body');
				$('#comments').focus();
			}
			else{
				var name = encodeURIComponent($('#name').val());
				var company = encodeURIComponent($('#company').val());
				var address = encodeURIComponent($('#address').val());
				var city = encodeURIComponent($('#city').val());
				var state = encodeURIComponent($('#state').val());
				var zip = encodeURIComponent($('#zip').val());
				var phone1 = encodeURIComponent($('#phone1').val());
				var phone2 = encodeURIComponent($('#phone2').val());
				var fax = encodeURIComponent($('#fax').val());
				var email = encodeURIComponent($('#email').val());
				var comments = encodeURIComponent($('#comments').val());
				var url = 'inc/ajax/contact.php';
				
				var vars = 'name=' + name + '&company=' + company + '&address=' + address + '&city=' + city + '&state=' + state + '&zip=' + zip + '&phone1=' + phone1 + '&phone2=' + phone2 + '&email=' + email + '&fax=' + fax + '&comments=' + comments;

				setTimeout('regProcess("'+url+'", "'+vars+'")', 1000);
				
				$('#message').html('Processing... Please wait');
				$('#contactForm input, #contactForm select, #contactForm textarea').each(function(){
					$(this).attr('disabled', true);
				});
			}
		});
	});
