//CerrarVentana
function Cerrar(){
	window.close();
}

// Comprueba si la variable del formulario es vacia
function esVacio(variable){
	var aux =  quitaEspacios(variable);

	return (aux.value == '');
}

//Función para comprobar si la cadena es alfabetica
function  esLetra(variable){
	var a = 0;
	var v = variable.value;

	for (var i=0;i < v.length;i++){
		if ((v.substring(i,i+1) < '0') || (v.substring(i,i+1) > '9'))
			a++;
		else
			return false;
	}
return true;
}

// Quita los espacios delanteros y traseros de una variable de un form
function quitaEspacios(variable){
    var x = variable.value;
    while (x.substring(0,1) == ' ') x = x.substring(1);
    while (x.substring(x.length-1,x.length) == ' ') x = x.substring(0,x.length-1);
	variable.value = x;
    return variable;
}

// Quita los espacios delanteros y traseros de todas las variables de un formulario
function quitaEspaciosForm(formulario){
	for(var i=0;i<formulario.length;i++){
		quitaEspacios(formulario.elements[i]);
	}
}

// Comprueba si la variable es numérica
function esNum(variable){
	v = variable.value;
	if (v.length == 0)        
		return false;
	for (var i=0;i < v.length;i++){
		if ((v.substring(i,i+1) < '0') || (v.substring(i,i+1) > '9'))
			return false;
	}
	return true;
}

// Comprueba si la variable es una dirección de correo
function esEmail(variable){

	var pos = variable.value.indexOf('@');
	if (pos == -1) return false;
	if ((pos == 0) || (pos == variable.value.length-1)) return false;

	var pos2 = variable.value.indexOf('.');
	if (pos2 == -1) return false;
	if ((pos2 == pos+1) || (pos2 == variable.value.length-1)) return false;
	for (i=0; i<variable.value.length; i++)
		if (variable.value.charAt(i) == ' ') return false;
	
	return true;

}

// Comprueba si la variable es un número y tiene el tamaño adecuado
function esTamano(variable,Min,Max){
	v = variable.value;

	if ((v.length < Min) || (v.length > Max))
		return false;
	return true;
}

function esTamanoNum(variable,Min,Max){
	v = variable.value;

	if ((v.length < Min) || (v.length > Max) || (!esNum(variable)))
		return false;
	return true;
}

//Funcion para comprobar que el formato de la fecha es (dd/mm/aaaa)
 function fechabien(frm)
 {
  var v=frm.value;
    if(v.length!=10) //longitud
  	  return false;
 

	if((v.substring(2,3)!='/')&&(v.substring(5,6)!='/')) //Posicion de las barras
	  return false;
	valorini=0;
	valorfin=2;
	for (j=0;j<3;j++){ //datos numericos
		for (var i=valorini;i<valorfin;i++){
				if ((v.substring(i,i+1) < '0') || (v.substring(i,i+1) > '9'))
					return false;
			}
		valorini+=3;
		valorfin+=3;
		if (j==2){
		valorfin=+2;
		}
	}
	vdia=v.substring(0,2);
	vmes=v.substring(3,5);
	vanio=v.substring(6,10);
	if (vanio<'1753')
		return false;
	if ((vmes<'01')||(vmes>'12'))
		return false;
	switch (vmes){
		case '02':{ //meses de 28,29 dias
			resto=vanio%4;
			if(resto==0){ //año bisiesto
				if ((vdia<'01')||(vdia>'29')) 
					return false;
			}else{ //si no es bisiesto
				if ((vdia<'01')||(vdia>'28')) 
					return false;
			}
		}
		case '04','06','09','11':{ //meses de 30 dias
			if ((vdia<'01')||(vdia>'30')) 
				return false;
		}
		default:{ //meses de 31 dias
			if ((vdia<'01')||(vdia>'31')) 
				return false;
		}
	}
    return true;
 }


