$(document).ready(function() {
	$("[class^=validate]").validationEngine({
		success :  function() {
			var form_name = '';
			var url = '';
			if ($('#FormRC-PF').length > 0) {
				form_name = '#FormRC-PF';
				var botonborrar = 'button_solicitar_pf';
				url = '_includes/php/acciones-financiacion.php?id-seccion=rc-credito-pf';
			} else {
				form_name = '#FormRC-PJ';
				var botonborrar = 'button_solicitar_pj';
				url = '_includes/php/acciones-financiacion.php?id-seccion=rc-credito-pj';
			}
			var datos = $(form_name).serialize();
			$("#"+botonborrar).attr({ value: "Enviando..."});
			$("#"+botonborrar).attr("disabled", "true");
			$.ajax({
				url: url,
				type: 'POST',
				data: datos,
				success: function (response)
				{
					if (response != 'Error enviando los datos...')
					{
						$(form_name).empty();
						$('#Response-AJAX').html(response);		
						$("html:not(:animated),body:not(:animated)").animate({ scrollTop: 0}, 1100);
					}
					else
					{
						$('#Response-AJAX').html('Error enviado los datos...');
					}
				},
				error: function (response) {
					$('#Response-AJAX').html('Error de servicio al enviar los datos...');
				}
			});
		},
		failure : function() {}
	})
});

function estaCasado(e) {
	var currCasado = e.options[e.selectedIndex].value;
	if (currCasado == "Casado/a"){ document.getElementById("nombre-conyuge").style.display = ""; document.getElementById("documento-conyuge").style.display = ""; } 
	else { document.getElementById("nombre-conyuge").style.display = "none"; document.getElementById("documento-conyuge").style.display = "none"; }
}
