jQuery(document).ready(function(){
	
	$('#contactform').submit(function(){
	
		var action = $(this).attr('action');
		
		$("#message").slideUp(750,function() {
		$('#message').hide();
		
 		$('#submit')
			.after('<img src="assets/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 "NO" } else { return "YES" }
					   
			}
			
		
		$.post(action, { 
			financialreq:  getCheckedValue('financialreq'),
			selfmanagereq:  getCheckedValue('selfmanagereq'),
			estatereq:  getCheckedValue('estatereq'),
			insuranceereq:  getCheckedValue('insuranceereq'),
			accountingreq:  getCheckedValue('accountingreq'),
			retirereq:  getCheckedValue('retirereq'),
			
			directsharereq:  getCheckedValue('directsharereq'),
			propertyreq:  getCheckedValue('propertyreq'),
			managereq:  getCheckedValue('managereq'),
			
			optin:  getCheckedValue('optin'),
			request: $('#request').val(),
			ebook: $('#ebook').val(),


			title: $('#title').val(),
			namef: $('#namef').val(),
			namel: $('#namel').val(),
			state: $('#state').val(),
			pcodeburb: $('#pcodeburb').val(),
			contacttime: $('#contacttime').val(),
			contactmeth: $('#contactmeth').val(),
			email: $('#email').val(),
			emailfriend: $('#emailfriend').val(),
			contactdate: $('#contactdate').val(),
			findus: $('#findus').val(),
			personsee: $('#personsee').val(),

			mobile: $('#mobile').val(),
			workph: $('#workph').val(),
			homeph: $('#homeph').val(),
			yob: $('#yob').val(),
			grossannual: $('#grossannual').val(),
			info: $('#info').val()
			


		},
			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; 
	
	});
	
	/*
	$('#resumeform').submit(function(){
	
		var action = $(this).attr('action');
		var formmethod = $(this).attr('method');
		var contenttype = $(this).attr('enctype');
		
		$("#message").slideUp(750,function(){
		  $('#message').hide();
		  
		  $('#submit')
			.after('<img src="assets/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 "NO" } else { return "YES" }
		  }
		  
		  $.post(action,function(data){
			document.getElementById('message').innerHTML = data;
			$('#message').slideDown('slow');
			$('#resumeform img.loader').fadeOut('slow',function(){$(this).remove()});
			$('#resumeform #submit').attr('disabled','');
			if(data.match('success') != null) $('#resumeform').slideUp('slow');
		  });
	    });
	    return false; 
	});
	*/

	
});
