jQuery(document).ready(function(){
	
	$('#contactform').submit(function(){
	
		var action = $(this).attr('action');
		
		$("#message").slideUp(750,function() {
		$('#message').hide();
		
 		$('#submit')
			.after('<img src="/wp-content/themes/paperstreet/images/ajax-loader.gif" class="loader" />')
			.attr('disabled','disabled');
		
			function getCheckedValue(field) {
			
			field = $('#' + field)
			txt = ""
			for (i = 0; i < field.length; i++) {
			if (field[i].checked) { txt = field[i].value }
			}
			
			if (txt == "") { return "0" } else { return txt + " " }
			
			}
			
		$.post(action, { 
			firstname: $('#firstname').val(),
			lastname: $('#lastname').val(),
			address: $('#address').val(),
			city: $('#city').val(),
			state: $('#state').val(),
			zipcode: $('#zipcode').val(),
			homephone: $('#homephone').val(),
			cellphone: $('#cellphone').val(),
			email: $('#email').val(),
			interested1:  getCheckedValue('interested1'),
			interested2:  getCheckedValue('interested2'),
			timeframe: $('#timeframe').val(),
			experience1:  getCheckedValue('experience1'),
			experience2:  getCheckedValue('experience2'),
			comments: $('#comments').val(),
			area_of_interest1: $('#area_of_interest1').val(),
			area_of_interest2: $('#area_of_interest2').val(),
			capital: $('#capital').val(),
			networth: $('#networth').val(),
			hear1:  getCheckedValue('hear1'),
			hear2:  getCheckedValue('hear2'),
			hear3:  getCheckedValue('hear3'),
			hear4:  getCheckedValue('hear4'),
			hear5:  getCheckedValue('hear5'),
			hear6:  getCheckedValue('hear6')
		
		},
			function(data){
				document.getElementById('message').innerHTML = data;
				$('#message').slideDown('slow');
				$('#contactform img.loader').fadeOut('slow',function(){$(this).remove()});
				$('#contactform #submit').attr('disabled',''); 
				if(data.match('success') != null) $('#contactform').slideUp('slow');
				
			}
		);
		
		});
		
		return false; 
	
	});
	
});