
		
		function clearInputBox(box) {
			if (!clicked) {
				box.value='';
				clicked = true;
			}
		}
		
		function uploadFoto(frmName, field, target) {
			var fl = $(field).value; 
			if (fl.length==0) {
				return false;
			}
					
		}
		
		function fileUploaded(file) {
			$('hddn_file').value= file;
		}
		
		function cleanUpload() {
			$('hddn_file').value= '';
			$('visibleFile').value= '';
			$('upload_target').src= '';
		}
		
		function maxLength(Object) {
			var MaxLen = 140;
			return (Object.value.length <= MaxLen);
		}
		
		function validateFirstForm(formName) {
			if ($(formName).condiciones.checked!=true) {
				alert("Por favor, lea las condiciones de uso y marque el check si las acepta.");
				return false;
			}
			
			if ($(formName).alta_email.value.length >= 7 && $(formName).alta_email.value.length < 40) {
				if (!validarEmail($(formName).alta_email.value)) {
	                alert("La direcci�n de correo es incorrecta.");
	                return false;
	            }
	        } else {
				alert("Por favor, ind�quenos una direcci�n de correo.");
				return false;
			}
            
            if ($(formName).alta_password.value == '') {
				alert("Por favor, indique la contrase�a.");
				return false;
			} else if($(formName).alta_password.value.length < 5) {
				alert("Por favor, el tamaño de la contraseña es menor de 5 caracteres.");
				return false;
			}
			
			if ($(formName).alta_password_re.value == '') {
				alert("Por favor, indique de nuevo la contrase�a.");
				return false;
			}

			if ($(formName).alta_password_re.value != $(formName).alta_password.value) {
				alert("Por favor, las dos contrase�as ha de ser iguales.");
				return false;
			}
			return true;
		}
		
		function validateProfileForm(formName) {
			/*
			if ($(formName).condiciones.checked!=true) {
				alert("Por favor, lea las condiciones de uso y marque el check si las acepta.");
				return false;
			}
			*/
			
			if ($(formName).alta_nombre.value=='') {
				alert("Por favor, indique el nombre del autor.");
				return false;
			}
			
			if ($(formName).alta_primerApellido.value=='') {
				alert("Por favor, indique el primer apellido.");
				return false;
			}
			
			if ($(formName).alta_numColegiado.value=='') {
				alert("Por favor, indique el n�mero de colegiado.");
				return false;
			}
			
			if ($(formName).alta_provincia.value=='') {
				alert("Por favor, indique la provincia.");
				return false;
			}
			
			if ($(formName).alta_especialidadUno.value=='') {
				alert("Por favor, indique la primera especialidad.");
				return false;
			}
			
			if ($(formName).alta_cp.value!='') {
				if ($(formName).alta_cp.value.length != 5) {
				alert("Por favor, el c�digo postal debe tener 5 cifras.");
				return false;
				}
			}
			
			if ($(formName).alta_telefono.value=='') {
				alert("Por favor, indique el número de teléfono.");
				return false;
			} else if(!(/^\d{9}$/.test($(formName).alta_telefono.value)) ) {
				alert("Por favor, el teléfono ha de tener 9 cifras.");
				return false;
			}
			
			if ($(formName).alta_web.value!='') {
				if (!validarURLs($(formName).alta_web.value)) {
	                alert("La URL que indica es incorrecta.");
	                return false;
	            }
			}
			return true;
		}
		
		
		function validateSendBlogMail(formName) {
			
			if ($(formName).condiciones.checked!=true) {
				alert("Por favor, lea las condiciones de uso y marque el check si las acepta.");
				return false;
			}
			if ($(formName).alta_foto.value=='') {
				alert("Debe enviar una imagen para usar en legalsolo, procure que las dimensiones no excedan 120x120 pixels. Gracias");
				return false;
			} 
			if ($(formName).alta_autor.value=='') {
				alert("Por favor, indique el nombre del autor.");
				return false;
			}
			if ($(formName).alta_title.value=='') {
				alert("Por favor, indique el titulo del blog.");
				return false;
			}
			if ($(formName).alta_blog.value=='') {
				alert("Por favor, indique la url del blog.");
				return false;
			}
			if ($(formName).contactMail.value=='') {
                alert("Por favor, indique el email de contacto.");
                return false;
            }
            if (!validarEmail($(formName).contactMail.value)) {
                alert("La dirección de email es incorrecta.");
                return false;
            }
			return true;
		}
		
		
		function callAjax(url, pars, target) {
			
			var myAjaxs = new Ajax.Request(url,
				{method: 'post',
				parameters: pars,
				onCreate: function(call) {
					$(target).innerHTML = '<div class="loading"></div>';					
				},
				onComplete: function(call) {
					$(target).innerHTML = call.responseText;
				}
			} );
		}	
		
		
		function dataFirstStep(formName,target) {
			if (!validateFirstForm(formName)) {
				return false;
			}
			
			var parms = Form.serialize($(formName));
			var context = contextPath.split(';')[0]; 
			var url = context+'RegisterUser.do';
			callAjax(url,parms,target);
			return false;
		}
		
		function updateProfile(formName,target) {
			if (!validateProfileForm(formName)) {
				return false;
			}
			var parms = Form.serialize($(formName));
			callAjax(url,parms,target);
			var context = contextPath.split(';')[0]; 
			var url = context+'PrivateUpdateProfile.do';
			callAjax(url,parms,target);
			return false;
		}
		
		function dataSecondStep(formName,target) {
			if (!validateProfileForm(formName)) {
				return false;
			}
			return true;
		}
		
		function updateFormLawyer(formName) {
			if (!validateProfileForm(formName)) {
				return false;
			}
			return true;
		}
		
		/* deprecated */
		function suggestBlog(formName, target) {
			if (!validateSendBlogMail(formName))
				return false;
			
			var context = contextPath.split(';')[0]; 
			var url = context+'SendMailForget.do';

			var parms = 'condiciones='+$(formName).condiciones.value;
			parms += '&alta_foto='+$(formName).alta_foto.value;
			parms += '&alta_autor='+$(formName).alta_autor.value;
			parms += '&alta_title='+$(formName).alta_title.value;
			parms += '&alta_blog='+$(formName).alta_blog.value;
			parms += '&alta_twt='+$(formName).alta_twt.value;
			parms += '&alta_fb='+$(formName).alta_fb.value;
			parms += '&alta_lkdin='+$(formName).alta_lkdin.value;
			parms += '&contactMail='+$(formName).contactMail.value;
			callAjax(url,parms,target);
			
			return false;
		}
		
		function sendMailError(formName, target) {
			var context = contextPath.split(';')[0]; 
			var url = context+'SendMailError.do';
			var parms = Form.serialize($(formName));
			callAjax(url,parms,target);
			return false;
		}
		
		function sendMailForget(formName, target) {
			if (!validarEmail($(formName).email.value)) {
				alert("La direcci�n de correo tiene un formato incorrecto.");
				return false;
			}
			var context = contextPath.split(';')[0]; 
			var url = context+'SendMailForget.do';

			var parms = 'email='+$(formName).email.value;
			callAjax(url,parms,target);
			
			return false;
		}
		
		function validarEmail(valor) {
			if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(valor)){
			    return true;
			} else {
			    return false;
			}
	   	}
	   
	   function validarURLs(valor) { 
			if(/^http:\/\/\w+(\.\w+)*\.\w{2,3}$/.test(valor)){
				return true;
			} else { 
				return false;
			} 
		} 
