﻿


function AbreNivel(familia) 
{
    var URL = "Productos.aspx?Familia=" + familia + "";
    window.location = URL;
}
function AbreMarcas(IdFamilia,IdTipo) {
    
    var URL = "Productos.aspx?BuscaMarcas=si&Familia=" + IdFamilia + "&Tipo=" + IdTipo + "";
    window.location = URL;
}
function AbreProductos(IdFamilia,IdTipoFamilia,IdMarca) 
{
    var URL = "Productos.aspx?BuscaProd=SI&Familia=" + IdFamilia + "&Tipo=" + IdTipoFamilia + "&Marca=" + IdMarca + "";
    window.location = URL;
}
function ValidaProducto(Valor) {
    var filter = /^([a-zA-Z_0-9_-]|\s|)+$/
    if (Valor == "")
        return false;
    else 
    {
        if (!filter.test(Valor))
            return false;
    }

    return true;

}
function setImage(vObject, vImage) {
    var vImageName
    vObject.style.cursor = 'pointer';
    if (vImage == 1) {
        vImageName = "url(img/boton_menu1.png)";
        vObject.style.backgroundImage = vImageName;
        vObject.children[0].className = "menutextout";
    }
    else {
        vImageName = "url(img/boton_menu2.png)";
        vObject.style.backgroundImage = vImageName;
        vObject.children[0].className = "menutextover";
    }

}
function BuscaProd(TipoProd) 
{
    //1 cartucho
    //2impresora
    var url = "Productos.aspx?Busqueda=si";
    var params='';
    var valor = "";
    if (TipoProd == 1) 
    {
        valor = document.getElementById("txtbuscaprod").value;
        document.getElementById("txtbuscaprod").value = "";
        document.getElementById("txtbuscaimp").value = "";
        params = "&TipoProducto=C&FiltroProductos=" + valor;
    }
    else 
    {
        valor = document.getElementById("txtbuscaimp").value;
        document.getElementById("txtbuscaimp").value = "";
        document.getElementById("txtbuscaprod").value = "";
        params = "&TipoProducto=E&FiltroProductos=" + valor;
    }
    if(ValidaProducto(valor))
    {
        url += params;
        document.getElementById("frmmain").src = url;
    }
    else
    {
        alert('Los valores ingresados en la búsqueda\n son incorrectos, solo letras y números son aceptados');
    }
    
    
    
    
}
function ServicioTecnico() {
    document.getElementById("frmmain").src="ServicioTecnico.aspx";
}
function BorraTexto(obj) 
{
    if (obj.id == "txtbuscaprod")
        document.getElementById("txtbuscaimp").value == "";
    else
        document.getElementById("txtbuscaprod").value == "";
}
function ValidaImpresora(valor) 
{
    var cuantoscaracteres = valor.length;
    var valor2 = "";
    valor2 = valor;
    var ExisteNumero = false;
    for (var i = 0; i <= cuantoscaracteres; i++) 
    {
        var letra = valor2.substring(0, 1);
        valor2=valor2.replace(letra, "");
        if (isNaN(parseInt(letra)))
            ExisteNumero = false;
        else
        {
            ExisteNumero = true;
            break;
        }

    }
    return ExisteNumero;
}
function CambiaImagen(tipo, obj) 
{
if(tipo == 1)
    obj.src = "img/busqueda/BUSQUEDA_LUPA.jpg"
else
    obj.src="img/busqueda/BUSQUEDA_LUPA_SOMBRA.jpg"
}
function AbreSig() 
{
    alert('hola');
}
function AbreServicio() 
{
    document.getElementById("frmmain").src = "ServicioTecnico.aspx";
}
function AbrePop(Image) {
var URL="AbreProd.aspx?NombreImagen="+Image;
window.open(URL, 'Prod', 'status=0,scrollbars =0,location=0 ,width=500px,height=500px');
}
function inicio() 
{
    document.getElementById("frmmain").src = "Principal.aspx";
}
function Historia()
{
    history.back();
}
