// Limitar caracteres alfanuméricos
function miracaracter(e) {
	tecla = (document.all) ? e.keyCode : e.which;
	if (tecla==8) return true; //TECLA DE BORRAR (RETROCESO)
	if (tecla==0) return true; //TECLAS ESPECIALES COMO CURSORES, SUPRIMIR, TABULADOR ...
	if (tecla==45 || tecla==46 || tecla==64) return true; //guión, punto, arroba
		//patron = /\d/; // Solo acepta numeros
                patron = /\w/; // Solo acepta numeros
		te = String.fromCharCode(tecla);
	return patron.test(te);
}

// Registro
function validadatosregistro() {
	var f = document.datosregistro;
	if (f.email.value=='' || f.nombre.value=='' || f.apellido_1.value=='' || f.apellido_2.value==''){
		alert('Todos los campos marcados con (*) son obigatorios.');
		return false;
	}
	if(f.clave.value!=f.clavev.value){
		alert('Los claves no coinciden');
		return false;
	}
	if(!f.aceptacondiciones.checked){
		alert('Es necesario aceptar las condiciones de uso y la política de privacidad.');
		return false;
	}
	if(f.permite_registro.value==0){
		alert('El E-mail que has introducido ya existe en Motobuykers.');
		return false;
	}
	return true;
}
function activa_registro(i){
	document.datosregistro.permite_registro.value=i;
}

// Actuailza datos perfil
function validadatosperfil() {
	var f = document.edit;
	if (f.email.value=='' || f.nombre.value=='' || f.apellido_1.value=='' || f.apellido_2.value==''){
		alert('Todos los campos marcados con (*) son obigatorios.');
		return false;
	}
	if(f.permite_cambios.value==0){
		alert('El E-mail que has introducido ya existe en Motobuykers.');
        		return false;
        	}
        document.edit.submit();
}
function permite_cambios(i){
	document.edit.permite_cambios.value=i;
}
function validaclave() {
	var f = document.edit_clave;
	if (f.clave.value==''){
		alert('Debes introducir una clave');
		return false;
	}
        if(f.clave.value!=f.clavev.value){
		alert('Los claves no coinciden');
		return false;
	}
	return true;
}


function confirma_delete(){
    var respuesta_delete=confirm("¿Estas seguro?");
    if (respuesta_delete==true){
        	return true;
    	}else{
        	return false;
	}
}
