    	function checkformUsuario(of)
		{
			var reqfields,em,i,f,ty;

			if(document.getElementById('required'))
			{
				reqfields=document.getElementById('required').value.split(',');
				if(document.getElementById('errormsg')){
					em=document.getElementById('errormsg');
					em.parentNode.removeChild(em);
				}
				for(i=0;i<reqfields.length;i++)
				{
					f=document.getElementById(reqfields[i]);
					if(f.previousSibling && /img/i.test(f.previousSibling.nodeName)){
						f.parentNode.removeChild(f.previousSibling);
					}
					//f.style.background='transparent';
					f.style.background='white';
					if(f){
						ty=f.type.toLowerCase();
						switch(ty)
						{
							case 'text':
								if (f.id=='email') {
									if(!isEmailAddr(f.value)){adderr(f.id,of)}
								} else {
									if(f.value==''){adderr(f.id,of)}
								}
							break;
							case 'password':
								if(f.value==''){
									adderr(f.id,of);
								} else {
									if (!checkPasswords())
										adderr(f.id,of);
								}
							break;
							case 'checkbox':
								if(!f.checked){adderr(f.id,of)}							
							break;
							/* extend as needed */
						}
					}
					
				}
			}
			if(document.getElementById('errormsg'))
			{
				return false;
			}
		}
		function checkPasswords()
		{
			var pwd1, pwd2; 
			pwd1 = document.getElementById('password').value;
			pwd2 = document.getElementById('password2').value;
			return (pwd1==pwd2);
		}
		function adderr(id,of)
		{
		 	var se,i,nli,na;
			i=document.createElement('img');
			i.src='img/alert.gif';
			i.alt='Error';
			i.title='This field has an error!';
			se=document.getElementById(id);
			se.parentNode.insertBefore(i,se)
			se.style.background='#fcc';
			if(!document.getElementById('errormsg')){
				var em=document.createElement('p');
				em.id='errormsg';
				em.appendChild(document.createTextNode('Introduzca o corrija los campos marcados con '))
				i=document.createElement('img');
				i.src='img/alert.gif';
				i.alt='Error';
				i.title='This field has an error!';
				em.appendChild(i);
				for(var i=0;i<of.getElementsByTagName('input').length;i++)
				{
					if(/submit/i.test(of.getElementsByTagName('input')[i].getAttribute('type')))
					{
						var sb=of.getElementsByTagName('input')[i];
						break;
					}
				}
				em.style.border='2px solid #c00';
				em.style.padding='5px';
				em.style.width='20em';
				sb.parentNode.insertBefore(em,sb);
			}
			if(id=='email' && !isEmailAddr(document.getElementById(id).value)){
				pn=document.createElement('p');
				pn.appendChild(document.createTextNode('Email incorrecto'))
				document.getElementById('errormsg').appendChild(pn);
			}
			if(id=='password' && !checkPasswords()){
				pn=document.createElement('p');
				pn.appendChild(document.createTextNode('Error de confirmación de contraseña'))
				document.getElementById('errormsg').appendChild(pn);
			}
		}

		function isEmailAddr(email)
		{
			// Esta validación no funcionaba porque no permitía poner puntos en el username
		    //return email.match(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/);
			var ind1, ind2, ind3;
			ind1 = email.indexOf('@');
			ind2 = email.lastIndexOf('.');
			ind3 = email.lastIndexOf('@');
			indSp = email.indexOf(' ');
			return !((ind1<=0) || (ind2<ind1) || (ind3 != ind1) || (indSp!=-1));
		}

		function confirmDelete(alias)
		{
			return confirm("¿Está usted seguro de que desea eliminar el usuario "+alias+"?");
		}

		function redirect(sUrl)
		{
			window.location=sUrl;
		}

		function sumar(sum1, sum2)
		{
		    var resultado;
		    resultado = sum1 + sum2;
		    document.write(resultado);
		}

		function alerta(texto)
		{
			alert(texto);
		}

