	//-------------------------------------------------------------------------

	function albumCodeSubmit(albumCode) {
		var aCode = document.getElementById('albumCodeInput').value;
		if (aCode == '' && albumCode != '') {
			aCode = albumCode;
			document.getElementById('albumCodeInput').value=albumCode;
		}
		var aButton = document.getElementById('acSubmitBttn');

		if ((aCode == '') || (aCode.length != 7)) {
			alert('por favor, introduce un código válido');
		} else {
			aButton.innerHTML = '<img src=\"/img/loading_mini.gif\" align=\"absmiddle\" alt=\"\" />';

			var codeForm = document.getElementById('albumNav');
			codeForm.action = 'album_validate.asp';
			codeForm.submit();
		}
	}

	//-------------------------------------------------------------------------
			
	function loginSubmit () {
		var loginForm = document.getElementById('custLogin');

		if ((isMail(loginForm.email.value)) && (loginForm.pwd.value != '')) {
			loginForm.submit();
		} else {
			alert('ATENCION: el formato de correo no es valido, o no se han introducido valores');
		}
	}

	//-------------------------------------------------------------------------

	function isMail(texto){
		var mailres = true;            
		var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-";
		
		var arroba = texto.indexOf("@",0);
		if ((texto.lastIndexOf("@")) != arroba) arroba = -1;
		
		var punto = texto.lastIndexOf(".");
					
		 for (var contador = 0 ; contador < texto.length ; contador++){
			if (cadena.indexOf(texto.substr(contador, 1),0) == -1){
				mailres = false;
				break;
		 }
		}

		if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1))
		 mailres = true;
		else
		 mailres = false;
					
		return mailres;
	} 

	//-------------------------------------------------------------------------

		function sendForm (typeForm, typeSend) {

			var valLang = 1;
			var formulario = document.getElementById('formulario');
			var cadenaEnvio = formulario.action + '?';
			var isOk = true;

			var literales = new Array (
				'Debes rellenar los campos obligatorios',
				'żDeseas enviar el formulario?',
				'contactar',
				'Enviando datos',
				'You have to fill the obligued fields',
				'Dou you want to send this form?',
				'contact',
				'Sending form',
				'Tu dois remplir les domaines obligatoires',
				'Souhaites-tu envoyer le formulaire ?',
				'contacter',
				'En envoyant formulaire',
				'Has de omplir els camps obligatoris',
				'żVols enviar el formulari?',
				'contactar',
				'Enviant dades');


			if (typeForm == 'account') {
				if (formulario.password.value != formulario.pwd2.value) {
					alert('Los dos valores de password deben ser iguales');
					isOk = false;
				}
			}

			//Comprobacion de campos obligatorios
			//-----------------------------------
			var obligados;
			
			switch (typeForm) {
			case 'contact':
				obligados = 'Nombre,Telefono';
				break;
			case 'account':
				obligados = 'nombre,email';
				break;
			}
			
			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 el metodo elegido
			//------------------------------------------------
			if (isOk) {
				if (confirm (literales[4*valLang-3])) {
					//alert('Enviando\n' + cadenaEnvio);

					if (typeSend == 'ajax') {
						CreateXmlHttpObj();
						
						if(XmlHttpObj) {	
							XmlHttpObj.onreadystatechange = function () {
								if (XmlHttpObj.readyState == 1) {				
									document.getElementById('theForm').innerHTML='<div class=\"img_l\"><img src=\"img/icons/letter_32.png\" alt=\"\" /></div><h3>' + literales[4*valLang-2] + '</h3><p><br /><img src=\"img/loading_mini.gif\" border=\"0\" align=\"absmiddle\">&nbsp;&nbsp;' + literales[4*valLang-1] + '...</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 if (typeSend == 'normal') {
						formulario.submit();
					}
				}
			} else {
				alert(literales[4*valLang-4] +': '+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 =======================