function fechaCorrecta(dia,mes,anno){
	vdia=dia;
	vmes=mes;
	vanio=anno.value;
	//alert(vdia);
	//alert(vmes)
	//alert(vanio);
	
	if ((vmes<'01')||(vmes>'12')){
		alert("El mes no es correcto");
		return false;
	}
	switch (vmes){
		case '02':{ //meses de 28,29 dias
			resto=vanio%4;
			if(resto==0){ //año bisiesto
				if ((vdia<'01')||(vdia>'29')) 
					return false;
			}else{ //si no es bisiesto
				if ((vdia<'01')||(vdia>'28')) 
					return false;
			}
		}
		case '04','06','09','11':{ //meses de 30 dias
			if ((vdia<'01')||(vdia>'30')) 
				return false;
		}
		default:{ //meses de 31 dias
			if ((vdia<'01')||(vdia>'31')) 
				return false;
		}
	}
	if (esVacio(anno)){
		alert("Introducir el año");
		return false;
	}
	if (!esNum(anno)){
		alert("Introducir el año");
		return false;
	}
	if (vanio<'1753'){
		alert("El año debe ser mayor de 1753");
		return false;
	}
    return true;
 }

function quitarComillas(frm){
//FUNCION QUE QUITA 
	alert("Se quitan todas las funciones de comillas."	);
	return true;

}//funcion que quita las comillas a la 




// Da un mensaje de alerta sobre un campo si no es una dirección email y centra el foco en él.  
// NoVacio debe estar a true por que necesitamos que el campo tenga algún valor =>
// Si noVacio == false => si esta vacio no pasa nada, pero si tiene algo debe ser un email válido
// Si noVacio == true  => debe contener un email válido 
// Retorna true si no tuvo que enviar ninguna alerta y false en caso contrario
function alertSiNoFechaCorrecta(v, noVacio){
	if(noVacio){
		if (esVacio(v)){
			alert("Debe introducir algún valor en todos los campos cuyo nombre contenga (*)");
			v.focus();
			return false;
		}
		if (! fechabien(v)){
			alert("La Fecha introducida  no es válida, debe de tener el formato dd/mm/aaaa");
			v.focus();
			return false;
		}
	} else{
		if(!esVacio(v)){
			if (! fechabien(v)){
				alert("La Fecha introducida  no es válida, debe de tener el formato dd/mm/aaaa");
				v.focus();
				return false;
			}	
		}
	}
	return true;
}




// Da un mensaje de alerta sobre un campo si no es una dirección email y centra el foco en él.  
// NoVacio debe estar a true por que necesitamos que el campo tenga algún valor =>
// Si noVacio == false => si esta vacio no pasa nada, pero si tiene algo debe ser un email válido
// Si noVacio == true  => debe contener un email válido 
// Retorna true si no tuvo que enviar ninguna alerta y false en caso contrario
function alertSiNoEmail(v, noVacio){
	if(noVacio){
		if (esVacio(v)){
			alert("Debe introducir algún valor en todos los campos cuyo nombre contenga (*)");
			v.focus();
			return false;
		}
		if (!esEmail(v)){
			alert("Dirección de correo no válida, debe introducir: Identificador@Ruta.País");
			v.focus();
			return false;
		}
	} else{
		if(!esVacio(v)){
			if (!esEmail(v)){
				alert("Dirección de correo no válida,/ndebe introducir: Identificador@Ruta.País");
				v.focus();
				return false;
			}	
		}
	}
	return true;
}



// Da un mensaje de alerta sobre un campo si no es un número de teléfono y centra el foco en él.  
// NoVacio debe estar a true por que necesitamos que el campo tenga algún valor =>
// Si noVacio == false => si esta vacio no pasa nada, pero si tiene algo debe ser un tf válido
// Si noVacio == true  => debe contener un Tf válido 
// Retorna true si no tuvo que enviar ninguna alerta y false en caso contrario

