function CambiarImg(Boton) {
  Boton.src = Boton.getAttribute("Out");
}

function RestaurarImg(Boton) {
  Boton.src = Boton.getAttribute("Base");
}

 function load() {  
  alert("load event detected!");
}

function fnbCodigo() {
 var Busqueda;
 Busqueda = document.getElementById("BCodigo").value;
 if (Busqueda != "") {
   location.replace("products-ready-resultado-busqueda-bcod-" + Busqueda + ".html");
 }
 else {
   fnbNombre();  
 }
}

function fnbNombre() {
 var Busqueda;
 Busqueda = document.getElementById("BNombre").value;
 if (Busqueda != "")  {
    location.replace("products-ready-resultado-busqueda-bnom-"+Busqueda+".html");
  }
}

function DelBusquedaSuperior() {
  document.getElementById("BSNombre").value = ""
}

function BusquedaSuperior() {
  var Busqueda;
  Busqueda = document.getElementById("BSNombre").value;
  if (Busqueda != "") {
    location.replace("products-ready-resultado-busqueda-bsup-" + Busqueda + ".html");
  }
  else {
    document.getElementById("BSNombre").value = "Buscar..."
  }
}

function EnterBusquedaSuperior(event) {
  if (window.event && window.event.keyCode == 13)
    BusquedaSuperior();
  else if (event && event.keyCode == 13) {
    BusquedaSuperior();
  }
}

function EnterBusquedaCodigo(event) {
  if (window.event && window.event.keyCode == 13)
    fnbCodigo();
  else if (event && event.keyCode == 13) {
    fnbCodigo();
  }
}

function fLoginsubmit3() {
  var vLogin;
  var vClave;
  vLogin = document.fLogin.txtLogin.value;
}

function EnterLogin(event) {
  if (window.event && window.event.keyCode == 13)
    fLoginsubmit();
  else if (event && event.keyCode == 13) {
    fLoginsubmit();
  }
}

function fLoginsubmit() {
  var vLogin;
  var vClave;
  
  vLogin = document.fLogin.txtLogin.value;
  vClave = document.fLogin.txtClave.value;


  if (vLogin != "") {
      if (vClave != "") {
      document.fLogin.submit();
    }
    else {
      alert("No ha escrito una clave valida");
      document.fLogin.txtClave.focus();
    }
  }
  else {
    alert("No ha escrito un nombre de usuario");
    document.fLogin.txtLogin.focus();
  }
}

function VerFactura(Factura)  {
  window.open("bases/impresionfv.asp?POS="+Factura, "Factura", "toolbar=0,location=0,directories=0,Status=0,menubar=0,scrollbars=1,resizable=1,width=830px,height=300px,top=0,left=0");
}

function VerFacturaPOS(Factura)  {
  window.open("http://repuestos.redorigen.com/rpt/excel.asp?Reporte=POSVentaPortal&POS="+Factura, "Factura", "toolbar=0,location=0,directories=0,Status=0,menubar=0,scrollbars=1,resizable=1,width=830px,height=300px,top=0,left=0");
}

function VerCotizacion(Factura) {
  window.open("bases/impresionctt.asp?POS=" + Factura, "Factura", "toolbar=0,location=0,directories=0,Status=0,menubar=0,scrollbars=1,resizable=1,width=830px,height=300px,top=0,left=0");
}

function AgregarCC(Cod1, RPi) {
  var Cantidad, Comentario
  Cantidad = document.getElementById("CantidadCC").value;
  Comentario = document.getElementById("ComentarioCC").value;
  if (Cantidad != "") {
    window.open("procesos.asp?Contenido=AddCC&RPi=" + RPi + "&Cantidad=" + Cantidad + "&Cod1=" + Cod1 + "&Com= " + Comentario + "&Fin=1", "Procesos");
  }
  else {
    alert("Escriba la cantidad a comprar");
    document.getElementById("CantidadCC").focus();
  }
}


function AgregarCCSugerido(Cod1, RPi, Cantidad) {
  Cantidad = document.getElementById("Cantidad" + Cantidad).value;
  window.open("procesos.asp?Contenido=AddCC&RPi=" + RPi + "&Cantidad=" + Cantidad + "&Cod1=" + Cod1, "Procesos");
}

function ActualizarRC(RC) {
  var Cantidad;
  var Campo;
  Campo = "Cantidad" + RC;
  Cantidad = document.getElementById(Campo).value;
  location.replace("procesos.asp?Contenido=ModificarRC&RC=" + RC + "&Cantidad=" + Cantidad);
}

function EsNumerico() {
  if ((window.event.keyCode < 48 || window.event.keyCode > 57) || (window.event.which < 48 || window.event.which > 57)) {
	  alert("Por favor sólo ingrese números");
	}
}

function CambiarClave() {
  //If Not ValidarFormulario("010203") Then Exit Sub
  if (document.form1.NuevaClave.value != document.form1.NuevaClave2.value) {
    alert("Las claves no corresponden");
    return
    }
  document.form1.submit();
}

function FinalizarCompra() {
  //If Not ValidarFormulario("010203") Then Exit Sub
  location.replace("procesos.asp?Contenido=CerrarCC", "Procesos");
}
