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 = "";
			ingreso ="";
			for (i = 0; i < field.length; i++) {
			if (field[i].checked==true) { txt = field[i].value; ingreso="ingreso";}
			}
				   
			if (txt == "") { return "none"; } else { return txt + " "; }
				   
		}
	
       // get the value from a checked checkbox


		$.post(action, { 
			nombre: $('#nombre').val(),
			apellidouno: $('#apellidouno').val(),
			apellidodos: $('#apellidodos').val(),
			ano: $('#ano').val(),
			mes: $('#mes').val(),
			dia: $('#dia').val(),
	        tipod:  $('input:radio[name=tipod]:checked').val(),
			numdoc: $('#numdoc').val(),
			email: $('#email').val(),
			tel: $('#tel').val(),
			cod: $('#cod').val(),
			ciudad: $('#ciudad').val(),
			quieronews: $('#quieronews:checked').val(),
			verify: $('#verify').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; 
	
	});
	
});