function alertSiNoTf(v, noVacio){
	if(noVacio){
		if (esVacio(v)){
			alert("Debe introducir algún valor en todos los campos cuyo nombre contenga (*)");
			v.focus();
			return false;
		}
		if (!esTamanoNum(v,9,9)){
			alert("Los números de teléfono deben tener 9 dígitos");
			v.focus();
			return false;
		}
	} else{
		if(!esVacio(v)){
			if (!esTamanoNum(v,9,9)){
				alert("Los números de teléfono deben tener 9 dígitos");
				v.focus();
				return false;
			}	
		}
	}
	return true;
}

// Da un mensaje de alerta sobre un campo si no es un C. Postal y centra el foco en él.  
// NoVacio debe estar a true por que necesitamos que el campo tenga algún valor =>
// Si noVacio == false => si esta vacio no pasa nada, pero si tiene algo debe ser un tf válido
// Si noVacio == true  => debe contener un C. Postal válido 
// Retorna true si no tuvo que enviar ninguna alerta y false en caso contrario
function alertSiNoCPostal(v, noVacio){
	if(noVacio){
		if (esVacio(v)){
			alert("Debe introducir algún valor en todos los campos cuyo nombre contenga (*)");
			v.focus();
			return false;
		}
		if (!esTamanoNum(v,5,5)){
			alert("El campo debe contener 5 dígitos");
			v.focus();
			return false;
		}
	} else{
		if(!esVacio(v)){
			if (!esTamanoNum(v,5,5)){
				alert("El campo debe contener 5 dígitos");
				v.focus();
				return false;
			}
		}
	}
	return true;
}


// Da un mensaje de alerta sobre un campo si es vacio y centra el foco en él. 
// Retorna true si no tuvo que enviar ninguna alerta y false en caso contrario 
function alertSiVacio(v){
	if (esVacio(v)){
		alert("Debe introducir un valor en todas aquellas casillas cuyo nombre contenga (*)");
		v.focus();
		return false;
	}
	return true;
}




// Da un mensaje de alerta si el numero de caracteres no se encuentra en el sistema.
function alertSiNoEstaEnIntervalo(variable,Min,Max){
	quitaEspacios(variable);
	v = variable.value;
	if ((v.length < Min)){
		var msg ="El texto introducido es inferior a (" + Min + ") Caracteres.";
		alert( msg);
		variable.focus();
		return false;
	}

	if ((v.length > Max)){
		var msg ="El texto introducido es superior a (" + Max + ") Caracteres.";
		alert( msg);
		variable.focus();
		return false;
	}
	
	return true;
}//fin de alartsinoestaneintervalo.
   
function esMayorFecha(fecha1,fecha2){
	var f1 = fecha1.value;
	var f2 = fecha2.value;

	var vdia1=f1.substring(0,2);
	var vmes1=f1.substring(3,5);
	var vanio1=f1.substring(6,10);
	
	var vdia2=f2.substring(0,2);
	var vmes2=f2.substring(3,5);
	var vanio2=f2.substring(6,10);
	if (vanio2>vanio1)
		return false;
	if (vmes2>vmes1)
		return false;
	if (vanio1<=vanio2)
		if (vmes1<=vmes2)
			if ((vmes1==vmes2) && (vdia1<vdia2))
				return false;
			else 
				if ((vmes1<vmes2) && (vdia1<=vdia2))
					return false;
	return true;
}
function esFecha(frm){
	if (!fechabien(frm))
	{
		alert("El formato de fecha es incorrecto. Debe ser dd/mm/aaaa.");	
		frm.focus();
		return false;
	}
	return true;
}


function convertirPunto(valor){
	var resul = "";
	for (i=0;i<valor.length ;i++){
		if (valor.charAt(i) == ","){
			resul += "."; 
		}else
			if (valor.charAt(i) != "."){
				resul +=valor.charAt(i);
			}
	}
	return resul;
}


