var
 vTecla;

//Valida las líneas de pedido de almacén que no sea inferior a lo servido.
function validaCantidad(t,antes,despues,servido) {   
  if (despues < servido)
  {      
	 alert ("No es posible poner menos cantidad que lo servido.")
	 t.value = antes;
	  return false  
  }
  else 
     return true        
}    
//**************** PRUEBA ***************************************

function Prueba(v) {
  //alert("PRUEBA:"+v)             
 //  this.style.visibility = 'hidden'
 if ( (v=='P'))
 {
	document.formulario.iPRESUP.style.visibility  = 'visible' ;
	document.formulario.iACUENTA.style.visibility = 'visible' ;
	document.formulario.iFIN.style.visibility     = 'visible' ;
	
 }
 else
 {
	document.formulario.iPRESUP.style.visibility  = 'hidden' ;
	document.formulario.iACUENTA.style.visibility = 'hidden' ;
    document.formulario.iFIN.style.visibility     = 'hidden' ;

 }
  
}
//**************** MSG ERROR ***********************************
function MsgError(error,mensaje) {
    alert('ERROR ' +error+': '+mensaje);

}

//**************** VALIDAR NIF ***********************************
function ValidarNif(dni) {
  numero = dni.substr(0,dni.length-1);
  let = dni.substr(dni.length-1,1);
  numero = numero % 23;
  letra='TRWAGMYFPDXBNJZSQVHLCKET';
  letra=letra.substring(numero,numero+1);
  if (letra!=let) 
    alert('Dni erroneo');
 
}
//********* PULSAR TECLA *****************
function pulsarTecla(e) {
 if (ns4) 
 {
	  var TeclaN=e.which; var teclaReal = String.fromCharCode(TeclaN)
       //alert("Número:  "+ TeclaN + "\nReal:  " + teclaReal)
 }
 if (ie4) 
 {
	 var TeclaIE=event.keyCode; var teclaReal = String.fromCharCode(TeclaIE)
          // alert("Número:  "+ TeclaIE + "\nReal:  " + teclaReal)
  }
  varjs = teclaReal;
  alert("XXX:"+varjs)
}

//********* PEDIR DATO *****************
function PedirDato(pantalla,titulo,campo) {   
//  prompt("Prueba: ","1") 
 if (pantalla=="TpvPres.php")
 {
   var nombre = prompt(titulo ,"")
   return true;
 }
 else
   return false;
  //confirm("¿Desea volver al inicio de la página?")
}
function GuardaTxt(pantalla,titulo,campo){ 
//var valor=inputBox.value; 
   var direc="TpvArt.php";//+inputBox.name+"="+valor; 
   //window.open(direc,'_top'); 
    alert ("OK.")
	 	window.open("TpvArt.php",'comersan','fullscreen=yes,scrollbars=no')

//   location.href = "TpvClientes.php";
} 
function PincharBoton(pantalla,estado,campo) {   
 //alert ("A."+pantalla+" B."+estado+" C."+campo);
 //PEDIDOS
 if (pantalla=="TpvPed.php")
 {
  if (estado=="MODIFICAR")
  {
   if (campo=="S")
   {
	  alert ("No es poble modificar un pedido ACEPTADO por la central.")
      return false
   }
   else
     return true        
  }
 }//FIN PEDIDOS
 //CLIENTES
 else if (pantalla=="TpvClientes.php")
 {
  if (estado=="GUARDAR") 
  {
   if (campo=="N")
   {
	  alert ("Faltan datos obligatorios del cliente.")
      return false
   }
   else
     return true        
  }
 }//FIN CLIENTES
 
}    
function Cambio(t) {   
 //alert ("A."+pantalla+" B."+estado+" C."+campo);
 //PEDIDOS
	  alert ("Dato Cambiado."+t.value)
}


//Abre el informe
function AbrirInforme(informe,parametros,ip)
{
a = ip.substr(0,9);

if (a == "10.255.0.")
  url = "http://10.255.0.24/result?report=" +informe +".fr3"+parametros;
else
   url = "http://80.24.176.176:5051/result?report=" +informe +".fr3"+parametros;

window.open(url,'comersan','fullscreen=yes,scrollbars=yes,toolbar=yes,menubar=yes');
}