try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

function abrirAmena() {
    window.open("amena.html", "Amena", "width=395, height=222, scrollbars=yes");
}

function muestra(DivName) {
    if (document.getElementById(DivName).style.display != "block") {
        document.getElementById(DivName).style.display = "block";
    } else {
        document.getElementById(DivName).style.display = "none";
    }
}

// ************************************
// Funciones para el menú
// ************************************

function muestra(menu) {
    var divName = "submenu" + menu.toLowerCase();
    var btnName = "Btn" + menu;
    if (document.getElementById(divName).style.display != "block") {
        document.getElementById(divName).style.display = "block";
    } else {
        document.getElementById(divName).style.display = "none";
    }
}

function abreSelPresupuesto() {

}

function abrirActualizar() {

}

function abrirDireccion() {
    window.open('pop_direccion.html', 'popup' ,'menubar=no, toolbar=no, width=436 ,height=249');
}

// generic ajax enabler function
function getHTTPRequest(){
    var xmlhttp = false;
    try{
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch( e ){
        try{
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch( E ){
        xmlhttp = false;
    }
    }
    if( !xmlhttp && typeof XMLHttpRequest != 'undefined' ){
    xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp;
}

function promotions(target){
     var xmlURI = '/inves/common/public/promotions.jsp?country=es';
     var xmlhttp = getHTTPRequest();
     xmlhttp.open('GET',xmlURI);
     xmlhttp.onreadystatechange = function(){
         if (xmlhttp.readyState == 4) {
            var nodeList = xmlhttp.responseXML.getElementsByTagName('product');
            var htmlContent = target.innerHTML;
            htmlContent = htmlContent + '<div style="height: 70px"></div>';

            if( nodeList.length > 0 ){
                var texto = '';

                for( var index = 0; index < nodeList.length; index ++ ){

                    texto = ( nodeList[index].text == undefined ? nodeList[index].textContent:nodeList[index].text );

                    htmlContent = htmlContent +
                                '<p><img src="' + nodeList[index].getAttribute('img').replace("https:","http:")
                                + '"' + 'width="91" height="70" alt="' + texto + '" border="0" /></p>';

                    htmlContent = htmlContent + '<p><span class="colDerProdLink">' + texto + '</span></p>';

                }

                target.innerHTML = htmlContent;
            }
          }
    }
    xmlhttp.send(null);
}