var mensaje = "";
var valorE = 166.386;

function calcularPts(euros,pts){
	if (!formatearImporte(euros,1))
		return false;
	var precioE = convertirPunto(euros.value);			
	var precioP = precioE * valorE;
	pts.value = cambiarCaracter(precioP,'.',',');		
	formatearImporte (pts,2);
	return true;
}


function formatearImporte(cmp,tipo){

  var importe = cmp.value;	  
  var tieneComa=false;
  var importeString=""+importe;
  for(k=importeString.length-1;k>=0;k--){
    if(importeString.charAt(k)==","){
      tieneComa= true;
      var posicionComa=k;
    }
  }
  var entero=importeString;
  var decimal="";
  if(tieneComa){
    entero=importeString.substring(0,posicionComa);
	if (tipo!=2)
		decimal=","+importeString.substring(posicionComa+1,posicionComa+3);  
  } 
  if (comprobarFormato(entero,decimal,tipo)){
	  cmp.value = entero+decimal;
	  return true;
  }
  var numPartes=-1;
  var partes=new Array();
  if(entero.length>3){
    while(entero.length>0){
     numPartes++;
     partes[numPartes]=entero.substring(entero.length-3,entero.length);
     entero=entero.substring(0,entero.length-3);	
	 var enteroAux = "";
	 for (i=0;i<entero.length;i++){
		if (entero.charAt(i)==".")
			enteroAux = enteroAux;
		else
			enteroAux +=entero.charAt(i);		
	 }
	 entero = enteroAux;	
    }
    entero="";
    for(f=partes.length-1;f>=0;f--){
      entero+=partes[f];
     if(f>0)
        entero+="."; 
    }
  }  

 if (comprobarFormato(entero,decimal,tipo))
 {	
	cmp.value = entero+decimal;
	return true;
 }else{
	cmp.focus();
	if (mensaje == "")
		mensaje = "El valor introducido no es valido";
	alert(mensaje);
	return false;  
}
  //return entero+decimal;  
}

function esDecimal(cmp){
 var tipo=0;
  var importe = cmp.value;	  
  var tieneComa=false;
  var importeString=""+importe;
  for(k=importeString.length-1;k>=0;k--){
    if(importeString.charAt(k)==","){
      tieneComa= true;
      var posicionComa=k;
    }
  }
  var entero=importeString;
  var decimal="";
  if(tieneComa){
    entero=importeString.substring(0,posicionComa);
	if (tipo!=2)
		decimal=","+importeString.substring(posicionComa+1,posicionComa+3);  
  } 
  if (comprobarFormato(entero,decimal,tipo)){
	  cmp.value = entero+decimal;
	  return true;
  }
  var numPartes=-1;
  var partes=new Array();
  if(entero.length>3){
    while(entero.length>0){
     numPartes++;
     partes[numPartes]=entero.substring(entero.length-3,entero.length);
     entero=entero.substring(0,entero.length-3);	
	 var enteroAux = "";
	 for (i=0;i<entero.length;i++){
		if (entero.charAt(i)==".")
			enteroAux = enteroAux;
		else
			enteroAux +=entero.charAt(i);		
	 }
	 entero = enteroAux;	
    }
    entero="";
    for(f=partes.length-1;f>=0;f--){
      entero+=partes[f];
     if(f>0)
        entero+="."; 
    }
  }  

 if (comprobarFormato(entero,decimal,tipo))
 {	
	cmp.value = entero+decimal;
	return true;
 }else{
	cmp.focus();
	if (mensaje == "")
		mensaje = "El valor introducido no es valido";
	alert(mensaje);
	return false;  
}
  //return entero+decimal;  
}

