﻿// Documento JavaScript
// Esta función cargará las paginas
function llamarasincrono(url, id_contenedor) {
    var pagina_requerida = false
    if (window.XMLHttpRequest) {// Si es Mozilla, Safari etc
        pagina_requerida = new XMLHttpRequest()
    } else if (window.ActiveXObject) { // pero si es IE
        try {
            pagina_requerida = new ActiveXObject("Msxml2.XMLHTTP")
        }
        catch (e) { // en caso que sea una versión antigua
            try {
                pagina_requerida = new ActiveXObject("Microsoft.XMLHTTP")
            }
            catch (e) { }
        }
    }
    else
        return false
    pagina_requerida.onreadystatechange = function() { // función de respuesta
        cargarpagina(pagina_requerida, id_contenedor)
    }
    pagina_requerida.open('GET', url, true) // asignamos los métodos open y send
    pagina_requerida.send(null)
}
// todo es correcto y ha llegado el momento de poner la información requerida
// en su sitio en la pagina xhtml
function cargarpagina(pagina_requerida, id_contenedor) {
    if (pagina_requerida.readyState == 4 && (pagina_requerida.status == 200 || window.location.href.indexOf("http") == -1)){
        var texto = pagina_requerida.responseText
        texto = texto.substring(texto.indexOf("<div id=\"detalle\">"),texto.indexOf("<div id=\"menu\">"))
        document.getElementById(id_contenedor).innerHTML = texto
    }
}

function cambiarImgProduct(urlnueva) {
    var s = urlnueva.substring(0, urlnueva.lastIndexOf("_"));
    document.getElementById("ctl00_main_imgZapato").src = s + "_400.jpg";   
  }


function setOpacity(testObj, value) {
    testObj.style.opacity = value / 10;
    testObj.style.filter = 'alpha(opacity=' + value * 10 + ')';
}
function show(id) {
    if (document.getElementById(id)) {
        obj = document.getElementById(id);
        if (obj.style.display == "" || obj.style.display == "none") {
            obj.style.display = "block";
        }
    }
}
function hide(id) {
    if (document.getElementById(id)) {
        obj = document.getElementById(id);
        if (obj.style.display == "" || obj.style.display == "block") {
            obj.style.display = "none";
        }
    }
}
function showhide(id) {
    if (document.getElementById(id)) {
        obj = document.getElementById(id);
        if (obj.style.display == "none") {
            obj.style.display = "block";
        } else
            obj.style.display = "none";
    }
}
function show_mini_ventana() {
    //setOpacity('condiv',50);
    show('fade');
    show('light');

    //obi('fname').focus();
}
function detFoto2(img,t,mod,d,piso) {
    //setOpacity('condiv',50);

    
    if (t == 0) {
        $("#col_tec").css("background-image", "none");
    } else if (t == 1) {
        $("#col_tec").css("background-image", "url(img/col_adp.png)");
    } else if (t == 2) {
        $("#col_tec").css("background-image", "url(img/col_adptot.png)");
    } else if (t == 3) {
        $("#col_tec").css("background-image", "url(img/col_adp3d.png)");
    }
    $("#col_detFoto").attr("src", img);
    $("#col_modelo").text(mod);
    $("#col_piso").text(piso);
    $("#col_vis1").attr("src", img.substring(0, img.lastIndexOf(".1")) + ".4_col.jpg");
    $("#col_desc").text(d);
    //obi('fname').focus();
}
function close_mini_ventana() {
    //setOpacity('condiv',50);
    hide('fade');
    hide('light');
}
function ver_detalle(img) {
    imgagen = document.getElementById("detalle");
    imgagen.src = null;
    imgagen.src = img;
    show('fade');
    show('light');
}

function ver_detalle2(img) {
    document.getElementById("light").innerHTML = ""
    show('fade');
    show('light');
    llamarasincrono('shoe_info.aspx?id=' + img, 'light');
}

function imprSelec(nombre)
{
  var ficha = document.getElementById(nombre);
  var ventimp = window.open(' ', 'Imprimir',"width=300,height=300,scrollbars=NO");
  ventimp.document.write( ficha.innerHTML );
  ventimp.document.close();
  var objBrowse = window.navigator;
  if (objBrowse.appName == "Opera" || objBrowse.appName == "Safari") {
      ventimp.onload = function () { ventimp.print(); ventimp.close();};
  } else {
      ventimp.print();
      ventimp.close();
  }
}


