$(document).ready(function() {

	$('#Newsfrm').submit(function() {
	  return false;
	});

});

enviarFormRegistro = function() {

	if (!frmRegistroNews_Validar()) return;

	var qs = $("#Newsfrm").serialize();
//	alert(qs);

	$.ajax({  
		type: "POST",  
		url: "web/ajax_registro_news.php",  
		data: qs,
		async: false,
		cache: false,
		timeout: 30000,
		dataTypeString: "text",
		beforeSend: function() {
//			$("#spinner_"+id).html('<img src="images/spinner_16x16.gif" />');
		},
		success: function (response) {

//			$("#spinner_"+id).html('&nbsp;');

			try {
				var json = jQuery.parseJSON(response);
			}
			catch (e) {
				alert(response);
				return -1;
			}


			if (json.status == 'error') {

				if (json.error == 'error_en_datos'){
					alert('Error al recibir los datos. Intente nuevamente.');
				}
			}else {

				alert('Te registraste éxitosamente.');
				$("#Newsfrm").reset();
			}
		}
	});  
}

jQuery.fn.reset = function () {
  $(this).each (function() { this.reset(); });
}

function frmRegistroNews_Validar(){
	var rt = true;
	var f = document.getElementById("Newsfrm");

	rt = rt && MM_validateForm('Newsfrm','email_news','RE','E-mail');

	return (rt);
}