function comprobarFormato(entero,decimal,tipo){
	var longi = entero.length;	
    while(longi>0){ 		
		if(longi>=4){	
		  for (i=longi-1;i>longi-4;i--)			
		  	if ((entero.charAt(i) < '0') || (entero.charAt(i) > '9'))
					return false;		   
		  longi = longi - 4;		
		  if (entero.charAt(longi)!=".")
			return false;
		}else{
			for (i=longi-1;i>=0;i--)
		  		if ((entero.charAt(i) < '0') || (entero.charAt(i) > '9'))
					return false;
		  
			longi=0;
		}
	}
	longi = decimal.length;	
	if (longi==1)
		return false;	
	if (longi>1)
		for (i=1;i<longi;i++){		
			if ((decimal.charAt(i) < '0') || (decimal.charAt(i) > '9'))
				return false;	
		}	
		
	switch (tipo){
	case 1:
		if (entero.length>7){
			mensaje = "El rango numérico máximo de este campo es 999.999,99";
			return false;
		}
		break;
	case 2:
		if (entero.length>11){
			mensaje = "El rango numérico máximo de este campo es 99.999.999";
			return false;
		}
		break;
	case 3:			
		if (entero.length>2){
			mensaje = "El rango numérico máximo de este campo es 99,99";
			return false;
		}
		break;
	}
	
	return true;
}

function quitarPunto(entero){
	var resul="";
	for (i=0;i<entero.length ;i++ )
		if (entero.charAt(i) != ".")
			resul += entero.charAt(i);
	return resul;
}

function estraerValor(url,dato){	
	var len = url.length;// - dato.length;
	for (i=0;i<len;i++)
	{		
		if (url.substring(i,(i+dato.length)) == dato)
		{
			for (j=(i+dato.length);j<len ;j++)
			{
				if (url.substring(j,j+1) == "&")
				{
					return url.substring(i+dato.length,j);
				}
			}
			return url.substring(i+dato.length,url.length);
		}
	}
	return "";

}

function esMayor(){
	if (esVacio(frmprecio.txtdesde)){
		//alert("El valor del campo DESDE no puede estar vacío.");
		alert (alert_8);
		frmprecio.txtdesde.focus();
		return false;
	}

	if (esVacio(frmprecio.txthasta)){
		//alert("El valor del campo HASTA no puede estar vacío.");
		alert (alert_9);
		frmprecio.txthasta.focus();
		return false;
	}
	
	if (frmprecio.txtdesde.value > frmprecio.txthasta.value){
		//alert("El valor del campo DESDE debe ser menor que el valor del campo HASTA");
		alert (alert_10);
		frmprecio.txtdesde.focus();
		return false;
	}
	return true;

}

function esMayorCombi(){	
	if (frmprecio.txtdesde.value > frmprecio.txthasta.value){
		//alert("El valor del campo DESDE debe ser menor que el valor del campo HASTA");
		alert (alert_10);
		frmprecio.txtdesde.focus();
		return false;
	}
	return true;

}

var carac_raros   = Array("à", "è", "ì", "ò", "ù", "ä", "ë", "ï", "ö", "ü", "â", "ê", "î", "ô", "û", "'", "\"");
var carac_normal  = Array("a", "e", "i", "o", "u", "a", "e", "i", "o", "u", "a", "e", "i", "o", "u", "´", "´´");
 
function convertirTerminos(formulario){
 for (var i=0;i<formulario.length;i++){
  formulario.elements[i].value = convertirTermino(formulario.elements[i]);
 }
 return false;
}
 
function convertirTermino(elemento){
 
 var terminoinicial = elemento.value;
 var terminofinal  = '';
 
 for (var i=0;i<terminoinicial.length;i++){
  var vi = i;
  var vf = vi + 1;
  for (j=0;j<=16;j++){
   if (terminoinicial.substring(vi,vf) == carac_raros[j]){
    caracter = carac_normal[j];
    break;
   }else{
    caracter = terminoinicial.substring(vi,vf);
   }
  }
  terminofinal = terminofinal + caracter;
 }
 return terminofinal;
}

