//<![CDATA[	
	$(document).ready(function(){
		
		$('#submitForm').click(function(){
			var error = false;
			
			if($('#firstname').val().replace(/\s+/g,"").length == 0){
				$('#firstname').addClass('missed');
				error = true;
			}
			else{
				$('#firstname').removeClass('missed');
			}
			
			if($('#lastname').val().replace(/\s+/g,"").length == 0){
				$('#lastname').addClass('missed');
				error = true;
			}
			else{
				$('#lastname').removeClass('missed');
			}
			
			if($('#email').val().replace(/\s+/g,"").length == 0){
				$('#email').addClass('missed');
				error = true;
			}
			else{
				$('#email').removeClass('missed');
			}
			
			if(error){
				$('#message').html('Please fill out all required fields. Form will not process unless all required fields (<span class="mandatory">*</span>) are complete.');
			}
			else{
				$('#submitForm').attr('disabled', 'true');
				$('#message').html('Processing... please wait. ');
				
				var formData = 'firstname=' + encodeURIComponent($('#firstname').val()) + '&lastname=' + encodeURIComponent($('#lastname').val()) + '&title=' + encodeURIComponent($('#title').val()) + '&company=' + encodeURIComponent($('#company').val());
				formData += '&address1=' + encodeURIComponent($('#address1').val()) + '&address2=' + encodeURIComponent($('#address2').val()) + '&city=' + encodeURIComponent($('#city').val()) + '&state=' + encodeURIComponent($('#state').val()) + '&zip=' + encodeURIComponent($('#zip').val()) + '&email=' + encodeURIComponent($('#email').val()) + '&phone=' + encodeURIComponent($('#phone').val()) + '&website=' + encodeURIComponent($('#website').val());
				formData += '&comments=' + encodeURIComponent($('#comments').val());
				
				$.ajax({
					type: 'POST',
					url: 'inc/contact.php',
					cache: false,
					data: formData,
					dataType: "xml",
					timeout: 10000,
					error: function(ob, status){
						$('#submitForm').attr('disabled', '');
						$('#message').html('Error: ' + status + '. Please try again.');
					},
					success: function(xml){
						$('#submitForm').attr('disabled', '');
						var root = xml.getElementsByTagName('root')[0];
						if(root.getElementsByTagName("error")[0].firstChild.nodeValue == 'false'){
							$('#contactForm')[0].reset();
							$('#formContent').html('<p><span id="confirm">Thank you! Your message has been successfully sent.</span></p>');
						}
						else{
							$('#message').html('Error. Please try again.');
						}
					}
				});
			}
		});
	});
//]]>
