function Entrar(pAction){
	if(document.getElementById('Usuario').value == ''){
		alert('Debe introducir el usuario');
		document.getElementById('Usuario').focus();
	}else{
		if(document.getElementById('Password').value == ''){
			alert('Debe introducir la password');
			document.getElementById('Password').focus();
		}else{
			document.getElementById('Entrada').action = pAction;
			document.getElementById('Entrada').submit();
		}
	}
}

function AltaUsuario(pAction){
	if(document.getElementById('Nombre').value == '' && document.getElementById('Apellidos').value == '' && document.getElementById('Email').value == '' && document.getElementById('EmailAmigo').value == ''){
		alert('Debe rellenar el formulario');
		document.getElementById('Nombre').focus();
	}else{
		if(document.getElementById('Email').value == ''){
			alert('El email es obligatorio');
			document.getElementById('Email').focus();
		}else{
			if(!CompruebaEmail(document.getElementById('Email').value)){
				alert('Debes introducir un email válido');
				document.getElementById('Email').focus();
			}else{
				if(document.getElementById('EmailAmigo').value != ''){
					if(document.getElementById('EmailAmigo').value == document.getElementById('Email').value){
						alert('El email de tu amigo debe ser distinto del tuyo');
						document.getElementById('EmailAmigo').focus();
					}else{
						if(!CompruebaEmail(document.getElementById('EmailAmigo').value)){
							alert('Debes introducir un email válido');
							document.getElementById('EmailAmigo').focus();
						}else{
							if(document.getElementById('Nombre').value == ''){
								alert('El nombre es obligatorio');
								document.getElementById('Nombre').focus();
							}else{
								document.getElementById('frmUsuario').action = pAction;
								//AbrirVentana('FT_Condiciones.asp','',718,432,0,0,0,0,0,0,0,0);
								document.getElementById('frmUsuario').submit();
							}
						}
					}
				}else{
					document.getElementById('frmUsuario').action = pAction;
					//AbrirVentana('FT_Condiciones.asp','',718,432,0,0,0,0,0,0,0,0);
					document.getElementById('frmUsuario').submit();
				}
			}
		}
	}
}


function CompruebaEmail(pValor) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(pValor)){
	    return (true);
	}else{
		return (false);
	}
}


function AbrirVentana(pVentana,Nombre,Ancho,Alto,Left,Top,Scroll,Resize,Tool,Status,Menu,Location){
var Ventana;
var Opciones;
	if((Ancho > screen.width) || (Ancho == 0)){
		Ancho = screen.width - 2;
	}
	if((Alto > screen.height) || (Alto == 0)){
		Alto = screen.height - 2;
	}
	if(Left == 0){
		Left	= ((screen.width - Ancho)/2);
	}
	if(Top == 0){
		Top			= ((screen.height - Alto)/2);
	}
	Opciones	= 'width='+Ancho+',height='+Alto+',top='+Top+',left='+Left+',toolbar='+Tool+',scrollbars='+Scroll+',location='+Location+',statusbar='+Status+',menubar='+Menu+',resizable='+Resize;
	Ventana	= window.open(pVentana,Nombre,Opciones);
	Ventana.focus();
}

function EnviarCodigo(pPagina){
	alert(pagina)
	if(document.getElementById('CodAcceso').value == ''){
		alert('Debes escribir tu Código de Acceso Gratuito');
		document.getElementById('CodAcceso').focus();
	}else{
		document.getElementById('Email').value = '';
		document.getElementById('Newsletter').checked = false;
		document.getElementById('frmCodigo').action = pPagina;
		document.getElementById('frmCodigo').submit();
	}
}

function SolicitarCodigo(pPagina){
	if(document.getElementById('Email').value == ''){
		alert('Debes escribir tu email');
		document.getElementById('Email').focus();
	}else{
		if(!CompruebaEmail(document.getElementById('Email').value)){
			alert('Debe introducir un email válido');
			document.getElementById('Email').focus();
		}else{
			document.getElementById('CodAcceso').value = '';
			document.getElementById('frmUsuario').action = pPagina;
			//AbrirVentana('FT_Condiciones.asp','',718,432,0,0,0,0,0,0,0,0);
			document.getElementById('frmUsuario').submit();
		}
	}
}

function AceptarCondiciones(){
	if(document.getElementById('CheckAcepto').checked){
		window.opener.document.getElementById('AceptoHid').value = '1';
	}else{
		window.opener.document.getElementById('AceptoHid').value = '0';
	}
}