function cargarElementosOrden(){
	document.frmorden.idsw.value = document.frmorden.idsw.value -1;
	document.frmorden.submit();
}

var treMen = null; 
 function vistaPrevia(dir){ 
		var url = dir; 
		treMen=window.open('','Ventana','toolbar=no,scrollbars=yes,location=no,directories=no,menubar=no,resizable=yes,left=200,top=150,width=650,height=500');
		treMen.location.href=url; 
		if(treMen.opener==null) 
			treMen.opener=self; 
 	}//fin de abrir ventana 

function formatear(importe){
  importe = quitarPunto(importe);
  importe = cambiarComa(importe);
  return importe;
}


function formatearValor(importe,tipo){
  var tieneComa=false;
  var importeString=""+importe;
  for(k=importeString.length-1;k>=0;k--){
    if(importeString.charAt(k)=="."){
      tieneComa= true;
      var posicionComa=k;
    }
  }
  var entero=importeString;
  var decimal="";
  if(tieneComa){
    entero=importeString.substring(0,posicionComa);
	if (tipo!=2)
		//decimal=","+importeString.substring(posicionComa+1,posicionComa+3); 
	    //CUATRO DECIMALES
		decimal=","+importeString.substring(posicionComa+1,posicionComa+5);  

	if (decimal.length>0 && decimal.length<3)
		decimal = decimal + "0";
  } 
  if (decimal == '') decimal = ",00";
  if (comprobarFormato(entero,decimal,tipo)){
	  return entero+decimal;
  }
  var numPartes=-1;
  var partes=new Array();
  if(entero.length>3){
    while(entero.length>0){
     numPartes++;
     partes[numPartes]=entero.substring(entero.length-3,entero.length);
     entero=entero.substring(0,entero.length-3);	
	 var enteroAux = "";
	 for (j=0;j<entero.length;j++){
		if (entero.charAt(i)==".")
			enteroAux = enteroAux;
		else
			enteroAux +=entero.charAt(j);		
	 }
	 entero = enteroAux;	
    }
    entero="";
    for(f=partes.length-1;f>=0;f--){
      entero+=partes[f];
     if(f>0)
        entero+="."; 
    }
  }  
 if (decimal == '') decimal = ",00";
 if (comprobarFormato(entero,decimal,tipo))
 {	
	return entero+decimal;
 }/*else{
	cmp.focus();
	if (mensaje == "")
		mensaje = "El valor introducido no es valido";
	alert(mensaje);
	return false;  
}*/
  //return entero+decimal;  
}


function formatearValor2(importe,tipo){
  var tieneComa=false;
  var importeString=""+importe;
  for(k=importeString.length-1;k>=0;k--){
    if(importeString.charAt(k)=="."){
      tieneComa= true;
      var posicionComa=k;
    }
  }
  var entero=importeString;
  var decimal="";
  if(tieneComa){
    entero=importeString.substring(0,posicionComa);
	if (tipo!=2)
		//DOS DECIMALES
		decimal=","+importeString.substring(posicionComa+1,posicionComa+3); 
	    //CUATRO DECIMALES
		//decimal=","+importeString.substring(posicionComa+1,posicionComa+5);  

	if (decimal.length>0 && decimal.length<3)
		decimal = decimal + "0";
  } 
  if (decimal == '') decimal = ",00";
  if (comprobarFormato(entero,decimal,tipo)){
	  return entero+decimal;
  }
  var numPartes=-1;
  var partes=new Array();
  if(entero.length>3){
    while(entero.length>0){
     numPartes++;
     partes[numPartes]=entero.substring(entero.length-3,entero.length);
     entero=entero.substring(0,entero.length-3);	
	 var enteroAux = "";
	 for (j=0;j<entero.length;j++){
		if (entero.charAt(i)==".")
			enteroAux = enteroAux;
		else
			enteroAux +=entero.charAt(j);		
	 }
	 entero = enteroAux;	
    }
    entero="";
    for(f=partes.length-1;f>=0;f--){
      entero+=partes[f];
     if(f>0)
        entero+="."; 
    }
  }  
 if (decimal == '') decimal = ",00";
 if (comprobarFormato(entero,decimal,tipo))
 {	
	return entero+decimal;
 }/*else{
	cmp.focus();
	if (mensaje == "")
		mensaje = "El valor introducido no es valido";
	alert(mensaje);
	return false;  
}*/
  //return entero+decimal;  
}//formatearValor2()


