function nousuario(email)
{
	if(!email) email="";
	window.open('nousuario.php?email='+email, 'ventana_no_registrado', 'top=10, left=20, toolbar=no, location=0, directories=0, status=0, scrollbars=no, resizable=0, width=296, height=267');
}

function validar(formulario)
{
		 if (formulario.email.value == "")
		 {
			alert("Es necesario rellenar el campo email antes de enviar.");
			return false;
		 }

		 /* comienzo a validar el email si lo hay*/
		 if(formulario.email.value!="")
		 {
			var checkTLD=1;
			var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
			var emailPat=/^(.+)@(.+)$/;
			var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
			var validChars="\[^\\s" + specialChars + "\]";
			var quotedUser="(\"[^\"]*\")";
			var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
			var atom=validChars + '+';
			var word="(" + atom + "|" + quotedUser + ")";
			var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
			var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
			var matchArray=formulario.email.value.match(emailPat);

			if (matchArray==null) {
			alert("La dirección de email parece incorrecta (comprueba @ y .)");
			formulario.email.focus();
			return false;
			}
			var user=matchArray[1];
			var domain=matchArray[2];
			for (i=0; i<user.length; i++) {
			if (user.charCodeAt(i)>127) {
			alert("El nombre de usuario contiene caracteres incorrectos en la dirección de correo.");
			formulario.email.focus();
			return false;
				 }
			}
			for (i=0; i<domain.length; i++) {
			if (domain.charCodeAt(i)>127) {
			alert("El dominio contiene caracteres incorrectos en la dirección de correo.");
			formulario.email.focus();
			return false;
				 }
			}
			if (user.match(userPat)==null) {
			alert("El nombre de usuario no es válido en la dirección de correo.");
			formulario.email.focus();
			return false;
			}
			var IPArray=domain.match(ipDomainPat);
			if (IPArray!=null) {
			for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
			alert("La IP de destino no es válida en la dirección de correo.");
			formulario.email.focus();
			return false;
				 }
			}
			return true;
			}
			var atomPat=new RegExp("^" + atom + "$");
			var domArr=domain.split(".");
			var len=domArr.length;
			for (i=0;i<len;i++) {
			if (domArr[i].search(atomPat)==-1) {
			alert("El nombre del dominio no es válido en la dirección de correo.");
			formulario.email.focus();
			return false;
				 }
			}
			if (checkTLD && domArr[domArr.length-1].length!=2 && 
			domArr[domArr.length-1].search(knownDomsPat)==-1) {
			alert("La dirección de correo debe terminar en un dominio conocido o de un país.");
			formulario.email.focus();
			return false;
			}
			if (len<2) {
			alert("Falta el dominio en la dirección de correo.");
			formulario.email.focus();
			return false;
			}
			/* termino de validar el email y si todo ok, devuelve true*/
			return (true);
	 }
}

function VAL_mail(correo) {
var i;var arroba;
var es_valido;
arroba=0;
//
  if (correo.value == "" || correo.value.indexOf ('@', 0) == -1 || correo.value.indexOf ('.', 0) == -1 || correo.value.length < 8) {
     alert("Tienes que introducir un e-mail válido.\nComprueba que no tenga errores.");
     es_valido=0;
	 return(es_valido); 
  }else{
     newString = "";
  for (i = 0; i < correo.value.length; i++) {
   ch = correo.value.substring(i, i+1); 
  if ((ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z") || (ch >= "0" && ch <= "9") || (ch=="-") || (ch=="_")) {
     newString+=ch;
     ultimo=ch;
  if (arroba > 0) {
     arroba++;
  }}else{
  if (ch=="@") {
  if (arroba==0) {
     newString+=ch;
     arroba++;}
     ultimo="@";}
  if (ch==".") {
  if (arroba != 1) {
     newString+=ch;}
  ultimo=".";
  }}}
  if ((correo.value != newString) || (ultimo == "@") || (ultimo == ".")) {
     alert("Tienes que introducir un e-mail válido.\nComprueba que no tenga errores.");
     es_valido=0;
	 return(es_valido); 
  }
  else
	  {
	   es_valido=1;
	   return(es_valido); 	
	  }
	  }
}



function swapimg() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preimg() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=preimg.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function findobj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findobj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapimg2() { //v3.0
  var i,j=0,x,a=swapimg2.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findobj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function abrirven(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function saltamenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}



