function AJAX(){var xmlhttp=false;try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}catch(E){xmlhttp = false;}}if(!xmlhttp && typeof XMLHttpRequest!='undefined'){xmlhttp = new XMLHttpRequest();}return xmlhttp;}

/**/
function SEND_formulario(Form,FormCompra,Loading)
{
	Form = document.getElementById(Form);
	var ind = 0;
	var cadena ="";
	var ARRAY_data 	= new Array();
	var ARRAY_campo = new Array();
	for(j=0;j<Form.elements.length;j++)
	{
		var Element = Form.elements[j];
		if(Element.type != undefined)
		{
			/*identificamos la alerta especifica de cada elemento*/
				var Alerta=Element.getAttribute("alerta");
				if(Alerta == undefined){Alerta="CAMPO";}
			/*llamamos las funciones de validacion correspondientes*/
				if(validar_requeridos(Element,Alerta)){return;}
				if(validar_tipo_archivo(Element,Alerta)){return;}
				if(validar_correo(Element,Alerta)){return;}
			/*obtenemos valores y campo*/
				var Campo = Element.getAttribute("campo");
				if(Campo != undefined)
				{
					ARRAY_data[ind]	= Element.value;
					ARRAY_campo[ind]	= Element.getAttribute("campo");
				}
			   ind++;
			
		}
	}
	/*conformamos la cadena de datos*/
		for(j=0;j<ARRAY_data.length;j++)
		{
			if(ARRAY_campo[j] != undefined){cadena = cadena+"&"+ARRAY_campo[j]+"="+ ARRAY_data[j];}
		}
		//alert(cadena);return;

	/**/
		Loading = document.getElementById(Loading);
		AJAX_obj=AJAX();
		AJAX_obj.open("POST", "../js/ajax_inscripcion/AJAX_action.php",true);
		AJAX_obj.onreadystatechange=function()
		{
			if(AJAX_obj.readyState==1){}//Loading.innerHTML = "<i>enviando...</i>";}
			else if(AJAX_obj.readyState==4)
			{
				if(AJAX_obj.status==200)
				{
					if(AJAX_obj.responseText!="")
					{
						eval("document."+FormCompra+".submit();");
						Loading.innerHTML = "<span class='enviado'>Gracias, estás siendo reenviado a nuestro sitio de pago >></span>";
					}
				}
				else if(AJAX_obj.status==404)
				{
					Loading.innerHTML = "La página no existe";
				}
				else
				{
					Loading.innerHTML = "Error:".AJAX_obj.status;
				}
			}
		}
		AJAX_obj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		AJAX_obj.send(cadena);

}