function cambiarComa(entero){
	var resul="";
	for (z=0;z<entero.length ;z++ )
		if (entero.charAt(z) != ",")
			resul += entero.charAt(z);
		else
			resul += ".";
	return resul;
}

function cambiarCaracter(entero,cambiar,por){
	var resul="";
	for (z=0;z<entero.length ;z++ )
		if (entero.charAt(z) != cambiar)
			resul += entero.charAt(z);
		else
			resul += por;
	return resul;
}


function eliminardecimales(entero){
	//alert("*"+entero+"*");
	var resul="";
	for (z=0;z<entero.length ;z++ )
		if (entero.charAt(z) != ",")
			resul += entero.charAt(z);
		else
			return resul;
	return resul;
}

function redondear(value, precision)
{
        value = "" + value;
        precision = parseInt(precision);

        var whole = "" + Math.round(value * Math.pow(10, precision));

        var decPoint = whole.length - precision;

        if(decPoint != 0)
        {
                result = whole.substring(0, decPoint);
                result += ".";
                result += whole.substring(decPoint, whole.length);
        }
        else
        {
                result = 0;
                result += ".";
                result += whole.substring(decPoint, whole.length);
        }
        return result;
}


// Comprueba si la variable es una dirección de correo
function esEmail(variable){

	var pos = variable.value.indexOf('@');
	if (pos == -1) return false;
	if ((pos == 0) || (pos == variable.value.length-1)) return false;

	var pos2 = variable.value.indexOf('.');
	if (pos2 == -1) return false;
	if ((pos2 == pos+1) || (pos2 == variable.value.length-1)) return false;
	for (i=0; i<variable.value.length; i++)
		if (variable.value.charAt(i) == ' ') return false;
	
	return true;

}
// Da un mensaje de alerta sobre un campo si no es una dirección email y centra el foco en él.  
// NoVacio debe estar a true por que necesitamos que el campo tenga algún valor =>
// Si noVacio == false => si esta vacio no pasa nada, pero si tiene algo debe ser un email válido
// Si noVacio == true  => debe contener un email válido 
// Retorna true si no tuvo que enviar ninguna alerta y false en caso contrario
function alertSiNoEmail(v, noVacio){
	if(noVacio){
		if (esVacio(v)){
			alert("Debe introducir algún valor en todos los campos cuyo nombre contenga (*)");
			v.focus();
			return false;
		}
		if (!esEmail(v)){
			alert("Dirección de correo no válida, debe introducir: Identificador@Ruta.País");
			v.focus();
			return false;
		}
	} else{
		if(!esVacio(v)){
			if (!esEmail(v)){
				alert("Dirección de correo no válida,/ndebe introducir: Identificador@Ruta.País");
				v.focus();
				return false;
			}	
		}
	}
	return true;
}

 //Comprobar NIF válido
  function esNIFValido(dni) {
	 quitaEspacios(dni);
	var d = dni.value;

	var letra = d.substring(d.length-1,d.length);
	d = d.substring(0,d.length-1);
		var letras = 'TRWAGMYFPDXBNJZSQVHLCKE';
		
		var numero = d%23;
		var letraNIF = letras.substring(numero,numero+1);

		if (letraNIF!=letra.toUpperCase()){
			//alert("El NIF introducido no es válido");
			//dni.focus();
			return false;
		}
	return true;
}

