			function loadForm (tipo) {
				cadenaEnvio = 'form_' + tipo + '.asp';
				
				CreateXmlHttpObj();
				
				if(XmlHttpObj) {	
					XmlHttpObj.onreadystatechange = function () {
						if (XmlHttpObj.readyState == 1) {				
							document.getElementById('theForm').innerHTML='<h3>Alta Socio</h3><p><br /><img src=\"img/fixed/loading_mini.gif\" border=\"0\" align=\"absmiddle\">&nbsp;&nbsp;Cargando datos...</p>';									
						}

						if(XmlHttpObj.readyState == 4) {

							if(XmlHttpObj.status == 200) {			
								document.getElementById('theForm').innerHTML=XmlHttpObj.responseText;
							}
							else {
								alert("Código de error: "  + XmlHttpObj.status);
							}
						}
					}
					XmlHttpObj.open("POST", cadenaEnvio, true );
					XmlHttpObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
					XmlHttpObj.send('');		
				}

			}

			//===========================================================================

			function sendMail (regId) {
				var formulario = document.getElementById('sendForm');

				//deberiamos comprobar que la estructura de correo es valida
				//***********************************************************

				if (formulario.email.value.replace(' ', '') == '') {
					alert('No puedes dejarlo en blanco');
				} else {

					cadenaEnvio = "sys_sendinfo.asp?id=" + regId + "&email=" + formulario.email.value;

					CreateXmlHttpObj();
					
					if(XmlHttpObj) {	
						XmlHttpObj.onreadystatechange = function () {
							if (XmlHttpObj.readyState == 1) {				
								document.getElementById('waiting').style.visibility = 'visible';
							}

							if(XmlHttpObj.readyState == 4) {

								if(XmlHttpObj.status == 200) {			
									document.getElementById('sqr_send').innerHTML=XmlHttpObj.responseText;
								}
								else {
									alert("Código de error: "  + XmlHttpObj.status);
								}
							}
						}
						XmlHttpObj.open("POST", cadenaEnvio, true );
						XmlHttpObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
						XmlHttpObj.send('');		
					}

				}
			}
			
			//===========================================================================

			function toggleSendSqr() {
				var capa = document.getElementById('sqr_send');
				var boton = document.getElementById('btn_send');
				var waiting = document.getElementById('waiting');


				if (capa.style.visibility == 'visible') {
					capa.style.visibility = 'hidden';
					boton.style.backgroundImage = 'url(/img/fixed/button_88.png)';
					waiting.style.visibility = 'hidden';
				} else {
					capa.style.visibility = 'visible';
					boton.style.backgroundImage = 'url(/img/fixed/button_88_on.png)';
				}
			}
			
			//===========================================================================
			
			function printable(regId) {
				window.open('sys_printable.asp?id=' + regId, 'pr', 'width=750,height=600,resizable=yes,status=no,menubar=no,toolbar=no,location=no,titlebar=no,directories=no,scrollbars=yes');

			}
			
			//===========================================================================

			function sendForm () {

				var formulario = document.getElementById('formulario');
				var cadenaEnvio = 'sys_procform.asp?';
				var isOk = true;


				//Comprobacion de campos obligatorios
				//-----------------------------------
				var obligados = 'Nombre,Telefono';
				var noRellenados = '';

				for (var i=0; i<formulario.length; i++) {
					var elemento = formulario.elements[i].name;
					var esObligado = obligados.indexOf(elemento);
					var valor = formulario.elements[i].value;

					if (valor.replace(' ', '') != '') {
						cadenaEnvio += elemento + '=' + formulario.elements[i].value + '&';
					} 
					else {
						if (esObligado >= 0) {
							isOk = false;
							noRellenados += elemento + ', ';
						}
					}
					
				}

				//Comprobacion final y envio por AJAX
				//-----------------------------------
				if (isOk) {
					if (confirm ('¿Desea enviar el formulario?')) {
						//alert('Enviando\n' + cadenaEnvio);
					
						rotulo = formulario.rotulo.value;

						CreateXmlHttpObj();
						
						if(XmlHttpObj) {	
							XmlHttpObj.onreadystatechange = function () {
								if (XmlHttpObj.readyState == 1) {				
									document.getElementById('theForm').innerHTML='<h3>'+rotulo+'</h3><p><br /><img src=\"img/fixed/loading_mini.gif\" border=\"0\" align=\"absmiddle\">&nbsp;&nbsp;Enviando datos...</p>';									
								}

								if(XmlHttpObj.readyState == 4) {

									if(XmlHttpObj.status == 200) {			
										document.getElementById('theForm').innerHTML=XmlHttpObj.responseText;
									}
									else {
										alert("Código de error: "  + XmlHttpObj.status);
									}
								}
							}
							XmlHttpObj.open("POST", cadenaEnvio, true );
							XmlHttpObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
							XmlHttpObj.send('');		
						}

					}
				} else {
					alert('Debes rellenar los campos obligatorios: ' + noRellenados);
				}

			}

			//================ AJAX Functions =======================

			function CreateXmlHttpObj() {
				try {
					XmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e) {
					try	{
						XmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
					} 
					catch(oc) {
						XmlHttpObj = null;
					}
				}
					
				if(!XmlHttpObj && typeof XMLHttpRequest != "undefined") {
					XmlHttpObj = new XMLHttpRequest();
				}
			}

		//============= END AJAX =======================

