﻿var paginaId = 0;

function registraVideoLog(iEstilismo, _estilismoId, ultimo, video, _subseccionId, idiomaId, zonaId, paisId) {
    AjxRegistraVideoLog('carrouselEstilismos.aspx', _estilismoId, _subseccionId, video);
    document.getElementById('player_' + iEstilismo).style.display = 'block';
    eval("video_" + iEstilismo + ".play();");
}

function registraVideoHome(url,tipo, video) {
    AjxRegistraVideoHomeLog(url, tipo, video);
}

function AjxRegistraUsuarioPagLog(_pagina, _queryString, _paginaCompleta, _menuId, _subseccionId) {
    var http_request  = crearInstanciaAjax();
    var url = 'ajax/registraLog.aspx';
  
    if (!http_request){
        return false;
    }


    var xmlDoc = crearInstanciaDOM();
        
    if (!xmlDoc){
        return false;
    }
        
    var date = new Date()
    var ticks = date.getTime()
        
    http_request.open("GET", url + "?REGISTRAUSUARIOPAGINA=S&PAGINA="+ _pagina +"&QUERYSTRING="+ _queryString +"&PAGINACOMPLETA="+ _paginaCompleta +"&MENUID="+ _menuId + "&SUBSECCIONID="+_subseccionId+ "&" +ticks, true);
    
    http_request.onreadystatechange = function (){
        
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);
        
                if (!xmlDocResp){
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = false;
               
                if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0){
                    var oResultado =xmlDocResp.getElementsByTagName("resultado").item(0);
                    var sTabla = ""
                        
                    if (oResultado.getElementsByTagName("correcto") != null && oResultado.getElementsByTagName("correcto").length > 0){
                        if (oResultado.getElementsByTagName("mensaje") != null && oResultado.getElementsByTagName("mError").length > 0){
                            alert(oResultado.getElementsByTagName("mensaje").item(0).text)
                        }
                        else if (oResultado.getElementsByTagName("paginaLogId") != null && oResultado.getElementsByTagName("paginaLogId").length > 0){
                            try{
                                paginaId = parseInt(oResultado.getElementsByTagName("paginaLogId")[0].firstChild.nodeValue);
                            }
                            catch (e){
                                paginaId = 0;
                            }
                                
                        }
                    }
                 }
                 else {
                    //alert('Ha ocurrido un error al recuperar los datos de la cita.');
                 }
            }
        }
    }
    
    http_request.send(null);
}

function AjxRegistraUsuarioLog(_clienteId){
    var http_request  = crearInstanciaAjax();
    var url = 'ajax/registraLog.aspx';
  
    if (!http_request){
        return false;
    }

    var xmlDoc = crearInstanciaDOM();
        
    if (!xmlDoc){
        return false;
    }
        
    var date = new Date()
    var ticks = date.getTime()

    if (_clienteId != null) {
        http_request.open("GET", url + "?REGISTRAUSUARIO=S&clienteId="+_clienteId +"&" + ticks, true);
    }
    else {
        http_request.open("GET", url + "?REGISTRAUSUARIO=S&" + ticks, true);
    }
    
    http_request.onreadystatechange = function (){
        
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);
        
                if (!xmlDocResp){
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = false;
               
                if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0){
                    var oResultado =xmlDocResp.getElementsByTagName("resultado").item(0);
                    var sTabla = ""
                        
                    if (oResultado.getElementsByTagName("correcto") != null && oResultado.getElementsByTagName("correcto").length > 0 && oResultado.getElementsByTagName("correcto").item(0).text == "N"){
                        if (oResultado.getElementsByTagName("mensaje") != null && oResultado.getElementsByTagName("mensaje").length > 0){
                            alert(oResultado.getElementsByTagName("mensaje").item(0).text)
                        }
                    }
                 }
                 else {
                    //alert('Ha ocurrido un error al recuperar los datos de la cita.');
                 }
            }
        }
    }
    
    http_request.send(null);
}



function AjxActualizaUsuarioLog(_usuarioId,_usuarioLogId){
    var http_request  = crearInstanciaAjax();
    var url = 'ajax/registraLog.aspx';
  
    if (!http_request){
        return false;
    }

    var xmlDoc = crearInstanciaDOM();
        
    if (!xmlDoc){
        return false;
    }
        
    var date = new Date()
    var ticks = date.getTime()
        
    http_request.open("GET", url + "?ACTUALIZAUSUARIO=S&USUARIOID="+ _usuarioId  +"&USUARIOLOGID="+ _usuarioLogId  +"&"+ticks, true);
    
    http_request.onreadystatechange = function (){
        
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);
        
                if (!xmlDocResp){
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = false;
               
                if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0){
                    var oResultado =xmlDocResp.getElementsByTagName("resultado").item(0);
                    var sTabla = ""
                        
                    if (oResultado.getElementsByTagName("correcto") != null && oResultado.getElementsByTagName("correcto").length > 0){
                        if (oResultado.getElementsByTagName("mensaje") != null && oResultado.getElementsByTagName("mError").length > 0){
                            alert(oResultado.getElementsByTagName("mensaje").item(0).text)
                        }
                    }
                 }
                 else {
                    //alert('Ha ocurrido un error al recuperar los datos de la cita.');
                 }
            }
        }
    }
    
    http_request.send(null);
}


function AjxRegistraPaginaLog(_usuarioLogId , _pagina,_queryString,_paginaCompleta,_menuId,_subseccionId)
{
    var http_request  = crearInstanciaAjax();
    var url = 'ajax/registraLog.aspx';
  
    if (!http_request){
        return false;
    }

    var xmlDoc = crearInstanciaDOM();
        
    if (!xmlDoc){
        return false;
    }
        
    var date = new Date()
    var ticks = date.getTime()
        
    http_request.open("GET", url + "?REGISTRAPAGINA=S&USUARIOLOGID=" + _usuarioLogId +"&PAGINA="+ _pagina +"&QUERYSTRING="+ _queryString +"&PAGINACOMPLETA="+ _paginaCompleta +"&MENUID="+ _menuId + "&SUBSECCIONID="+_subseccionId+ "&" +ticks, true);
    
    http_request.onreadystatechange = function (){
        
        if (http_request.readyState  == 4) {
            if (http_request.status == 200) {
                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);
        
                if (!xmlDocResp){
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = false;
               
                if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0){
                    var oResultado =xmlDocResp.getElementsByTagName("resultado").item(0);
                    var sTabla = ""
                        
                    if (oResultado.getElementsByTagName("correcto") != null && oResultado.getElementsByTagName("correcto").length > 0){
                        if (oResultado.getElementsByTagName("mensaje") != null && oResultado.getElementsByTagName("mError").length > 0){
                            alert(oResultado.getElementsByTagName("mensaje").item(0).text)
                        }
                        else if (oResultado.getElementsByTagName("paginaLogId") != null && oResultado.getElementsByTagName("paginaLogId").length > 0){
                            try{
                                paginaId = parseInt(oResultado.getElementsByTagName("paginaLogId")[0].firstChild.nodeValue);
                            }
                            catch (e){
                                paginaId = 0;
                            }
                                
                        }
                    }
                 }
                 else {
                    //alert('Ha ocurrido un error al recuperar los datos de la cita.');
                 }
            }
        }
    }
    
    http_request.send(null);
}


function AjxRegistraEstilismoLog(_paginaCompleta,_estilismoId,_subseccionId)
{
    var http_request  = crearInstanciaAjax();
    var url = 'ajax/registraLog.aspx';
  
    if (!http_request){
        return false;
    }

    var xmlDoc = crearInstanciaDOM();
        
    if (!xmlDoc){
        return false;
    }
        
    var date = new Date()
    var ticks = date.getTime()
        
    http_request.open("GET", url + "?REGISTRAESTILISMO=S&PAGINAID="+ paginaId +"&PAGINACOMPLETA="+ _paginaCompleta +"&ESTILISMOID="+ _estilismoId + "&SUBSECCIONID="+_subseccionId+ "&"+ticks, true);
    
    http_request.onreadystatechange = function (){
        
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);
        
                if (!xmlDocResp){
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = false;
               
                if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0){
                    var oResultado =xmlDocResp.getElementsByTagName("resultado").item(0);
                    var sTabla = ""
                        
                    if (oResultado.getElementsByTagName("correcto") != null && oResultado.getElementsByTagName("correcto").length > 0){
                        if (oResultado.getElementsByTagName("mensaje") != null && oResultado.getElementsByTagName("mError").length > 0){
                            alert(oResultado.getElementsByTagName("mensaje").item(0).text)
                        }
                        else if (oResultado.getElementsByTagName("paginaLogId") != null && oResultado.getElementsByTagName("paginaLogId").length > 0){
                            try{
                                paginaId = parseInt(oResultado.getElementsByTagName("paginaLogId")[0].firstChild.nodeValue);
                            }
                            catch (e){
                                paginaId = 0;
                            }
                                
                        }
                    }
                 }
                 else {
                    //alert('Ha ocurrido un error al recuperar los datos de la cita.');
                 }
            }
        }
    }
    
    http_request.send(null);
}


function AjxRegistraVideoLog(_paginaCompleta, _estilismoId, _subseccionId,_video) {
    var http_request = crearInstanciaAjax();
    var url = 'ajax/registraLog.aspx';

    if (!http_request) {
        return false;
    }

    var xmlDoc = crearInstanciaDOM();

    if (!xmlDoc) {
        return false;
    }

    var date = new Date()
    var ticks = date.getTime()

    http_request.open("GET", url + "?REGISTRAVIDEO=S&PAGINAID=" + paginaId + "&PAGINACOMPLETA=" + _paginaCompleta + "&ESTILISMOID=" + _estilismoId + "&SUBSECCIONID=" + _subseccionId + "&VIDEO=" + _video + "&" + ticks, true);

    http_request.onreadystatechange = function() {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);

                if (!xmlDocResp) {
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = false;

                if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0) {
                    var oResultado = xmlDocResp.getElementsByTagName("resultado").item(0);
                    var sTabla = ""

                    if (oResultado.getElementsByTagName("correcto") != null && oResultado.getElementsByTagName("correcto").length > 0) {
                        if (oResultado.getElementsByTagName("mensaje") != null && oResultado.getElementsByTagName("mError").length > 0) {
                            alert(oResultado.getElementsByTagName("mensaje").item(0).text)
                        }
                        else if (oResultado.getElementsByTagName("paginaLogId") != null && oResultado.getElementsByTagName("paginaLogId").length > 0) {
                            try {
                                paginaId = parseInt(oResultado.getElementsByTagName("paginaLogId")[0].firstChild.nodeValue);
                            }
                            catch (e) {
                                paginaId = 0;
                            }

                        }
                    }
                }
                else {
                    //alert('Ha ocurrido un error al recuperar los datos de la cita.');
                }
            }
        }
    }

    http_request.send(null);
}

function AjxRegistraVideoHomeLog(_paginaCompleta, _tipo, _video) {
    var http_request = crearInstanciaAjax();
    var url = 'ajax/registraLog.aspx';

    if (!http_request) {
        return false;
    }
    if (isNaN(paginaId))
        paginaId = 0;
        
    var xmlDoc = crearInstanciaDOM();

    if (!xmlDoc) {
        return false;
    }

    var date = new Date()
    var ticks = date.getTime();
    http_request.open("GET", url + "?REGISTRAVIDEOHOME=S&PAGINAID=" + paginaId + "&PAGINACOMPLETA=" + _paginaCompleta + "&TIPO=" + _tipo + "&VIDEO=" + _video + "&" + ticks, true);
    http_request.onreadystatechange = function() {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);

                if (!xmlDocResp) {
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = false;

                if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0) {
                    var oResultado = xmlDocResp.getElementsByTagName("resultado").item(0);
                    var sTabla = ""

                    if (oResultado.getElementsByTagName("correcto") != null && oResultado.getElementsByTagName("correcto").length > 0) {
                        if (oResultado.getElementsByTagName("mensaje") != null && oResultado.getElementsByTagName("mError").length > 0) {
                            alert(oResultado.getElementsByTagName("mensaje").item(0).text)
                        }
                        else if (oResultado.getElementsByTagName("paginaLogId") != null && oResultado.getElementsByTagName("paginaLogId").length > 0) {
                            try {
                                paginaId = parseInt(oResultado.getElementsByTagName("paginaLogId")[0].firstChild.nodeValue);
                            }
                            catch (e) {
                                paginaId = 0;
                            }

                        }
                    }
                }
                else {
                    alert('Ha ocurrido un error al recuperar los datos de la cita.');
                }
            }
        }
    }

    http_request.send(null);
}

function AjxRegistraProductoLog(_paginaCompleta,_estilismoId,_productoTempId,_subseccionId)
{
    var http_request  = crearInstanciaAjax();
    var url = 'ajax/registraLog.aspx';
  
    if (!http_request){
        return false;
    }

    var xmlDoc = crearInstanciaDOM();
        
    if (!xmlDoc){
        return false;
    }
        
    var date = new Date()
    var ticks = date.getTime()
        
    http_request.open("GET", url + "?REGISTRAPRODUCTO=S&PAGINAID="+ paginaId +"&PAGINACOMPLETA="+ _paginaCompleta +"&ESTILISMOID="+ _estilismoId + "&PRODUCTOTEMPID="+_productoTempId +"&SUBSECCIONID="+_subseccionId+ "&"+ticks, true);
    
    http_request.onreadystatechange = function (){
        
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);
        
                if (!xmlDocResp){
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = false;
               
                if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0){
                    var oResultado =xmlDocResp.getElementsByTagName("resultado").item(0);
                    var sTabla = ""
                        
                    if (oResultado.getElementsByTagName("correcto") != null && oResultado.getElementsByTagName("correcto").length > 0){
                        if (oResultado.getElementsByTagName("mensaje") != null && oResultado.getElementsByTagName("mError").length > 0){
                            alert(oResultado.getElementsByTagName("mensaje").item(0).text)
                        }
                        else if (oResultado.getElementsByTagName("paginaLogId") != null && oResultado.getElementsByTagName("paginaLogId").length > 0){
                            try{
                                paginaId = parseInt(oResultado.getElementsByTagName("paginaLogId")[0].firstChild.nodeValue);
                            }
                            catch (e){
                                paginaId = 0;
                            }
                                
                        }
                    }
                 }
                 else {
                    //alert('Ha ocurrido un error al recuperar los datos de la cita.');
                 }
            }
        }
    }
    
    http_request.send(null);
}



function AjxComprobarStock(_img,_img2,_referencia,_imgUrl, bt1,bt2, butAnyadir,btCerrar){
    var http_request  = crearInstanciaAjax();
    var url = 'ajax/ComprobarStock.ashx';
  
   if (!http_request){
        return false;
    }

    var xmlDoc = crearInstanciaDOM();
        
    if (!xmlDoc){
        return false;
    }

    var date = new Date()
    var ticks = date.getTime()
        
    http_request.open("GET", url + "?referencia="+ _referencia  +"&"+ticks, true);

    http_request.onreadystatechange = function () {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);

                if (!xmlDocResp) {
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    bt1.disabled = false;
                    bt2.disabled = false;
                    if (document.getElementById(butAnyadir) != null) {
                        document.getElementById(butAnyadir).disabled = false;
                    }
                    return false;
                }
                xmlDocResp.async = false;

                if (xmlDocResp.getElementsByTagName("productosConStock") != null && xmlDocResp.getElementsByTagName("productosConStock").length > 0) {
                    var oResultado = xmlDocResp.getElementsByTagName("productosConStock").item(0);
                    var numeroProductosConStock = oResultado.lastChild.nodeValue;
                    anyadirProductoConStock(numeroProductosConStock);
                }
            }
        }
    }

    http_request.send(null);
    
}


function AjxCargaProductosEstilismo(iEstilismo, _estilismoId, _subseccionId, idiomaId, zonaId, paisId, colorPrecioRebajado) {
    var http_request  = crearInstanciaAjax();
    var url = 'ajax/cargaArticulos.aspx';
  
    if (!http_request){
        alert("No se pudo realizar la llamada al servidor.");
        return false;
    }
        
    var date = new Date()
    var ticks = date.getTime()

    http_request.open("GET", url + "?ESTILISMOID=" + _estilismoId+"&"+ticks, false);

    http_request.send(null);

    var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);
        
    if (!xmlDocResp){
        alert("No se pudo crear el documento xml para procesar la respuesta.");
        return false;
    }
    xmlDocResp.async = false;
        
    if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0){
        var oResultado =xmlDocResp.getElementsByTagName("resultado").item(0);
                               
        aImg = new Array()
                        
        if (oResultado.getElementsByTagName("Productos") != null && oResultado.getElementsByTagName("Productos").length > 0){
            var aImgProductos = oResultado.getElementsByTagName("Productos").item(0).getElementsByTagName("ImgProducto")

            if (aImgProductos != null && aImgProductos.length > 0){
                for (var i = 0;i< aImgProductos.length ;i++){
                    if (document.getElementById('imgEstilismo_' + iEstilismo + '_Articulo_' + (i + 1)) != null) {

                        document.getElementById ("fichas_"+iEstilismo ).innerHTML +="<li id='feature_"+iEstilismo  +"_"+(i+1) +"' class='articlefeatureLi'></li>"
            
                        var texto = "";
//                        if (document.getElementById('imgEstilismo_' + iEstilismo + '_Articulo_' + (i + 1)).className == 'oneelem') {
//                            document.getElementById('imgEstilismo_' + iEstilismo + '_Articulo_' + (i + 1)).className = "";
//                            document.getElementById('imgEstilismo_' + iEstilismo + '_Articulo_' + (i + 1)).display = "inline";
//                            texto += "<img src= 'img/separate.png' height='80px'><br><img src= 'img/separate.gif' width='80px' height='10px' align='left'>";
//                        }
                        texto += "<a class='openfeature' id='ariculo_" + iEstilismo + "_" + (i + 1) + "'>";
                        //texto += '<img class=initimg id="img_article_' + iEstilismo + '_' + (i + 1) + '" src="img/precarga_claros2.gif" onClick="muestraFicha(' + iEstilismo + ',' + (i + 1) + ',' + aImgProductos.item(i).getAttribute("productoID") + ',' + _subseccionId + ',' + idiomaId + ',' + zonaId + ',' + paisId + ',' + _estilismoId + ')" ';
                        if (i < 2) {
                            texto += '<img class="initimg imgarriba" id="img_article_' + iEstilismo + '_' + (i + 1) + '" src="img/precarga_claros2.gif" onClick="muestraFicha(' + iEstilismo + ',' + (i + 1) + ',' + aImgProductos.item(i).getAttribute("productoID") + ',' + _subseccionId + ',' + idiomaId + ',' + zonaId + ',' + paisId + ',' + _estilismoId + ', \'' + colorPrecioRebajado + '\')" ';
                        }
                        else {
                            texto += '<img class="initimg imgabajo" id="img_article_' + iEstilismo + '_' + (i + 1) + '" src="img/precarga_claros2.gif" onClick="muestraFicha(' + iEstilismo + ',' + (i + 1) + ',' + aImgProductos.item(i).getAttribute("productoID") + ',' + _subseccionId + ',' + idiomaId + ',' + zonaId + ',' + paisId + ',' + _estilismoId + ', \'' + colorPrecioRebajado + '\')" ';
                        }
                        texto += '/>';
//                        if (aImgProductos.item(i).getAttribute("marcador") != null){
//                            texto +='<a href="#" id="marcadorPrenda' + iEstilismo +"_"+ (i+1) + '" style="display:block;position:absolute;top:0px;left:0px;" onclick="this.previous(0).click();"><img src="img/' + aImgProductos.item(i).getAttribute("marcador") + '"  width="31px" height="31px" onClick="muestraFicha(' + iEstilismo +','+ (i+1) +','+ aImgProductos.item(i).getAttribute("productoID")+ ','+ _subseccionId+ ','+idiomaId+ ','+zonaId+','+paisId+','+_estilismoId  +')"/></a>';
//                        }
                        texto += "</a>"
                        
                      
                        
                         
                        
                        document.getElementById('imgEstilismo_'+ iEstilismo +'_Articulo_'+ (i+1)).innerHTML =  texto;
                                            
                        document.getElementById('ariculo_'+ iEstilismo +'_'+ (i+1)).style.left = '0px';
                        document.getElementById('ariculo_'+ iEstilismo +'_'+ (i+1)).style.opacity = 1;
                            
                        if (aImgProductos.item(i).lastChild != null && aImgProductos.item(i).lastChild.nodeValue != null){
                            loadImage(document.getElementById('img_article_'+ iEstilismo +'_'+ (i+1)),aImgProductos.item(i).lastChild.nodeValue ,0);
                        }
                        else if (aImgProductos.item(i).lastChild.text != null){
                            loadImage(document.getElementById('img_article_'+ iEstilismo +'_'+ (i+1)),aImgProductos.item(i).text ,0);
                        }
                    }
                }

                
                
            }
            
            //alert(document.getElementById ("fichas_"+iEstilismo ).innerHTML);
        }
    }
    else {
        if (xmlDocResp.getElementsByTagName("raiz") != null && xmlDocResp.getElementsByTagName("raiz").length > 0) {
            var oResultado = xmlDocResp.getElementsByTagName("raiz").item(0);

            if (oResultado.getElementsByTagName("Error") != null && oResultado.getElementsByTagName("Error").length > 0) {
                if (oResultado.getElementsByTagName("Error").item(0).lastChild != null && oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue != null) {
                    MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue, "Default.aspx");
                }
                else if (oResultado.getElementsByTagName("Error").item(0).lastChild.text != null) {
                    MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.text, "Default.aspx");
                }
            }
        }
    }
}
      

function AjxCargaFicha(iEstilismo,iProducto, _productoId,idiomaId,zonaId,paisId){
    
    var http_request  = crearInstanciaAjax();
    var url = 'ajax/cargaArticulos.aspx';
  
    if (!http_request){
        alert("No se pudo realizar la llamada al servidor.");
        return false;
    }
    
    var date = new Date()
    var ticks = date.getTime()
        
    http_request.open("GET", url + "?PRODUCTOID=" + _productoId+"&ESTILISMO=S&"+ticks, false);
    http_request.send(null);

    var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);
        
    if (!xmlDocResp){
        alert("No se pudo crear el documento xml para procesar la respuesta.");
        return false;
    }
    xmlDocResp.async = false;
               
    if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0){
        var oResultado =xmlDocResp.getElementsByTagName("resultado").item(0);
                               
        if (oResultado.getElementsByTagName("fichaProducto") != null && oResultado.getElementsByTagName("fichaProducto").length > 0){
            var oFicha =oResultado.getElementsByTagName("fichaProducto").item(0)
            
            //document.getElementById (iEstilismo  +'_'+ iProducto +'_OtraInformacion').innerHTML = oFicha.getAttribute("OtraInformacion")
            document.getElementById (iEstilismo  +'_'+ iProducto +'_coloresDisponibles').innerHTML = oFicha.getAttribute("coloresDisponibles")
            document.getElementById (iEstilismo  +'_'+ iProducto +'_verTallas').innerHTML = oFicha.getAttribute("verTallas")
            //document.getElementById (iEstilismo  +'_'+ iProducto +'_suEleccion').innerHTML = oFicha.getAttribute("suEleccion")
            //document.getElementById (iEstilismo  +'_'+ iProducto +'_color').innerHTML = oFicha.getAttribute("color")
            //document.getElementById (iEstilismo  +'_'+ iProducto +'_talla').innerHTML = oFicha.getAttribute("talla")
//            document.getElementById('licuid' + iEstilismo + '_' + iProducto).innerHTML = oFicha.getAttribute("cuidados")
//            document.getElementById('licomp' + iEstilismo + '_' + iProducto).innerHTML =  oFicha.getAttribute("composicion")


            var addWishList = ""

            addWishList = oFicha.getAttribute("addWishList")
            
            var nombreEstilismo =""
            if (oFicha.getElementsByTagName("Nombre") != null && oFicha.getElementsByTagName("Nombre").length > 0){
                if (oFicha.getElementsByTagName("Nombre").item(0).lastChild !=null){
                    nombreEstilismo = oFicha.getElementsByTagName("Nombre").item(0).lastChild.nodeValue ;
                }
                else if (oFicha.getElementsByTagName("Nombre").item(0).text != null){
                    nombreEstilismo = oFicha.getElementsByTagName("Nombre").item(0).text ;
                }
                
                document.getElementById (iEstilismo +'_'+iProducto +'_titulo').innerHTML = nombreEstilismo ;
                //document.getElementById(iEstilismo +'_'+iProducto +'_nombreS').innerHTML = nombreEstilismo ;
            }
            
           

            var _agotado = false;
            var msgAgotado = ""
            try {
                if (oFicha.getElementsByTagName("agotado") != null && oFicha.getElementsByTagName("agotado").length > 0) {
                    if (oFicha.getElementsByTagName("agotado").item(0).lastChild != null && oFicha.getElementsByTagName("agotado").item(0).lastChild.nodeValue != null) {
                        if (oFicha.getElementsByTagName("agotado").item(0).lastChild.nodeValue.length > 0) {
                            _agotado = true;
                            msgAgotado = oFicha.getElementsByTagName("agotado").item(0).lastChild.nodeValue;
                        }

                    }
                    else if (oFicha.getElementsByTagName("agotado").item(0).text != null) {
                        if (oFicha.getElementsByTagName("agotado").item(0).text.length > 0) {
                            _agotado = true;
                            msgAgotado = oFicha.getElementsByTagName("agotado").item(0).text;
                        }
                    }

                }
            }
            catch (e) {
            }       
            

            if (oFicha.getElementsByTagName("Descripcion") != null && oFicha.getElementsByTagName("Descripcion").length > 0) {

                //lides' + iEstilismo + '_' + iArticulo + '
//                if (oFicha.getAttribute("TituloDescripcion") != null) {

//                    document.getElementById('lides' + iEstilismo + '_' + iProducto).innerHTML = oFicha.getAttribute("TituloDescripcion");
//            
//                }
                if (oFicha.getElementsByTagName("Descripcion").item(0).lastChild != null && oFicha.getElementsByTagName("Descripcion").item(0).lastChild.nodeValue != null){
                    document.getElementById (iEstilismo +'_'+iProducto +'_descripcion').innerHTML = "<p>" +oFicha.getElementsByTagName("Descripcion").item(0).lastChild.nodeValue +"</p>";
                }
                else if(oFicha.getElementsByTagName("Descripcion").item(0).text != null){
                    document.getElementById(iEstilismo + '_' + iProducto + '_descripcion').innerHTML = "<p>" + oFicha.getElementsByTagName("Descripcion").item(0).text + "</p>";
                }
                else{
                    document.getElementById (iEstilismo +'_'+iProducto +'_descripcion').innerHTML = "";
                }
            }
            
            var sPrecioR = "";
            var sTituloR = "";
            var sPrecioDescuento = "";
            var monedaEst = "";
            var soloExperience = "N";        
            var sPrecioAnt = "";
            var _decimales = "";   
            if (oFicha.getElementsByTagName("Precio") != null && oFicha.getElementsByTagName("Precio").length > 0 && oFicha.getElementsByTagName("Moneda") != null && oFicha.getElementsByTagName("Moneda").length > 0){
                if (oFicha.getElementsByTagName("Moneda").item(0).lastChild != null && oFicha.getElementsByTagName("Moneda").item(0).lastChild.nodeValue != null){
                    monedaEst = oFicha.getElementsByTagName("Moneda").item(0).lastChild.nodeValue 
                }
                else if (oFicha.getElementsByTagName("Moneda").item(0).text != null){
                    monedaEst = oFicha.getElementsByTagName("Moneda").item(0).text 
                }
                
                var sPrecio = ""
                if (oFicha.getElementsByTagName("Precio").item(0).lastChild != null && oFicha.getElementsByTagName("Precio").item(0).lastChild.nodeValue != null){
                    sPrecio = oFicha.getElementsByTagName("Precio").item(0).lastChild.nodeValue
                }
                else if (oFicha.getElementsByTagName("Precio").item(0).text != null){
                    sPrecio = oFicha.getElementsByTagName("Precio").item(0).text
                }
                if (sPrecio == "--") {
                    document.getElementById(iEstilismo + '_' + iProducto + '_precio').innerHTML += sPrecio;
                    document.getElementById(iEstilismo + '_' + iProducto + '_precio').className = 'priceart';

                    document.getElementById(iEstilismo + '_' + iProducto + '_precio2').style.display = 'none';
                }
                else {

                    _decimales = sPrecio.substring(sPrecio.length - 3, sPrecio.length - 2);
                    sPrecio = Math.round(parseFloat(sPrecio.replace(",", ".")));
                    sPrecio += _decimales + '00'

                    sPrecioAnt = sPrecio;
                    
                    document.getElementById(iEstilismo + '_' + iProducto + '_precio').innerHTML += sPrecio + ' ' + monedaEst;
                    document.getElementById(iEstilismo + '_' + iProducto + '_precio').className = 'priceart';

                    document.getElementById(iEstilismo + '_' + iProducto + '_precio2').style.display = 'none';
                }
                
                 
                if (oFicha.getElementsByTagName("PrecioR") != null && oFicha.getElementsByTagName("PrecioR").length > 0){
                    
                    if (oFicha.getElementsByTagName("PrecioR").item(0).lastChild != null && oFicha.getElementsByTagName("PrecioR").item(0).lastChild.nodeValue != null){
                        sPrecioR  = oFicha.getElementsByTagName("PrecioR").item(0).lastChild.nodeValue 
                    }
                    else if (oFicha.getElementsByTagName("PrecioR").item(0).text != null){
                        sPrecioR = oFicha.getElementsByTagName("PrecioR").item(0).text 
                    }
                    
                    if (oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("TituloPrecioR") != null ){
                        sTituloR = oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("TituloPrecioR")
                    }
                     sPrecio = sPrecioR
                    if (oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("soloExperienceR") == null || oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("soloExperienceR") != "S"){               
                        soloExperience="N";
                    }
                    else{
                        soloExperience="S";
                    }
                    
                    
                    //document.getElementById (iEstilismo +'_'+iProducto +'_precioReal').style.textDecoration = 'line-through';
//                    if (oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("TipoPrecioR") != null && oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("TipoPrecioR") == "RR"){
//                        document.getElementById (iEstilismo +'_'+iProducto +'_descripcion').innerHTML +='<span class=link_precio_web style="font-size: 10px;">'+ sTituloR  +'</span> <span class=link_video_promocion id ="'+iEstilismo +'_'+iProducto +'_precioRebajas">' + sPrecioR   + ' ' + monedaEst  + '</span>';
//                    }
//                    else{
//                        document.getElementById (iEstilismo +'_'+iProducto +'_descripcion').innerHTML +='<span class=link_precio_web>'+ sTituloR  +'</span> <span class=link_video_promocion id ="'+iEstilismo +'_'+iProducto +'_precioRebajas">' + sPrecioR   + ' ' + monedaEst  + '</span>';
                    //                    }

                    _decimales = sPrecioR.substring(sPrecioR.length - 3, sPrecioR.length - 2);
                    sPrecioR = Math.round(parseFloat(sPrecioR.replace(",", ".")));
                    sPrecioR += _decimales + '00' 
                    
                    document.getElementById(iEstilismo + '_' + iProducto + '_precio').className = 'pricearttachado';
                    document.getElementById(iEstilismo + '_' + iProducto + '_precio2').innerHTML += sPrecioR + ' ' + monedaEst;
                    document.getElementById(iEstilismo + '_' + iProducto + '_precio2').style.display = 'block';

                }
                
                var sTituloD = ""; 
                if (oFicha.getElementsByTagName("PrecioD") != null && oFicha.getElementsByTagName("PrecioD").length > 0){
                    
                    if (oFicha.getElementsByTagName("PrecioD").item(0).lastChild != null && oFicha.getElementsByTagName("PrecioD").item(0).lastChild.nodeValue != null){
                        sPrecioDescuento = oFicha.getElementsByTagName("PrecioD").item(0).lastChild.nodeValue 
                    }
                    else if (oFicha.getElementsByTagName("PrecioD").item(0).text != null){
                        sPrecioDescuento = oFicha.getElementsByTagName("PrecioD").item(0).text 
                    }
                    
                     if (oFicha.getElementsByTagName("PrecioD").item(0).getAttribute("TituloPrecioD") != null ){
                        sTituloD = oFicha.getElementsByTagName("PrecioD").item(0).getAttribute("TituloPrecioD")
                    }
                    
//                    if (sPrecioR != "") {
//                        document.getElementById (iEstilismo +'_'+iProducto +'_precioRebajas').style.textDecoration = 'line-through';
//                        document.getElementById (iEstilismo +'_'+iProducto +'_precioReal').style.background='transparent url(img/footer_promocion2.png) repeat';
//                        document.getElementById (iEstilismo +'_'+iProducto +'_precioRebajas').style.background='transparent url(img/footer.png) repeat';
//                         document.getElementById (iEstilismo +'_'+iProducto +'_descripcion').innerHTML +='<span class=link_precio_web2>'+ sTituloD +'</span> <span class=link_video_promocion2>' + sPrecioDescuento   + ' ' + monedaEst  + '</span>';
//                       }
//                    else{
//                        document.getElementById (iEstilismo +'_'+iProducto +'_precioReal').style.textDecoration = 'line-through';
//                        document.getElementById (iEstilismo +'_'+iProducto +'_descripcion').innerHTML +='<span class=link_precio_web>'+ sTituloD +'</span> <span class=link_video_promocion>' + sPrecioDescuento   + ' ' + monedaEst  + '</span>';
                    //                    }


                    _decimales = sPrecioDescuento.substring(sPrecioDescuento.length - 3, sPrecioDescuento.length - 2);
                    sPrecioDescuento = Math.round(parseFloat(sPrecioDescuento.replace(",", ".")));
                    sPrecioDescuento += _decimales + '00' 
                    
                    document.getElementById(iEstilismo + '_' + iProducto + '_precio').className = 'pricearttachado';
                    document.getElementById(iEstilismo + '_' + iProducto + '_precio2').innerHTML += sPrecioDescuento + ' ' + monedaEst;
                    document.getElementById(iEstilismo + '_' + iProducto + '_precio2').style.display = 'block';
                       
                }
                else{
                    sPrecioDescuento = sPrecio 
                }
            }
            
            if (oFicha.getElementsByTagName("colores") != null && oFicha.getElementsByTagName("colores").length > 0){
                var oColores = oFicha.getElementsByTagName("colores").item(0);
                       
                if (oColores.getElementsByTagName("color") != null && oColores.getElementsByTagName("color").length > 0){     
                    for (var i =0;i< oColores.getElementsByTagName("color").length;i++){
                        var oColor = oColores.getElementsByTagName("color").item(i);
                                    
                        var _descColor = "";
                        var _colorVarianteId ="";
                        var _rgb_ruta ="";
                        var _imagenDetalleV ="";
                        var _identificadorPantoneid="";
                                    
                        if (oColor.getElementsByTagName("descripcionColor").item(0).lastChild != null && oColor.getElementsByTagName("descripcionColor").item(0).lastChild.nodeValue != null){
                            _descColor = oColor.getElementsByTagName("descripcionColor").item(0).lastChild.nodeValue;
                        }
                        else if (oColor.getElementsByTagName("descripcionColor").item(0).text != null){
                            _descColor = oColor.getElementsByTagName("descripcionColor").item(0).text;
                        }
                                    
                        if (oColor.getElementsByTagName("colorVarianteId").item(0).lastChild != null && oColor.getElementsByTagName("colorVarianteId").item(0).lastChild.nodeValue != null){
                            _colorVarianteId = oColor.getElementsByTagName("colorVarianteId").item(0).lastChild.nodeValue;
                        }
                        else if (oColor.getElementsByTagName("colorVarianteId").item(0).text != null){
                            _colorVarianteId = oColor.getElementsByTagName("colorVarianteId").item(0).text;
                        }
                        
                        if (oColor.getElementsByTagName("rgb_ruta").item(0).lastChild != null && oColor.getElementsByTagName("rgb_ruta").item(0).lastChild.nodeValue != null){
                            _rgb_ruta = oColor.getElementsByTagName("rgb_ruta").item(0).lastChild.nodeValue;
                        }
                        else if (oColor.getElementsByTagName("rgb_ruta").item(0).text != null){
                            _rgb_ruta = oColor.getElementsByTagName("rgb_ruta").item(0).text;
                        }
                             
                        if (oColor.getElementsByTagName("imagenDetalleV").item(0).lastChild != null && oColor.getElementsByTagName("imagenDetalleV").item(0).lastChild.nodeValue != null){
                            _imagenDetalleV = oColor.getElementsByTagName("imagenDetalleV").item(0).lastChild.nodeValue;
                        }
                        else if (oColor.getElementsByTagName("imagenDetalleV").item(0).text != null){
                            _imagenDetalleV = oColor.getElementsByTagName("imagenDetalleV").item(0).text;
                        }     
                             
                        if (oColor.getElementsByTagName("identificadorPantoneid").item(0).lastChild != null && oColor.getElementsByTagName("identificadorPantoneid").item(0).lastChild.nodeValue != null){
                            _identificadorPantoneid = oColor.getElementsByTagName("identificadorPantoneid").item(0).lastChild.nodeValue;
                        }
                        else if (oColor.getElementsByTagName("identificadorPantoneid").item(0).text != null){
                            _identificadorPantoneid = oColor.getElementsByTagName("identificadorPantoneid").item(0).text;
                        }
                                    
                        if ((oColor.getElementsByTagName("tipo").item(0).lastChild != null && oColor.getElementsByTagName("tipo").item(0).lastChild.nodeValue != null &&  oColor.getElementsByTagName("tipo").item(0).lastChild.nodeValue == "C") || (oColor.getElementsByTagName("tipo").item(0).text != null &&  oColor.getElementsByTagName("tipo").item(0).text == "C")){
                            document.getElementById('pColores_' + iEstilismo + '_' + iProducto).innerHTML += '<span id=capaColor_' + iEstilismo + '_' + iProducto + '_' + _colorVarianteId + ' style=background:#' + _rgb_ruta + ';cursor:pointer;" onmouseout="restaurarImagenColor(\'_' + iEstilismo + '_' + iProducto + '\');" onmouseover="mostrarColor(\'' + _imagenDetalleV + '\',\'_' + iEstilismo + '_' + iProducto + '\',\'_' + iEstilismo + '_' + iProducto + '\');" onclick="seleccionaColor(\'capaColor_' + iEstilismo + '_' + iProducto + '_' + _colorVarianteId + '\',\'' + _imagenDetalleV + '\',\'_' + iEstilismo + '_' + iProducto + '\',\'_' + iEstilismo + '_' + iProducto + '\',\'' + _colorVarianteId + '\',\'' + _identificadorPantoneid + '\',\'' + _descColor + '\');"><img src=img/transparent.gif width=23 height=23 alt="' + _descColor + '" title="' + _descColor + '"/></span>';
                        }
                        else{
                            document.getElementById('pColores_' + iEstilismo + '_' + iProducto).innerHTML += '<span id="capaColor_' + iEstilismo + '_' + iProducto + '_' + _colorVarianteId + '" style="cursor:pointer;" onmouseout="restaurarImagenColor(\'_' + iEstilismo + '_' + iProducto + '\');" onmouseover="mostrarColor(\'' + _imagenDetalleV + '\',\'_' + iEstilismo + '_' + iProducto + '\',\'_' + iEstilismo + '_' + iProducto + '\');" onclick="seleccionaColor(\'capaColor_' + iEstilismo + '_' + iProducto + '_' + _colorVarianteId + '\',\'' + _imagenDetalleV + '\',\'_' + iEstilismo + '_' + iProducto + '\',\'_' + iEstilismo + '_' + iProducto + '\',\'' + _colorVarianteId + '\',\'' + _identificadorPantoneid + '\',\'' + _descColor + '\');"><img src="' + _rgb_ruta + '" width="23" height="23" alt="' + _descColor + '" title="' + _descColor + '"/></span>';
                        }
                        if ((oColor.getElementsByTagName("esPrincipal").item(0).lastChild != null && oColor.getElementsByTagName("esPrincipal").item(0).lastChild.nodeValue != null && oColor.getElementsByTagName("esPrincipal").item(0).lastChild.nodeValue == "true") || (oColor.getElementsByTagName("tipo").item(0).text != null && oColor.getElementsByTagName("tipo").item(0).text == "true")) {
                            document.getElementById('capaColor_' + iEstilismo + '_' + iProducto + '_' + _colorVarianteId).click();
                        }
                    }
                }
            }

            var stalla = "<select id=selectTalla_" + iEstilismo + "_" + iProducto + " style=width:80px "

            if (!_agotado) {
                stalla += "onChange=seleccionaTalla(this,'_" + iEstilismo + "_" + iProducto + "')";
                }
            else {
                stalla += " disabled=true "
            }

            stalla += ">"
 
            if (oFicha.getElementsByTagName("tallas") != null && oFicha.getElementsByTagName("tallas").length > 0){
                var otallas = oFicha.getElementsByTagName("tallas").item(0);
            
               // stalla += "<option value=0>"+ otallas.getAttribute("etiqueta") +"</option>";           
                if (otallas.getElementsByTagName("talla") != null && otallas.getElementsByTagName("talla").length > 0) {
                    if (otallas.getElementsByTagName("talla").length > 1) {
                        stalla += "<option value=0>" + otallas.getAttribute("etiqueta") + "</option>";
                    }
                    for (var i =0;i< otallas.getElementsByTagName("talla").length;i++){
                        var otalla = otallas.getElementsByTagName("talla").item(i);
                        
                        var _tallaD = "";
                        var _tallaId ="";
                        
                        if (otalla.getElementsByTagName("valuetalla").item(0).lastChild != null && otalla.getElementsByTagName("valuetalla").item(0).lastChild.nodeValue != null){
                            _tallaId = otalla.getElementsByTagName("valuetalla").item(0).lastChild.nodeValue;
                        }
                        else if(otalla.getElementsByTagName("valuetalla").item(0).text){
                            _tallaId =otalla.getElementsByTagName("valuetalla").item(0).text;
                        }
                        
                        if (otalla.getElementsByTagName("texttalla").item(0).lastChild != null && otalla.getElementsByTagName("texttalla").item(0).lastChild.nodeValue != null){
                            _tallaD = otalla.getElementsByTagName("texttalla").item(0).lastChild.nodeValue;
                        }
                        else if(otalla.getElementsByTagName("texttalla").item(0).text){
                            _tallaD =otalla.getElementsByTagName("texttalla").item(0).text;
                        }
                        
                        stalla+="<option value="+_tallaId  + ">" + _tallaD +"</option>";
                    }
                }
            }
            else{
                 stalla += "<option value=0> Tallas </option>";         
            }
                 
            stalla+="</select>"
            document.getElementById( iEstilismo +'_'+iProducto +'_tdTalla').innerHTML = stalla
            
            if (oFicha.getElementsByTagName("colorPid") != null && oFicha.getElementsByTagName("colorPid").length > 0){
                var _colorPid ="";
                var _colorPdesc ="";
                
                if (oFicha.getElementsByTagName("colorPid").item(0).lastChild != null && oFicha.getElementsByTagName("colorPid").item(0).lastChild.nodeValue != null){
                    _colorPid = oFicha.getElementsByTagName("colorPid").item(0).lastChild.nodeValue;
                }
                else if(oFicha.getElementsByTagName("colorPid").item(0).text){
                    _colorPid =oFicha.getElementsByTagName("colorPid").item(0).text;
                }
                
//                if (oFicha.getElementsByTagName("colorPdesc").item(0).lastChild != null && oFicha.getElementsByTagName("colorPdesc").item(0).lastChild.nodeValue != null){
//                    _colorPdesc = oFicha.getElementsByTagName("colorPdesc").item(0).lastChild.nodeValue;
//                }
//                else if(oFicha.getElementsByTagName("colorPdesc").item(0).text){
//                    _colorPdesc =oFicha.getElementsByTagName("colorPdesc").item(0).text;
//                }
                
                //document.getElementById('sColorSelec_'+ iEstilismo +'_'+iProducto).innerHTML = _colorPdesc
                document.getElementById('hVarianteId_'+ iEstilismo +'_'+iProducto).value= _colorPid
            }

            var _periodotarifaid = 0

            if (oFicha.getElementsByTagName("periodotarifaid") != null && oFicha.getElementsByTagName("periodotarifaid").length > 0){
               
                if (oFicha.getElementsByTagName("periodotarifaid").item(0).lastChild != null && oFicha.getElementsByTagName("periodotarifaid").item(0).lastChild.nodeValue != null){
                    _periodotarifaid = oFicha.getElementsByTagName("periodotarifaid").item(0).lastChild.nodeValue;
                }
                else if(oFicha.getElementsByTagName("colorPid").item(0).text){
                    _periodotarifaid =oFicha.getElementsByTagName("periodotarifaid").item(0).text;
                }
           
            }

            
            var _bAnyadir = "<input type=button id='anyadirCompra_" + iEstilismo + "_" + iProducto + "' class=compra_but "

            if (!_agotado) {
                document.getElementById(iEstilismo + '_' + iProducto + '_anadir').innerHTML += _bAnyadir + "onclick=\"fAnyadirCompra('_" + iEstilismo + "_" + iProducto + "','" + _productoId + "','" + sPrecioDescuento + "','" + monedaEst + "','anyadirCompra_" + iEstilismo + "_" + iProducto + "','" + soloExperience + "','" + sPrecioAnt + "'," + _periodotarifaid + ")\" />";
                document.getElementById(iEstilismo + '_' + iProducto + '_wishlist').innerHTML = "<a style='cursor:pointer;' onclick=\"anyadirWishlist('_" + iEstilismo + "_" + iProducto + "','" + _productoId + "','" + sPrecioDescuento + "','" + monedaEst + "','anyadirCompra_" + iEstilismo + "_" + iProducto + "','" + soloExperience + "','" + sPrecioAnt + "')\">&nbsp;&nbsp;" + addWishList + "</a>";
          
            }
            else {
                document.getElementById(iEstilismo + '_' + iProducto + '_anadir').innerHTML += _bAnyadir + " onclick=\" radalert('" + msgAgotado +"', 300, 200, '');\" />";

            }

            if (oFicha.getElementsByTagName("Composicion") != null && oFicha.getElementsByTagName("Composicion").length > 0) {
                if (oFicha.getElementsByTagName("Composicion").item(0).lastChild != null && oFicha.getElementsByTagName("Composicion").item(0).lastChild.nodeValue != null) {
                    //document.getElementById(iEstilismo + '_' + iProducto + '_composicion').innerHTML += oFicha.getElementsByTagName("Composicion").item(0).lastChild.nodeValue;
                    document.getElementById(iEstilismo + '_' + iProducto + '_descripcion').innerHTML += "<p>" + oFicha.getElementsByTagName("Composicion").item(0).lastChild.nodeValue + "</p>";
                }
                else if (oFicha.getElementsByTagName("Composicion").item(0).text != null) {
                    // document.getElementById(iEstilismo + '_' + iProducto + '_composicion').innerHTML += oFicha.getElementsByTagName("Composicion").item(0).text;
                    document.getElementById(iEstilismo + '_' + iProducto + '_descripcion').innerHTML += "<p>" + oFicha.getElementsByTagName("Composicion").item(0).text + "</p>"; 
                }
                else {
                  //  document.getElementById(iEstilismo + '_' + iProducto + '_composicion').innerHTML += ""
                }
            }

            try{    
                if (oFicha.getElementsByTagName("Cuidados") != null && oFicha.getElementsByTagName("Cuidados").length > 0){
                    if (oFicha.getElementsByTagName("Cuidados").item(0).lastChild != null && oFicha.getElementsByTagName("Cuidados").item(0).lastChild.nodeValue != null){
                        // document.getElementById(iEstilismo +'_'+iProducto +'_cuidados').innerHTML += oFicha.getElementsByTagName("Cuidados").item(0).lastChild.nodeValue  ;
                        document.getElementById(iEstilismo + '_' + iProducto + '_descripcion').innerHTML += "<p>" + oFicha.getElementsByTagName("Cuidados").item(0).lastChild.nodeValue + "</p>";
                    }
                    else if (oFicha.getElementsByTagName("Cuidados").item(0).text != null){
                        //document.getElementById(iEstilismo +'_'+iProducto +'_cuidados').innerHTML += oFicha.getElementsByTagName("Cuidados").item(0).text  ;
                        document.getElementById(iEstilismo + '_' + iProducto + '_descripcion').innerHTML += "<p>" + oFicha.getElementsByTagName("Cuidados").item(0).text + "</p>";
                    }
                    else{
                        //document.getElementById(iEstilismo +'_'+iProducto +'_cuidados').innerHTML += ""
                    }
                }
            }
            catch (e){
            }

            if (oFicha.getElementsByTagName("Referencia") != null && oFicha.getElementsByTagName("Referencia").length > 0) {
                if (oFicha.getElementsByTagName("Referencia").item(0).lastChild != null && oFicha.getElementsByTagName("Referencia").item(0).lastChild.nodeValue != null) {
                    document.getElementById(iEstilismo + '_' + iProducto + '_descripcion').innerHTML += "<p>" + "Ref: " + oFicha.getElementsByTagName("Referencia").item(0).lastChild.nodeValue + "</p>";
                }
                else if (oFicha.getElementsByTagName("Referencia").item(0).text != null) {
                    document.getElementById(iEstilismo + '_' + iProducto + '_descripcion').innerHTML += "<p>" + "Ref: " + oFicha.getElementsByTagName("Referencia").item(0).text + "</p>";
                }
                else {
                    document.getElementById(iEstilismo + '_' + iProducto + '_descripcion').innerHTML += "<p>" + "Ref: </p>";
                }
            }

            document.getElementById(iEstilismo + '_' + iProducto + '_descripcionPop').innerHTML = document.getElementById(iEstilismo + '_' + iProducto + '_descripcion').innerHTML

            if (oFicha.getElementsByTagName("colorPImg") != null && oFicha.getElementsByTagName("colorPImg").length > 0){
                if (oFicha.getElementsByTagName("colorPImg").item(0).lastChild != null && oFicha.getElementsByTagName("colorPImg").item(0).lastChild.nodeValue != null){
                    loadImage(document.getElementById('imgVar_'+ iEstilismo +'_'+iProducto),oFicha.getElementsByTagName("colorPImg").item(0).lastChild.nodeValue,0);
                }
                else if (oFicha.getElementsByTagName("colorPImg").item(0).text != null){
                    loadImage(document.getElementById('imgVar_'+ iEstilismo +'_'+iProducto),oFicha.getElementsByTagName("colorPImg").item(0).text,0);
                }
            }
            document.getElementById(iEstilismo + '_' + iProducto + '_recomendar').innerHTML = '<a style="cursor:pointer;" href="JavaScript:recomendarProducto(\'' + nombreEstilismo + '\',' + _productoId + ',' + zonaId + ',' + idiomaId + ',' + paisId + ',\'' + sPrecioDescuento   /*+ ' ' + monedaEst*/ + '\');">&nbsp;&nbsp;' + oFicha.getAttribute("RecomendarAmigo") + '</a>';
          
        }
    }
    else {
        if (xmlDocResp.getElementsByTagName("raiz") != null && xmlDocResp.getElementsByTagName("raiz").length > 0) {
            var oResultado = xmlDocResp.getElementsByTagName("raiz").item(0);

            if (oResultado.getElementsByTagName("Error") != null && oResultado.getElementsByTagName("Error").length > 0) {
                if (oResultado.getElementsByTagName("Error").item(0).lastChild != null && oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue != null) {
                    MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue, "Default.aspx");
                }
                else if (oResultado.getElementsByTagName("Error").item(0).lastChild.text != null) {
                    MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.text, "Default.aspx");
                }
            }
        }
    }        
}


function AjxCargaFichaProducto(iProducto, _productoId,_subseccionId,idiomaId,zonaId,paisId){
    var http_request  = crearInstanciaAjax();
    var url = 'ajax/fichaProducto.ashx';
    if (!http_request){
        alert("No se pudo realizar la llamada al servidor.");
        return false;
    }
    
    var date = new Date()
    var ticks = date.getTime()

    http_request.open("GET", url + "?PRODUCTOID=" + _productoId + "&" + ticks, false);
    http_request.send(null);    
//    http_request.onreadystatechange = function () {

//        if (http_request.readyState == 4) {
//            if (http_request.status == 200) {


                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);

                if (!xmlDocResp) {
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = true;
                try {
                    if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0) {
                        var oResultado = xmlDocResp.getElementsByTagName("resultado").item(0);

                        if (oResultado.getElementsByTagName("fichaProducto") != null && oResultado.getElementsByTagName("fichaProducto").length > 0) {
                            var oFicha = oResultado.getElementsByTagName("fichaProducto").item(0)

                            document.getElementById(iProducto + '_coloresDisponibles').innerHTML = oFicha.getAttribute("coloresDisponibles")
                            document.getElementById(iProducto + '_verTallas').innerHTML = oFicha.getAttribute("verTallas")

                            var addWishList = ""

                            addWishList = oFicha.getAttribute("addWishList")
                            var nombreEstilismo = ""
                            if (oFicha.getElementsByTagName("Nombre") != null && oFicha.getElementsByTagName("Nombre").length > 0) {
                                if (oFicha.getElementsByTagName("Nombre").item(0).lastChild != null) {
                                    nombreEstilismo = oFicha.getElementsByTagName("Nombre").item(0).lastChild.nodeValue;
                                }
                                else if (oFicha.getElementsByTagName("Nombre").item(0).text != null) {
                                    nombreEstilismo = oFicha.getElementsByTagName("Nombre").item(0).text;
                                }

                                document.getElementById(iProducto + '_titulo').innerHTML = nombreEstilismo;
                            }

                            var _agotado = false;
                            var msgAgotado = ""

                            try {
                                if (oFicha.getElementsByTagName("agotado") != null && oFicha.getElementsByTagName("agotado").length > 0) {
                                    if (oFicha.getElementsByTagName("agotado").item(0).lastChild != null && oFicha.getElementsByTagName("agotado").item(0).lastChild.nodeValue != null) {
                                        if (oFicha.getElementsByTagName("agotado").item(0).lastChild.nodeValue.length > 0) {
                                            _agotado = true;
                                            msgAgotado = oFicha.getElementsByTagName("agotado").item(0).lastChild.nodeValue;
                                        }

                                    }
                                    else if (oFicha.getElementsByTagName("agotado").item(0).text != null) {
                                        if (oFicha.getElementsByTagName("agotado").item(0).text.length > 0) {
                                            _agotado = true;
                                            msgAgotado = oFicha.getElementsByTagName("agotado").item(0).text;
                                        }
                                    }

                                }
                            }
                            catch (e) {
                            }

                            if (oFicha.getElementsByTagName("Descripcion") != null && oFicha.getElementsByTagName("Descripcion").length > 0) {
                                if (oFicha.getElementsByTagName("Descripcion").item(0).lastChild != null && oFicha.getElementsByTagName("Descripcion").item(0).lastChild.nodeValue != null) {
                                    document.getElementById(iProducto + '_descripcion').innerHTML = "<p>" + oFicha.getElementsByTagName("Descripcion").item(0).lastChild.nodeValue + "</p>";
                                }
                                else if (oFicha.getElementsByTagName("Descripcion").item(0).text != null) {
                                    document.getElementById(iProducto + '_descripcion').innerHTML = "<p>" + oFicha.getElementsByTagName("Descripcion").item(0).text + "</p>";
                                }
                                else {
                                    document.getElementById(iProducto + '_descripcion').innerHTML = "";
                                }
                            }

                            var _bAnyadir = "<input type=button id='anyadirCompra_" + iProducto + "' class=compra_but  "

                            if (!_agotado) {
                                document.getElementById(iProducto + '_anadir').innerHTML += _bAnyadir + " onclick=\"fAnyadirCompra('_" + iProducto + "','" + _productoId + "',document.getElementById('sPrecioDescuento_" + iProducto + "').value,document.getElementById('monedaEst_" + iProducto + "').value,'anyadirCompra_" + iProducto + "',document.getElementById('soloExperience_" + iProducto + "').value,document.getElementById('sPrecioAnt_" + iProducto + "').value,document.getElementById('_periodotarifaid_" + iProducto + "').value)\" />";
                                document.getElementById(iProducto + '_wishlist').innerHTML = "<a style='cursor:pointer;' onclick=\"anyadirWishlist('_" + iProducto + "','" + _productoId + "',document.getElementById('sPrecioDescuento_" + iProducto + "').value,document.getElementById('monedaEst_" + iProducto + "').value,'anyadirCompra_" + iProducto + "',document.getElementById('soloExperience_" + iProducto + "').value,document.getElementById('sPrecioAnt_" + iProducto + "').value)\">&nbsp;&nbsp;" + addWishList + "</a>";
                            }
                            else {
                                document.getElementById(iProducto + '_anadir').innerHTML += _bAnyadir + " onclick=\" radalert('" + msgAgotado + "',300, 200, '');\" />";

                            }

                            if (oFicha.getElementsByTagName("Composicion") != null && oFicha.getElementsByTagName("Composicion").length > 0) {
                                if (oFicha.getElementsByTagName("Composicion").item(0).lastChild != null && oFicha.getElementsByTagName("Composicion").item(0).lastChild.nodeValue != null) {
                                    document.getElementById(iProducto + '_descripcion').innerHTML += "<p>" + oFicha.getElementsByTagName("Composicion").item(0).lastChild.nodeValue + "</p>";
                                }
                                else if (oFicha.getElementsByTagName("Composicion").item(0).text != null) {
                                    document.getElementById(iProducto + '_descripcion').innerHTML += "<p>" + oFicha.getElementsByTagName("Composicion").item(0).text + "</p>";
                                }
                                else {
                                }
                            }

                            try {
                                if (oFicha.getElementsByTagName("Cuidados") != null && oFicha.getElementsByTagName("Cuidados").length > 0) {
                                    if (oFicha.getElementsByTagName("Cuidados").item(0).lastChild != null && oFicha.getElementsByTagName("Cuidados").item(0).lastChild.nodeValue != null) {
                                        document.getElementById(iProducto + '_descripcion').innerHTML += "<p>" + oFicha.getElementsByTagName("Cuidados").item(0).lastChild.nodeValue + "</p>";
                                    }
                                    else if (oFicha.getElementsByTagName("Cuidados").item(0).text != null) {
                                        document.getElementById(iProducto + '_descripcion').innerHTML += "<p>" + oFicha.getElementsByTagName("Cuidados").item(0).text + "</p>";
                                    }
                                    else {
                                    }
                                }
                            }
                            catch (e) {
                            }

                            if (oFicha.getElementsByTagName("Referencia") != null && oFicha.getElementsByTagName("Referencia").length > 0) {
                                if (oFicha.getElementsByTagName("Referencia").item(0).lastChild != null && oFicha.getElementsByTagName("Referencia").item(0).lastChild.nodeValue != null) {
                                    document.getElementById(iProducto + '_descripcion').innerHTML += "<p>" + "Ref: " + oFicha.getElementsByTagName("Referencia").item(0).lastChild.nodeValue + "</p>";
                                }
                                else if (oFicha.getElementsByTagName("Referencia").item(0).text != null) {
                                    document.getElementById(iProducto + '_descripcion').innerHTML += "<p>" + "Ref: " + oFicha.getElementsByTagName("Referencia").item(0).text + "</p>";
                                }
                                else {
                                    document.getElementById(iProducto + '_descripcion').innerHTML += "<p>" + "Ref: " + "</p>";
                                }
                            }


                            document.getElementById(iProducto + '_descripcionPop').innerHTML = document.getElementById(iProducto + '_descripcion').innerHTML

                            document.getElementById(iProducto + '_recomendar').innerHTML = '<a style="cursor:pointer;" href="JavaScript:recomendarProducto(\'' + nombreEstilismo + '\',' + _productoId + ',' + zonaId + ',' + idiomaId + ',' + paisId + ',document.getElementById(\'sPrecioDescuento_' + iProducto + '\').value);">&nbsp;&nbsp;' + oFicha.getAttribute("RecomendarAmigo") + '</a>';
                        }
                    }
                    else {
                        if (xmlDocResp.getElementsByTagName("raiz") != null && xmlDocResp.getElementsByTagName("raiz").length > 0) {
                            var oResultado = xmlDocResp.getElementsByTagName("raiz").item(0);

                            if (oResultado.getElementsByTagName("Error") != null && oResultado.getElementsByTagName("Error").length > 0) {
                                if (oResultado.getElementsByTagName("Error").item(0).lastChild != null && oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue != null) {
                                    MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue, "Default.aspx");
                                }
                                else if (oResultado.getElementsByTagName("Error").item(0).lastChild.text != null) {
                                    MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.text, "Default.aspx");
                                }
                            }
                        }
                    }
                }
                catch (e) {
                }
//            }
//        }
//    }
  
}

function AjxCargaTallas(iProducto, _productoId, _subseccionId, idiomaId, zonaId, paisId) {

    var http_request = crearInstanciaAjax();
    var url = 'ajax/cargaArticulos.aspx';
    if (!http_request) {
        alert("No se pudo realizar la llamada al servidor.");
        return false;
    }

    var date = new Date()
    var ticks = date.getTime()

    http_request.open("GET", url + "?PRODUCTOID=" + _productoId + "&TALLA=S&" + ticks, true);

    http_request.onreadystatechange = function () {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);

                if (!xmlDocResp) {
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = true;

                if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0) {
                    var oResultado = xmlDocResp.getElementsByTagName("resultado").item(0);

                    if (oResultado.getElementsByTagName("fichaProducto") != null && oResultado.getElementsByTagName("fichaProducto").length > 0) {
                        var oFicha = oResultado.getElementsByTagName("fichaProducto").item(0)


                        var _agotado = false;
                        var msgAgotado = ""
                        try {
                            if (oFicha.getElementsByTagName("agotado") != null && oFicha.getElementsByTagName("agotado").length > 0) {
                                if (oFicha.getElementsByTagName("agotado").item(0).lastChild != null && oFicha.getElementsByTagName("agotado").item(0).lastChild.nodeValue != null) {
                                    if (oFicha.getElementsByTagName("agotado").item(0).lastChild.nodeValue.length > 0) {
                                        _agotado = true;
                                        msgAgotado = oFicha.getElementsByTagName("agotado").item(0).lastChild.nodeValue;
                                    }

                                }
                                else if (oFicha.getElementsByTagName("agotado").item(0).text != null) {
                                    if (oFicha.getElementsByTagName("agotado").item(0).text.length > 0) {
                                        _agotado = true;
                                        msgAgotado = oFicha.getElementsByTagName("agotado").item(0).text;
                                    }
                                }

                            }
                        }
                        catch (e) {
                        }

                        var stalla = "<select id=selectTalla_" + iProducto + " style=width:80px "

                        if (!_agotado) {
                            stalla += "onChange=seleccionaTalla(this,'_" + iProducto + "')";
                        }
                        else {
                            stalla += " disabled=true "
                        }

                        stalla += ">"


                        if (oFicha.getElementsByTagName("tallas") != null && oFicha.getElementsByTagName("tallas").length > 0) {
                            var otallas = oFicha.getElementsByTagName("tallas").item(0);

                            if (otallas.getElementsByTagName("talla") != null && otallas.getElementsByTagName("talla").length > 0) {
                                if (otallas.getElementsByTagName("talla").length > 1) {
                                    stalla += "<option value=0>" + otallas.getAttribute("etiqueta") + "</option>";
                                }
                                for (var i = 0; i < otallas.getElementsByTagName("talla").length; i++) {
                                    var otalla = otallas.getElementsByTagName("talla").item(i);

                                    var _tallaD = "";
                                    var _tallaId = "";

                                    if (otalla.getElementsByTagName("valuetalla").item(0).lastChild != null && otalla.getElementsByTagName("valuetalla").item(0).lastChild.nodeValue != null) {
                                        _tallaId = otalla.getElementsByTagName("valuetalla").item(0).lastChild.nodeValue;
                                    }
                                    else if (otalla.getElementsByTagName("valuetalla").item(0).text) {
                                        _tallaId = otalla.getElementsByTagName("valuetalla").item(0).text;
                                    }

                                    if (otalla.getElementsByTagName("texttalla").item(0).lastChild != null && otalla.getElementsByTagName("texttalla").item(0).lastChild.nodeValue != null) {
                                        _tallaD = otalla.getElementsByTagName("texttalla").item(0).lastChild.nodeValue;
                                    }
                                    else if (otalla.getElementsByTagName("texttalla").item(0).text) {
                                        _tallaD = otalla.getElementsByTagName("texttalla").item(0).text;
                                    }

                                    stalla += "<option value=" + _tallaId + ">" + _tallaD + "</option>";
                                }
                            }
                            else {
                                stalla += "<option value=0>Tallas</option>";
                            }
                        }
                        else {
                            stalla += "<option value=0>Tallas</option>";
                        }
                        stalla += "</select>"
                        document.getElementById(iProducto + '_tdTalla').innerHTML = stalla
                    }
                }
                else {
                    if (xmlDocResp.getElementsByTagName("raiz") != null && xmlDocResp.getElementsByTagName("raiz").length > 0) {
                        var oResultado = xmlDocResp.getElementsByTagName("raiz").item(0);

                        if (oResultado.getElementsByTagName("Error") != null && oResultado.getElementsByTagName("Error").length > 0) {
                            if (oResultado.getElementsByTagName("Error").item(0).lastChild != null && oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue != null) {
                                MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue, "Default.aspx");
                            }
                            else if (oResultado.getElementsByTagName("Error").item(0).lastChild.text != null) {
                                MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.text, "Default.aspx");
                            }
                        }
                    }
                }
            }
        }
    }
    http_request.send(null);    
}

function AjxCargaColores(iProducto, _productoId, _subseccionId, idiomaId, zonaId, paisId, varianteId) {

    var http_request  = crearInstanciaAjax();
    var url = 'ajax/cargaArticulos.aspx';
    if (!http_request){
        alert("No se pudo realizar la llamada al servidor.");
        return false;
    }
    
    var date = new Date()
    var ticks = date.getTime()

    http_request.open("GET", url + "?PRODUCTOID=" + _productoId + "&COLOR=S&COLORMOSTRADO=" + varianteId + "&" + ticks, true);

    http_request.onreadystatechange = function () {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {


                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);

                if (!xmlDocResp) {
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = true;

                if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0) {
                    var oResultado = xmlDocResp.getElementsByTagName("resultado").item(0);

                    if (oResultado.getElementsByTagName("fichaProducto") != null && oResultado.getElementsByTagName("fichaProducto").length > 0) {
                        var oFicha = oResultado.getElementsByTagName("fichaProducto").item(0)


                        if (oFicha.getElementsByTagName("colores") != null && oFicha.getElementsByTagName("colores").length > 0) {
                            var oColores = oFicha.getElementsByTagName("colores").item(0);

                            if (oColores.getElementsByTagName("color") != null && oColores.getElementsByTagName("color").length > 0) {
                                for (var i = 0; i < oColores.getElementsByTagName("color").length; i++) {
                                    var oColor = oColores.getElementsByTagName("color").item(i);

                                    var _descColor = "";
                                    var _colorVarianteId = "";
                                    var _rgb_ruta = "";
                                    var _imagenDetalleV = "";
                                    var _identificadorPantoneid = "";

                                    if (oColor.getElementsByTagName("descripcionColor").item(0).lastChild != null && oColor.getElementsByTagName("descripcionColor").item(0).lastChild.nodeValue != null) {
                                        _descColor = oColor.getElementsByTagName("descripcionColor").item(0).lastChild.nodeValue;
                                    }
                                    else if (oColor.getElementsByTagName("descripcionColor").item(0).text != null) {
                                        _descColor = oColor.getElementsByTagName("descripcionColor").item(0).text;
                                    }

                                    if (oColor.getElementsByTagName("colorVarianteId").item(0).lastChild != null && oColor.getElementsByTagName("colorVarianteId").item(0).lastChild.nodeValue != null) {
                                        _colorVarianteId = oColor.getElementsByTagName("colorVarianteId").item(0).lastChild.nodeValue;
                                    }
                                    else if (oColor.getElementsByTagName("colorVarianteId").item(0).text != null) {
                                        _colorVarianteId = oColor.getElementsByTagName("colorVarianteId").item(0).text;
                                    }

                                    if (oColor.getElementsByTagName("rgb_ruta").item(0).lastChild != null && oColor.getElementsByTagName("rgb_ruta").item(0).lastChild.nodeValue != null) {
                                        _rgb_ruta = oColor.getElementsByTagName("rgb_ruta").item(0).lastChild.nodeValue;
                                    }
                                    else if (oColor.getElementsByTagName("rgb_ruta").item(0).text != null) {
                                        _rgb_ruta = oColor.getElementsByTagName("rgb_ruta").item(0).text;
                                    }

                                    if (oColor.getElementsByTagName("imagenDetalleV").item(0).lastChild != null && oColor.getElementsByTagName("imagenDetalleV").item(0).lastChild.nodeValue != null) {
                                        _imagenDetalleV = oColor.getElementsByTagName("imagenDetalleV").item(0).lastChild.nodeValue;
                                    }
                                    else if (oColor.getElementsByTagName("imagenDetalleV").item(0).text != null) {
                                        _imagenDetalleV = oColor.getElementsByTagName("imagenDetalleV").item(0).text;
                                    }

                                    if (oColor.getElementsByTagName("identificadorPantoneid").item(0).lastChild != null && oColor.getElementsByTagName("identificadorPantoneid").item(0).lastChild.nodeValue != null) {
                                        _identificadorPantoneid = oColor.getElementsByTagName("identificadorPantoneid").item(0).lastChild.nodeValue;
                                    }
                                    else if (oColor.getElementsByTagName("identificadorPantoneid").item(0).text != null) {
                                        _identificadorPantoneid = oColor.getElementsByTagName("identificadorPantoneid").item(0).text;
                                    }

                                    if ((oColor.getElementsByTagName("tipo").item(0).lastChild != null && oColor.getElementsByTagName("tipo").item(0).lastChild.nodeValue != null && oColor.getElementsByTagName("tipo").item(0).lastChild.nodeValue == "C") || (oColor.getElementsByTagName("tipo").item(0).text != null && oColor.getElementsByTagName("tipo").item(0).text == "C")) {
                                        document.getElementById('pColores_' + iProducto).innerHTML += '<span id=capaColor_' + iProducto + '_' + _colorVarianteId + ' style=background:#' + _rgb_ruta + ';cursor:pointer; onmouseout="restaurarImagenColorProducto(\'_' + iProducto + '\');" onmouseover="mostrarColorProducto(\'' + _imagenDetalleV + '\',\'_' + iProducto + '\');"  onclick="seleccionaColorProducto(\'capaColor_' + iProducto + '_' + _colorVarianteId + '\',\'_' + iProducto + '\',\'' + _colorVarianteId + '\',\'' + _identificadorPantoneid + '\',\'' + _descColor + '\',\'' + _imagenDetalleV + '\');"><img src=img/transparent.gif width=23 height=23 alt="' + _descColor + '" title="' + _descColor + '"/></span>';
                                    }
                                    else {
                                        document.getElementById('pColores_' + iProducto).innerHTML += '<span id="capaColor_' + iProducto + '_' + _colorVarianteId + '" style="cursor:pointer;" onmouseout="restaurarImagenColorProducto(\'_' + iProducto + '\');" onmouseover="mostrarColorProducto(\'' + _imagenDetalleV + '\',\'_' + iProducto + '\');" onclick="seleccionaColorProducto(\'capaColor_' + iProducto + '_' + _colorVarianteId + '\',\'_' + iProducto + '\',\'' + _colorVarianteId + '\',\'' + _identificadorPantoneid + '\',\'' + _descColor + '\',\'' + _imagenDetalleV + '\');"><img src="' + _rgb_ruta + '" width="23" height="23" alt="' + _descColor + '" title="' + _descColor + '"/></span>';
                                    }

                                    if ((oColor.getElementsByTagName("esPrincipal").item(0).lastChild != null && oColor.getElementsByTagName("esPrincipal").item(0).lastChild.nodeValue != null && oColor.getElementsByTagName("esPrincipal").item(0).lastChild.nodeValue == "true") || (oColor.getElementsByTagName("tipo").item(0).text != null && oColor.getElementsByTagName("tipo").item(0).text == "true")) {
                                        document.getElementById('capaColor_' + iProducto + '_' + _colorVarianteId).click();
                                    }
                                }
                            }
                        }

                        if (oFicha.getElementsByTagName("colorPid") != null && oFicha.getElementsByTagName("colorPid").length > 0) {
                            var _colorPid = "";
                            var _colorPdesc = "";

                            if (oFicha.getElementsByTagName("colorPid").item(0).lastChild != null && oFicha.getElementsByTagName("colorPid").item(0).lastChild.nodeValue != null) {
                                _colorPid = oFicha.getElementsByTagName("colorPid").item(0).lastChild.nodeValue;
                            }
                            else if (oFicha.getElementsByTagName("colorPid").item(0).text) {
                                _colorPid = oFicha.getElementsByTagName("colorPid").item(0).text;
                            }

                            if (oFicha.getElementsByTagName("colorPdesc").item(0).lastChild != null && oFicha.getElementsByTagName("colorPdesc").item(0).lastChild.nodeValue != null) {
                                _colorPdesc = oFicha.getElementsByTagName("colorPdesc").item(0).lastChild.nodeValue;
                            }
                            else if (oFicha.getElementsByTagName("colorPdesc").item(0).text) {
                                _colorPdesc = oFicha.getElementsByTagName("colorPdesc").item(0).text;
                            }

                            //document.getElementById('sColorSelec_'+ iProducto).innerHTML = _colorPdesc
                            document.getElementById('hVarianteId_' + iProducto).value = _colorPid
                        }

                        if (oFicha.getElementsByTagName("colorPImg") != null && oFicha.getElementsByTagName("colorPImg").length > 0) {
                            if (oFicha.getElementsByTagName("colorPImg").item(0).lastChild != null && oFicha.getElementsByTagName("colorPImg").item(0).lastChild.nodeValue != null) {
                                loadImage(document.getElementById('imgVar_' + iProducto), oFicha.getElementsByTagName("colorPImg").item(0).lastChild.nodeValue, 0);
                            }
                            else if (oFicha.getElementsByTagName("colorPImg").item(0).text != null) {
                                loadImage(document.getElementById('imgVar_' + iProducto), oFicha.getElementsByTagName("colorPImg").item(0).text, 0);
                            }
                        }

                    }
                }
                else {
                    if (xmlDocResp.getElementsByTagName("raiz") != null && xmlDocResp.getElementsByTagName("raiz").length > 0) {
                        var oResultado = xmlDocResp.getElementsByTagName("raiz").item(0);

                        if (oResultado.getElementsByTagName("Error") != null && oResultado.getElementsByTagName("Error").length > 0) {
                            if (oResultado.getElementsByTagName("Error").item(0).lastChild != null && oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue != null) {
                                MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue, "Default.aspx");
                            }
                            else if (oResultado.getElementsByTagName("Error").item(0).lastChild.text != null) {
                                MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.text, "Default.aspx");
                            }
                        }
                    }
                }
            }
        }
    }
    http_request.send(null);    
}

function AjxCargaPrecio(iProducto, _productoId, _subseccionId, idiomaId, zonaId, paisId, clienteId) {

    var http_request  = crearInstanciaAjax();
    var url = 'ajax/cargaArticulos.aspx';
    if (!http_request){
        alert("No se pudo realizar la llamada al servidor.");
        return false;
    }
    
    var date = new Date()
    var ticks = date.getTime()

    http_request.open("GET", url + "?PRODUCTOID=" + _productoId + "&PRECIO=S&PAISID=" + paisId + "&ZONAID=" + zonaId + "&CLIENTEID=" + clienteId + "&"+ ticks, true);

    http_request.onreadystatechange = function () {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {


                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);

                if (!xmlDocResp) {
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = true;

                if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0) {
                    var oResultado = xmlDocResp.getElementsByTagName("resultado").item(0);

                    if (oResultado.getElementsByTagName("fichaProducto") != null && oResultado.getElementsByTagName("fichaProducto").length > 0) {
                        var oFicha = oResultado.getElementsByTagName("fichaProducto").item(0)

                        var sPrecioR = "";
                        var sTituloR = "";
                        var sPrecioDescuento = "";
                        var monedaEst = "";
                        var soloExperience = "N";
                        var sPrecioAnt = "";
                        if (oFicha.getElementsByTagName("Precio") != null && oFicha.getElementsByTagName("Precio").length > 0 && oFicha.getElementsByTagName("Moneda") != null && oFicha.getElementsByTagName("Moneda").length > 0) {
                            if (oFicha.getElementsByTagName("Moneda").item(0).lastChild != null && oFicha.getElementsByTagName("Moneda").item(0).lastChild.nodeValue != null) {
                                monedaEst = oFicha.getElementsByTagName("Moneda").item(0).lastChild.nodeValue
                            }
                            else if (oFicha.getElementsByTagName("Moneda").item(0).text != null) {
                                monedaEst = oFicha.getElementsByTagName("Moneda").item(0).text
                            }

                            var sPrecio = ""
                            if (oFicha.getElementsByTagName("Precio").item(0).lastChild != null && oFicha.getElementsByTagName("Precio").item(0).lastChild.nodeValue != null) {
                                sPrecio = oFicha.getElementsByTagName("Precio").item(0).lastChild.nodeValue
                            }
                            else if (oFicha.getElementsByTagName("Precio").item(0).text != null) {
                                sPrecio = oFicha.getElementsByTagName("Precio").item(0).text
                            }

                            if (sPrecio == "--") {
                                document.getElementById(iProducto + '_precio').innerHTML += sPrecio;
                            }
                            else {
                                _decimales = sPrecio.substring(sPrecio.length - 3, sPrecio.length - 2);
                                sPrecio = Math.round(parseFloat(sPrecio.replace(",", ".")));
                                sPrecio += _decimales + '00'

                                sPrecioAnt = sPrecio;
                                //document.getElementById (iProducto +'_descripcion').innerHTML += '<span class=link_video id ="'+ iProducto +'_precioReal">' + sPrecio  + ' ' + monedaEst  + '</span>';
                                document.getElementById(iProducto + '_precio').innerHTML += sPrecio + ' ' + monedaEst;
                            }
                            document.getElementById(iProducto + '_precio').className = 'priceart';
                            document.getElementById(iProducto + '_precio2').style.display = 'none';

                            if (oFicha.getElementsByTagName("PrecioR") != null && oFicha.getElementsByTagName("PrecioR").length > 0) {

                                if (oFicha.getElementsByTagName("PrecioR").item(0).lastChild != null && oFicha.getElementsByTagName("PrecioR").item(0).lastChild.nodeValue != null) {
                                    sPrecioR = oFicha.getElementsByTagName("PrecioR").item(0).lastChild.nodeValue
                                }
                                else if (oFicha.getElementsByTagName("PrecioR").item(0).text != null) {
                                    sPrecioR = oFicha.getElementsByTagName("PrecioR").item(0).text
                                }

                                if (oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("TituloPrecioR") != null) {
                                    sTituloR = oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("TituloPrecioR")
                                }

                                sPrecio = sPrecioR
                                if (oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("soloExperienceR") == null || oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("soloExperienceR") != "S") {
                                    soloExperience = "N";
                                }
                                else {
                                    soloExperience = "S";
                                }
                                if (sPrecioR == "--") {
                                    document.getElementById(iProducto + '_precio2').innerHTML += sPrecioR;
                                }
                                else {
                                    _decimales = sPrecioR.substring(sPrecioR.length - 3, sPrecioR.length - 2);
                                    sPrecioR = Math.round(parseFloat(sPrecioR.replace(",", ".")));
                                    sPrecioR += _decimales + '00'

                                    document.getElementById(iProducto + '_precio2').innerHTML += sPrecioR + ' ' + monedaEst;
                                }
                                document.getElementById(iProducto + '_precio').className = 'pricearttachado';
                                document.getElementById(iProducto + '_precio2').style.display = 'block';
                            }

                            var sTituloD = "";
                            if (oFicha.getElementsByTagName("PrecioD") != null && oFicha.getElementsByTagName("PrecioD").length > 0) {

                                if (oFicha.getElementsByTagName("PrecioD").item(0).lastChild != null && oFicha.getElementsByTagName("PrecioD").item(0).lastChild.nodeValue != null) {
                                    sPrecioDescuento = oFicha.getElementsByTagName("PrecioD").item(0).lastChild.nodeValue
                                }
                                else if (oFicha.getElementsByTagName("PrecioD").item(0).text != null) {
                                    sPrecioDescuento = oFicha.getElementsByTagName("PrecioD").item(0).text
                                }

                                if (oFicha.getElementsByTagName("PrecioD").item(0).getAttribute("TituloPrecioD") != null) {
                                    sTituloD = oFicha.getElementsByTagName("PrecioD").item(0).getAttribute("TituloPrecioD")
                                }

                                if (sPrecioDescuento == "--") {
                                    document.getElementById(iProducto + '_precio2').innerHTML += sPrecioDescuento;
                                }
                                else {
                                    _decimales = sPrecioDescuento.substring(sPrecioDescuento.length - 3, sPrecioDescuento.length - 2);
                                    sPrecioDescuento = Math.round(parseFloat(sPrecioDescuento.replace(",", ".")));
                                    sPrecioDescuento += _decimales + '00'

                                    document.getElementById(iProducto + '_precio2').innerHTML += sPrecioDescuento + ' ' + monedaEst;
                                }
                                document.getElementById(iProducto + '_precio').className = 'pricearttachado';
                                document.getElementById(iProducto + '_precio2').style.display = 'block';

                            }
                            else {
                                sPrecioDescuento = sPrecio
                            }
                        }


                        var _periodotarifaid = 0

                        if (oFicha.getElementsByTagName("periodotarifaid") != null && oFicha.getElementsByTagName("periodotarifaid").length > 0) {

                            if (oFicha.getElementsByTagName("periodotarifaid").item(0).lastChild != null && oFicha.getElementsByTagName("periodotarifaid").item(0).lastChild.nodeValue != null) {
                                _periodotarifaid = oFicha.getElementsByTagName("periodotarifaid").item(0).lastChild.nodeValue;
                            }
                            else if (oFicha.getElementsByTagName("periodotarifaid").item(0).text) {
                                _periodotarifaid = oFicha.getElementsByTagName("periodotarifaid").item(0).text;
                            }

                        }


                        document.getElementById('sPrecioDescuento_' + iProducto).value = sPrecioDescuento;
                        document.getElementById('monedaEst_' + iProducto).value = monedaEst;
                        document.getElementById('soloExperience_' + iProducto).value = soloExperience;
                        document.getElementById('sPrecioAnt_' + iProducto).value = sPrecioAnt;
                        document.getElementById('_periodotarifaid_' + iProducto).value = _periodotarifaid;

                    }
                }
                else {
                    if (xmlDocResp.getElementsByTagName("raiz") != null && xmlDocResp.getElementsByTagName("raiz").length > 0) {
                        var oResultado = xmlDocResp.getElementsByTagName("raiz").item(0);

                        if (oResultado.getElementsByTagName("Error") != null && oResultado.getElementsByTagName("Error").length > 0) {
                            if (oResultado.getElementsByTagName("Error").item(0).lastChild != null && oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue != null) {
                                MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue, "Default.aspx");
                            }
                            else if (oResultado.getElementsByTagName("Error").item(0).lastChild.text != null) {
                                MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.text, "Default.aspx");
                            }
                        }
                    }
                }
            }
        }
    }
    http_request.send(null);    
}

function AjxCargaRecomendados(iProducto, _productoId,_subseccionId,idiomaId,zonaId,paisId){

    var http_request  = crearInstanciaAjax();
    var url = 'ajax/recomendados.ashx';
    if (!http_request){
        alert("No se pudo realizar la llamada al servidor.");
        return false;
    }
    
    var date = new Date()
    var ticks = date.getTime()

    http_request.open("GET", url + "?PRODUCTOID=" + _productoId + "&RECOMENDADOS=S&" + ticks, true);

    http_request.onreadystatechange = function () {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);

                if (!xmlDocResp) {
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = true;

                if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0) {
                    var oResultado = xmlDocResp.getElementsByTagName("resultado").item(0);

                    if (oResultado.getElementsByTagName("fichaProducto") != null && oResultado.getElementsByTagName("fichaProducto").length > 0) {
                        var oFicha = oResultado.getElementsByTagName("fichaProducto").item(0)

                        var txt = "";
                        
                        if (oFicha.getElementsByTagName("imgRelacionadas") != null && oFicha.getElementsByTagName("imgRelacionadas").length > 0) {
                            var oImgRelacionadas = oFicha.getElementsByTagName("imgRelacionadas").item(0);

                            if (oImgRelacionadas.getElementsByTagName("imgR") != null && oImgRelacionadas.getElementsByTagName("imgR").length > 0) {
                                if (oImgRelacionadas.getElementsByTagName("imgR").length == 1) {
                                    txt = txt + '<div class="com031">';
                                }
                                else {
                                    txt = txt + '<div class="com03">';
                                }
                                var sImgR = ""
                                var cont_ = 0;
                                for (var i = 0; i < oImgRelacionadas.getElementsByTagName("imgR").length; i++) {
                                    oImgR = oImgRelacionadas.getElementsByTagName("imgR").item(i);

                                    if (cont_ < 3) {
                                        if (oImgR.getAttribute("productoID") != null) {

                                            txt += "<a href='javascript:muestraProducto(\"" + _subseccionId + "\",\"" + oImgR.getAttribute("productoID") + "\");' target='_self' "


                                            txt += " ><img src='"

                                            if (oImgR.lastChild != null && oImgR.lastChild.nodeValue != null) {
                                                txt += oImgR.lastChild.nodeValue;
                                            }
                                            else if (oImgR.text != null) {
                                                txt += oImgR.text;
                                            }

                                            txt += "' class='initimg'  height='160px' width='166px'/></a>"
                                            cont_ += 1;
                                        }
                                        else if ((oImgRelacionadas.getElementsByTagName("imgR").length - 1) == i) {
                                        }
                                    }
                                }

                                txt = txt + '</div><!--columna 03-->';

                                var sImgEstilismoR = "";
                                var sListImgEstilismoR = "";

                                if (oFicha.getElementsByTagName("imgEstilismosRelacionados") != null && oFicha.getElementsByTagName("imgEstilismosRelacionados").length > 0) {
                                    var oImgRelacionadasE = oFicha.getElementsByTagName("imgEstilismosRelacionados").item(0);

                                    if (oImgRelacionadasE.getAttribute("imgEstR") != null && oImgRelacionadasE.getAttribute("imgEstR") != '') {
                                        sImgEstilismoR = oImgRelacionadasE.getAttribute("imgEstR");
                                    }
                                    else {
                                        sImgEstilismoR = "img/noestilismo.jpg";
                                    }
                                    var sIdsEstilismosRelacionados = "";

                                    if (oImgRelacionadasE.getAttribute("idsCategoriasR") != null && oImgRelacionadasE.getAttribute("idsCategoriasR") != '') {
                                        sIdsEstilismosRelacionados = oImgRelacionadasE.getAttribute("idsCategoriasR");
                                    }

                                    if (oImgRelacionadasE.getElementsByTagName("imgR") != null && oImgRelacionadasE.getElementsByTagName("imgR").length > 0) {
                                        var sListImgEstilismoR = ""
                                        for (var i = 0; i < oImgRelacionadasE.getElementsByTagName("imgR").length; i++) {
                                            oImgR = oImgRelacionadasE.getElementsByTagName("imgR").item(i);

                                            if (oImgR.getAttribute("estilismoID") != null) {
                                                // sListImgEstilismoR +=  "<a href='javascript:alert(\"verEstilismo " + oImgR.getAttribute("estilismoID")  + "\");' target='_self'><img src='"
                                                sListImgEstilismoR += "<img src='"

                                                if (oImgR.lastChild != null && oImgR.lastChild.nodeValue != null) {
                                                    sListImgEstilismoR += oImgR.lastChild.nodeValue;
                                                }
                                                else if (oImgR.text != null) {
                                                    sListImgEstilismoR += oImgR.text;
                                                }

                                                sListImgEstilismoR += "' id='estilismomas_" + i + "' class='initimg' style='cursor:pointer;' onclick='javascript:muestraMasEstilismos(\"" + oImgR.getAttribute("estilismoID") + "\");'  width='52' height='100'/>"
                                            }
                                            else {
                                                sListImgEstilismoR += "<img src='"

                                                if (oImgR.lastChild != null && oImgR.lastChild.nodeValue != null) {
                                                    sListImgEstilismoR += oImgR.lastChild.nodeValue;
                                                }
                                                else if (oImgR.text != null) {
                                                    sListImgEstilismoR += oImgR.text;
                                                }
                                                sListImgEstilismoR += "' id='estilismomas_" + i + "' class='initimg' width='52' height='100'/>"
                                            }

                                        }
                                    }
                                }
                                txt = txt + '<div class="com04">';
                                txt = txt + '<img src="' + sImgEstilismoR + '" id="estilismomas" class="initimg"/>';
                                txt = txt + '</div>';
                                txt = txt + '<div class="com05">';
                                //txt = txt + '<a href="#" class="sclose_" onclick="this.up(4).down(\'a.sclose\').click();"><img src="img/sclose.png" id="article1" class="initimg"/></a>';
                                txt = txt + '<div class="miniartcicle">';
                                //                    txt = txt + '<img src="barevalo/prendas/img/image2.jpg" id="estilismomas" class="initimg" width="52" height="100"/>';
                                //                    txt = txt + '<img src="barevalo/prendas/img/image2.jpg" id="estilismomas" class="initimg" width="52" height="100"/>';
                                txt = txt + sListImgEstilismoR;
                                txt = txt + '</div>';
                                if (sIdsEstilismosRelacionados != "") {
                                    txt = txt + '<a href="javascript:muestraMasEstilismos(\'' + sIdsEstilismosRelacionados + '\');" target="_self">' + oImgRelacionadasE.getAttribute("verMasEstilismos") + ' </a>';
                                }
                                txt = txt + '<div class="miniartcicle">';

                                if (oImgRelacionadas.getElementsByTagName("imgR_detalle") != null && oImgRelacionadas.getElementsByTagName("imgR_detalle").length > 0) {
                                    var sImgR = ""
                                    for (var i = 0; i < oImgRelacionadas.getElementsByTagName("imgR_detalle").length; i++) {
                                        oImgR = oImgRelacionadas.getElementsByTagName("imgR_detalle").item(i);

                                        if (oImgR.getAttribute("productoID") != null) {
                                            txt += "<img src='"

                                            if (oImgR.lastChild != null && oImgR.lastChild.nodeValue != null) {
                                                txt += oImgR.lastChild.nodeValue;
                                            }
                                            else if (oImgR.text != null) {
                                                txt += oImgR.text;
                                            }

                                            txt += "' class='initimg' height='100px' width='52px' style='cursor:pointer' onclick='muestraProducto(\"" + _subseccionId + "\",\"" + oImgR.getAttribute("productoID") + "\");''/>"
                                        }
                                        else {
                                            txt += "<img src='"

                                            if (oImgR.lastChild != null && oImgR.lastChild.nodeValue != null) {
                                                txt += oImgR.lastChild.nodeValue;
                                            }
                                            else if (oImgR.text != null) {
                                                txt += oImgR.text;
                                            }
                                            txt += "' class='initimg' height='100px' width='52px'/>"
                                        }

                                    }
                                }
                                //txt = txt + '<img src="barevalo/prendas/img/image1.jpg" id="estilismomas" class="initimg" width="52" height="100"/>';
                                //txt = txt + '<img src="barevalo/prendas/img/image1.jpg" id="estilismomas" class="initimg" width="52" height="100"/>';
                                txt = txt + '</div>';

                                if (oImgRelacionadas.getElementsByTagName("tipoPrenda") != null && oImgRelacionadas.getElementsByTagName("tipoPrenda").length > 0) {
                                    var oTipoPrenda = oImgRelacionadas.getElementsByTagName("tipoPrenda").item(0);

                                    txt = txt + '<a href="#" onclick="muestraPrenda(\'' + oTipoPrenda.getAttribute("valor") + '\',' + oTipoPrenda.getAttribute("subseccionid") + ')">' + oTipoPrenda.getAttribute("verMas") + ' ' + oTipoPrenda.lastChild.nodeValue + ' </a>';
                                    // oImgR.lastChild.nodeValue;
                                }
                                else if (oImgRelacionadas.getElementsByTagName("imgR_detalle") != null && oImgRelacionadas.getElementsByTagName("imgR_detalle").length > 0) {
                                    txt = txt + '<a href="#" onclick="muestraProducto(\'' + _subseccionId + '\',\'' + oImgRelacionadas.getElementsByTagName("imgR_detalle").item(0).getAttribute("productoID") + '\');">' + oImgRelacionadas.getElementsByTagName("imgR_detalle").item(0).getAttribute("combinaloCon") + ' ... >></a>';
                                }

                                txt = txt + '</div>';

                                document.getElementById('articuleFeature_' + iProducto + '_1').innerHTML = txt
                            }
                        }

                    }
                }
                else {
                    if (xmlDocResp.getElementsByTagName("raiz") != null && xmlDocResp.getElementsByTagName("raiz").length > 0) {
                        var oResultado = xmlDocResp.getElementsByTagName("raiz").item(0);

                        if (oResultado.getElementsByTagName("Error") != null && oResultado.getElementsByTagName("Error").length > 0) {
                            if (oResultado.getElementsByTagName("Error").item(0).lastChild != null && oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue != null) {
                                MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue, "Default.aspx");
                            }
                            else if (oResultado.getElementsByTagName("Error").item(0).lastChild.text != null) {
                                MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.text, "Default.aspx");
                            }
                        }
                    }
                }
            }
        }
    }
    http_request.send(null);
}
function AjxCargaFichaMascota(iProducto, _estilismoId, _productoTempId,_subseccionId, idiomaId, zonaId, paisId) {
    var http_request = crearInstanciaAjax();
    var url = 'ajax/cargaArticulos.aspx';
    if (!http_request) {
        alert("No se pudo realizar la llamada al servidor.");
        return false;
    }

    var date = new Date()
    var ticks = date.getTime()

    http_request.open("GET", url + "?MASCOTAID=" + _estilismoId + "&PRODUCTOID=" + _productoTempId + "&" + ticks, false);
    http_request.send(null);

    var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);

    if (!xmlDocResp) {
        alert("No se pudo crear el documento xml para procesar la respuesta.");
        return false;
    }
    xmlDocResp.async = false;

    if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0) {
        var oResultado = xmlDocResp.getElementsByTagName("resultado").item(0);

        if (oResultado.getElementsByTagName("fichaProducto") != null && oResultado.getElementsByTagName("fichaProducto").length > 0) {
            var oFicha = oResultado.getElementsByTagName("fichaProducto").item(0)

            document.getElementById(iProducto + '_coloresDisponibles').innerHTML = oFicha.getAttribute("coloresDisponibles")
            document.getElementById(iProducto + '_verTallas').innerHTML = oFicha.getAttribute("verTallas")
//            document.getElementById(iProducto + '_cuidados').innerHTML = ""
//            document.getElementById(iProducto + '_composicion').innerHTML = ""

//            document.getElementById('licuid' + iProducto).innerHTML = oFicha.getAttribute("cuidados")
//            document.getElementById('licomp' + iProducto).innerHTML = oFicha.getAttribute("composicion")

            //var _productoId = oFicha.getAttribute("ProductoTmpId")
            var addWishList = ""

            addWishList = oFicha.getAttribute("addWishList")
            var nombreEstilismo = ""
            if (oFicha.getElementsByTagName("Nombre") != null && oFicha.getElementsByTagName("Nombre").length > 0) {
                if (oFicha.getElementsByTagName("Nombre").item(0).lastChild != null) {
                    nombreEstilismo = oFicha.getElementsByTagName("Nombre").item(0).lastChild.nodeValue;
                }
                else if (oFicha.getElementsByTagName("Nombre").item(0).text != null) {
                    nombreEstilismo = oFicha.getElementsByTagName("Nombre").item(0).text;
                }

                document.getElementById(iProducto + '_titulo').innerHTML = nombreEstilismo;
            }

           


            var _agotado = false;
            var msgAgotado= ""
            try {
                if (oFicha.getElementsByTagName("agotado") != null && oFicha.getElementsByTagName("agotado").length > 0) {
                    if (oFicha.getElementsByTagName("agotado").item(0).lastChild != null && oFicha.getElementsByTagName("agotado").item(0).lastChild.nodeValue != null) {
                        if (oFicha.getElementsByTagName("agotado").item(0).lastChild.nodeValue.length > 0) {
                            _agotado = true;
                            msgAgotado = oFicha.getElementsByTagName("agotado").item(0).lastChild.nodeValue;
                        }

                    }
                    else if (oFicha.getElementsByTagName("agotado").item(0).text != null) {
                        if (oFicha.getElementsByTagName("agotado").item(0).text.length > 0) {
                            _agotado = true;
                            msgAgotado = oFicha.getElementsByTagName("agotado").item(0).text;
                        }
                    }

                }
            }
            catch (e) {
            }     

            if (oFicha.getElementsByTagName("Descripcion") != null && oFicha.getElementsByTagName("Descripcion").length > 0) {
//                if (oFicha.getAttribute("TituloDescripcion") != null) {
//                    document.getElementById('lides' + iProducto).innerHTML = oFicha.getAttribute("TituloDescripcion");
//                }
                if (oFicha.getElementsByTagName("Descripcion").item(0).lastChild != null && oFicha.getElementsByTagName("Descripcion").item(0).lastChild.nodeValue != null) {
                    document.getElementById(iProducto + '_descripcion').innerHTML = "<p>"+ oFicha.getElementsByTagName("Descripcion").item(0).lastChild.nodeValue+ "</p>";
                }
                else if (oFicha.getElementsByTagName("Descripcion").item(0).text != null) {
                    document.getElementById(iProducto + '_descripcion').innerHTML = "<p>" + oFicha.getElementsByTagName("Descripcion").item(0).text+ "</p>";
                }
                else {
                    document.getElementById(iProducto + '_descripcion').innerHTML = "";
                }
            }

            var sPrecioR = "";
            var sTituloR = "";
            var sPrecioDescuento = "";
            var monedaEst = "";
            var soloExperience = "N";
            var sPrecioAnt = "";
            if (oFicha.getElementsByTagName("Precio") != null && oFicha.getElementsByTagName("Precio").length > 0 && oFicha.getElementsByTagName("Moneda") != null && oFicha.getElementsByTagName("Moneda").length > 0) {
                if (oFicha.getElementsByTagName("Moneda").item(0).lastChild != null && oFicha.getElementsByTagName("Moneda").item(0).lastChild.nodeValue != null) {
                    monedaEst = oFicha.getElementsByTagName("Moneda").item(0).lastChild.nodeValue
                }
                else if (oFicha.getElementsByTagName("Moneda").item(0).text != null) {
                    monedaEst = oFicha.getElementsByTagName("Moneda").item(0).text
                }

                var sPrecio = ""
                if (oFicha.getElementsByTagName("Precio").item(0).lastChild != null && oFicha.getElementsByTagName("Precio").item(0).lastChild.nodeValue != null) {
                    sPrecio = oFicha.getElementsByTagName("Precio").item(0).lastChild.nodeValue
                }
                else if (oFicha.getElementsByTagName("Precio").item(0).text != null) {
                    sPrecio = oFicha.getElementsByTagName("Precio").item(0).text
                }

                if (sPrecio == "--") {
                    document.getElementById(iProducto + '_precio').innerHTML += sPrecio;
                }
                else {
                    _decimales = sPrecio.substring(sPrecio.length - 3, sPrecio.length - 2);
                    sPrecio = Math.round(parseFloat(sPrecio.replace(",", ".")));
                    sPrecio += _decimales + '00'

                    sPrecioAnt = sPrecio;
                    document.getElementById(iProducto + '_precio').innerHTML += sPrecio + ' ' + monedaEst;
                }
                
                document.getElementById(iProducto + '_precio').className = 'priceart';

                document.getElementById(iProducto + '_precio2').style.display = 'none';

                if (oFicha.getElementsByTagName("PrecioR") != null && oFicha.getElementsByTagName("PrecioR").length > 0) {
                    if (oFicha.getElementsByTagName("PrecioR").item(0).lastChild != null && oFicha.getElementsByTagName("PrecioR").item(0).lastChild.nodeValue != null) {
                        sPrecioR = oFicha.getElementsByTagName("PrecioR").item(0).lastChild.nodeValue
                    }
                    else if (oFicha.getElementsByTagName("PrecioR").item(0).text != null) {
                        sPrecioR = oFicha.getElementsByTagName("PrecioR").item(0).text
                    }

                    if (oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("TituloPrecioR") != null) {
                        sTituloR = oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("TituloPrecioR")
                    }

                    sPrecio = sPrecioR
                    if (oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("soloExperienceR") == null || oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("soloExperienceR") != "S") {
                        soloExperience = "N";
                    }
                    else {
                        soloExperience = "S";
                    }
                    if (sPrecioR == "--") {
                        document.getElementById(iProducto + '_precio2').innerHTML += sPrecioR;
                    }
                    else {
                        _decimales = sPrecioR.substring(sPrecioR.length - 3, sPrecioR.length - 2);
                        sPrecioR = Math.round(parseFloat(sPrecioR.replace(",", ".")));
                        sPrecioR += _decimales + '00'

                        document.getElementById(iProducto + '_precio2').innerHTML += sPrecioR + ' ' + monedaEst;
                    }
                    document.getElementById(iProducto + '_precio').className = 'pricearttachado';
                    document.getElementById(iProducto + '_precio2').style.display = 'block';
                }

                var sTituloD = "";
                if (oFicha.getElementsByTagName("PrecioD") != null && oFicha.getElementsByTagName("PrecioD").length > 0) {
                    if (oFicha.getElementsByTagName("PrecioD").item(0).lastChild != null && oFicha.getElementsByTagName("PrecioD").item(0).lastChild.nodeValue != null) {
                        sPrecioDescuento = oFicha.getElementsByTagName("PrecioD").item(0).lastChild.nodeValue
                    }
                    else if (oFicha.getElementsByTagName("PrecioD").item(0).text != null) {
                        sPrecioDescuento = oFicha.getElementsByTagName("PrecioD").item(0).text
                    }

                    if (oFicha.getElementsByTagName("PrecioD").item(0).getAttribute("TituloPrecioD") != null) {
                        sTituloD = oFicha.getElementsByTagName("PrecioD").item(0).getAttribute("TituloPrecioD")
                    }

                    if (sPrecioDescuento == "--") {
                        document.getElementById(iProducto + '_precio2').innerHTML += sPrecioDescuento;
                    }
                    else {
                        _decimales = sPrecioDescuento.substring(sPrecioDescuento.length - 3, sPrecioDescuento.length - 2);
                        sPrecioDescuento = Math.round(parseFloat(sPrecioDescuento.replace(",", ".")));
                        sPrecioDescuento += _decimales + '00'

                        document.getElementById(iProducto + '_precio2').innerHTML += sPrecioDescuento + ' ' + monedaEst;
                    }
                    document.getElementById(iProducto + '_precio').className = 'pricearttachado';
                    document.getElementById(iProducto + '_precio2').style.display = 'block';

                }
                else {
                    sPrecioDescuento = sPrecio
                }
            }

            if (oFicha.getElementsByTagName("colores") != null && oFicha.getElementsByTagName("colores").length > 0) {
                var oColores = oFicha.getElementsByTagName("colores").item(0);

                if (oColores.getElementsByTagName("color") != null && oColores.getElementsByTagName("color").length > 0) {
                    for (var i = 0; i < oColores.getElementsByTagName("color").length; i++) {
                        var oColor = oColores.getElementsByTagName("color").item(i);

                        var _descColor = "";
                        var _colorVarianteId = "";
                        var _rgb_ruta = "";
                        var _imagenDetalleV = "";
                        var _identificadorPantoneid = "";

                        if (oColor.getElementsByTagName("descripcionColor").item(0).lastChild != null && oColor.getElementsByTagName("descripcionColor").item(0).lastChild.nodeValue != null) {
                            _descColor = oColor.getElementsByTagName("descripcionColor").item(0).lastChild.nodeValue;
                        }
                        else if (oColor.getElementsByTagName("descripcionColor").item(0).text != null) {
                            _descColor = oColor.getElementsByTagName("descripcionColor").item(0).text;
                        }

                        if (oColor.getElementsByTagName("colorVarianteId").item(0).lastChild != null && oColor.getElementsByTagName("colorVarianteId").item(0).lastChild.nodeValue != null) {
                            _colorVarianteId = oColor.getElementsByTagName("colorVarianteId").item(0).lastChild.nodeValue;
                        }
                        else if (oColor.getElementsByTagName("colorVarianteId").item(0).text != null) {
                            _colorVarianteId = oColor.getElementsByTagName("colorVarianteId").item(0).text;
                        }

                        if (oColor.getElementsByTagName("rgb_ruta").item(0).lastChild != null && oColor.getElementsByTagName("rgb_ruta").item(0).lastChild.nodeValue != null) {
                            _rgb_ruta = oColor.getElementsByTagName("rgb_ruta").item(0).lastChild.nodeValue;
                        }
                        else if (oColor.getElementsByTagName("rgb_ruta").item(0).text != null) {
                            _rgb_ruta = oColor.getElementsByTagName("rgb_ruta").item(0).text;
                        }

                        if (oColor.getElementsByTagName("imagenDetalleV").item(0).lastChild != null && oColor.getElementsByTagName("imagenDetalleV").item(0).lastChild.nodeValue != null) {
                            _imagenDetalleV = oColor.getElementsByTagName("imagenDetalleV").item(0).lastChild.nodeValue;
                        }
                        else if (oColor.getElementsByTagName("imagenDetalleV").item(0).text != null) {
                            _imagenDetalleV = oColor.getElementsByTagName("imagenDetalleV").item(0).text;
                        }

                        if (oColor.getElementsByTagName("identificadorPantoneid").item(0).lastChild != null && oColor.getElementsByTagName("identificadorPantoneid").item(0).lastChild.nodeValue != null) {
                            _identificadorPantoneid = oColor.getElementsByTagName("identificadorPantoneid").item(0).lastChild.nodeValue;
                        }
                        else if (oColor.getElementsByTagName("identificadorPantoneid").item(0).text != null) {
                            _identificadorPantoneid = oColor.getElementsByTagName("identificadorPantoneid").item(0).text;
                        }

                        if ((oColor.getElementsByTagName("tipo").item(0).lastChild != null && oColor.getElementsByTagName("tipo").item(0).lastChild.nodeValue != null && oColor.getElementsByTagName("tipo").item(0).lastChild.nodeValue == "C") || (oColor.getElementsByTagName("tipo").item(0).text != null && oColor.getElementsByTagName("tipo").item(0).text == "C")) {
                            document.getElementById('pColores_' + iProducto).innerHTML += '<span id=capaColor_' + iProducto + '_' + _colorVarianteId + ' style=background:#' + _rgb_ruta + ';cursor:pointer;" onmouseout="restaurarImagenColor(\'_' + iProducto + '\');" onmouseover="mostrarColor(\'' + _imagenDetalleV + '\',\'_' + iProducto + '\');" onclick="seleccionaColorMascota(\'capaColor_' + iProducto + '_' + _colorVarianteId + '\',\'' + _imagenDetalleV + '\',\'_' + iProducto + '\',\'_' + iProducto + '\',\'' + _colorVarianteId + '\',\'' + _identificadorPantoneid + '\',\'' + _descColor + '\');" ><img src=img/transparent.gif width=23 height=23 alt="' + _descColor + '" title="' + _descColor + '"/></span>';
                        }
                        else {
                            document.getElementById('pColores_' + iProducto).innerHTML += '<span id="capaColor_' + iProducto + '_' + _colorVarianteId + '" style="cursor:pointer;" onmouseout="restaurarImagenColor(\'_' + iProducto + '\');" onmouseover="mostrarColor(\'' + _imagenDetalleV + '\',\'_' + iProducto + '\');" onclick="seleccionaColorMascota(\'capaColor_' + iProducto + '_' + _colorVarianteId + '\',\'' + _imagenDetalleV + '\',\'_' + iProducto + '\',\'_' + iProducto + '\',\'' + _colorVarianteId + '\',\'' + _identificadorPantoneid + '\',\'' + _descColor + '\');"><img src="' + _rgb_ruta + '" width="23" height="23" alt="' + _descColor + '" title="' + _descColor + '"/></span>';
                        }

                        if ((oColor.getElementsByTagName("esPrincipal").item(0).lastChild != null && oColor.getElementsByTagName("esPrincipal").item(0).lastChild.nodeValue != null && oColor.getElementsByTagName("esPrincipal").item(0).lastChild.nodeValue == "true") || (oColor.getElementsByTagName("tipo").item(0).text != null && oColor.getElementsByTagName("tipo").item(0).text == "true")) {
                            document.getElementById('capaColor_' + iProducto + '_' + _colorVarianteId).click();
                        }
                    }
                }
            }

            //var stalla = "<select id=selectTalla_" + iProducto + " style=width:80px onChange=seleccionaTalla(this,'_" + iProducto + "')>";

            var stalla = "<select id=selectTalla_" + iProducto + " style=width:80px "

            if (!_agotado) {
                stalla += "onChange=seleccionaTalla(this,'_" + iProducto + "')";
            }
            else {
                stalla += " disabled=true "
            }

            stalla += ">"

            if (oFicha.getElementsByTagName("tallas") != null && oFicha.getElementsByTagName("tallas").length > 0) {
                var otallas = oFicha.getElementsByTagName("tallas").item(0);

              //  stalla += "<option value=0>" + otallas.getAttribute("etiqueta") + "</option>";
                if (otallas.getElementsByTagName("talla") != null && otallas.getElementsByTagName("talla").length > 0) {
                    if (otallas.getElementsByTagName("talla").length > 1) {
                        stalla += "<option value=0>" + otallas.getAttribute("etiqueta") + "</option>";
                    }
                    for (var i = 0; i < otallas.getElementsByTagName("talla").length; i++) {
                        var otalla = otallas.getElementsByTagName("talla").item(i);

                        var _tallaD = "";
                        var _tallaId = "";

                        if (otalla.getElementsByTagName("valuetalla").item(0).lastChild != null && otalla.getElementsByTagName("valuetalla").item(0).lastChild.nodeValue != null) {
                            _tallaId = otalla.getElementsByTagName("valuetalla").item(0).lastChild.nodeValue;
                        }
                        else if (otalla.getElementsByTagName("valuetalla").item(0).text) {
                            _tallaId = otalla.getElementsByTagName("valuetalla").item(0).text;
                        }

                        if (otalla.getElementsByTagName("texttalla").item(0).lastChild != null && otalla.getElementsByTagName("texttalla").item(0).lastChild.nodeValue != null) {
                            _tallaD = otalla.getElementsByTagName("texttalla").item(0).lastChild.nodeValue;
                        }
                        else if (otalla.getElementsByTagName("texttalla").item(0).text) {
                            _tallaD = otalla.getElementsByTagName("texttalla").item(0).text;
                        }

                        stalla += "<option value=" + _tallaId + ">" + _tallaD + "</option>";
                    }
                }
            }
            else {
                stalla += "<option value=0>Tallas</option>";
            }
            stalla += "</select>"
            document.getElementById(iProducto + '_tdTalla').innerHTML = stalla

            if (oFicha.getElementsByTagName("colorPid") != null && oFicha.getElementsByTagName("colorPid").length > 0) {
                var _colorPid = "";
                var _colorPdesc = "";

                if (oFicha.getElementsByTagName("colorPid").item(0).lastChild != null && oFicha.getElementsByTagName("colorPid").item(0).lastChild.nodeValue != null) {
                    _colorPid = oFicha.getElementsByTagName("colorPid").item(0).lastChild.nodeValue;
                }
                else if (oFicha.getElementsByTagName("colorPid").item(0).text) {
                    _colorPid = oFicha.getElementsByTagName("colorPid").item(0).text;
                }

                if (oFicha.getElementsByTagName("colorPdesc").item(0).lastChild != null && oFicha.getElementsByTagName("colorPdesc").item(0).lastChild.nodeValue != null) {
                    _colorPdesc = oFicha.getElementsByTagName("colorPdesc").item(0).lastChild.nodeValue;
                }
                else if (oFicha.getElementsByTagName("colorPdesc").item(0).text) {
                    _colorPdesc = oFicha.getElementsByTagName("colorPdesc").item(0).text;
                }

                document.getElementById('hVarianteId_' + iProducto).value = _colorPid
            }

            if (oFicha.getElementsByTagName("colorPImg") != null && oFicha.getElementsByTagName("colorPImg").length > 0) {
                if (oFicha.getElementsByTagName("colorPImg").item(0).lastChild != null && oFicha.getElementsByTagName("colorPImg").item(0).lastChild.nodeValue != null) {
                    loadImage(document.getElementById('imgVar_' + iProducto), oFicha.getElementsByTagName("colorPImg").item(0).lastChild.nodeValue, 0);
                }
                else if (oFicha.getElementsByTagName("colorPImg").item(0).text != null) {
                    loadImage(document.getElementById('imgVar_'  + iProducto), oFicha.getElementsByTagName("colorPImg").item(0).text, 0);
                }
            }

            var _periodotarifaid = 0

            if (oFicha.getElementsByTagName("periodotarifaid") != null && oFicha.getElementsByTagName("periodotarifaid").length > 0) {

                if (oFicha.getElementsByTagName("periodotarifaid").item(0).lastChild != null && oFicha.getElementsByTagName("periodotarifaid").item(0).lastChild.nodeValue != null) {
                    _periodotarifaid = oFicha.getElementsByTagName("periodotarifaid").item(0).lastChild.nodeValue;
                }
                else if (oFicha.getElementsByTagName("colorPid").item(0).text) {
                    _periodotarifaid = oFicha.getElementsByTagName("periodotarifaid").item(0).text;
                }

            }


            //document.getElementById(iProducto + '_anadir').innerHTML += "<input type=button id='anyadirCompra_" + iProducto + "' class=compra_but onclick=\"fAnyadirCompra('_" + iProducto + "','" + _productoTempId + "','" + sPrecioDescuento + "','" + monedaEst + "','anyadirCompra_" + iProducto + "','" + soloExperience + "','" + sPrecioAnt + "',"+ _periodotarifaid  +")\" />";
         
            var _bAnyadir = "<input type=button id='anyadirCompra_" + iProducto + "' class=compra_but  "

            if (!_agotado) {
                document.getElementById(iProducto + '_anadir').innerHTML += _bAnyadir + "onclick=\"fAnyadirCompra('_" + iProducto + "','" + _productoTempId + "','" + sPrecioDescuento + "','" + monedaEst + "','anyadirCompra_" + iProducto + "','" + soloExperience + "','" + sPrecioAnt + "'," + _periodotarifaid + ")\" />";
                document.getElementById(iProducto + '_wishlist').innerHTML = "<a style='cursor:pointer;' onclick=\"anyadirWishlist('_" + iProducto + "','" + _productoId + "','" + sPrecioDescuento + "','" + monedaEst + "','anyadirCompra_" + iProducto + "','" + soloExperience + "','" + sPrecioAnt + "')\">&nbsp;&nbsp;" + addWishList + "</a>";
            }
            else {
                document.getElementById(iProducto + '_anadir').innerHTML += _bAnyadir + " onclick=\" radalert('" + msgAgotado +"', 300, 200, '');\" />";

            }

             if (oFicha.getElementsByTagName("Composicion") != null && oFicha.getElementsByTagName("Composicion").length > 0) {
                if (oFicha.getElementsByTagName("Composicion").item(0).lastChild != null && oFicha.getElementsByTagName("Composicion").item(0).lastChild.nodeValue != null) {
                    //document.getElementById(iProducto + '_composicion').innerHTML += oFicha.getElementsByTagName("Composicion").item(0).lastChild.nodeValue;
                     document.getElementById(iProducto + '_descripcion').innerHTML += "<p>"+ oFicha.getElementsByTagName("Composicion").item(0).lastChild.nodeValue + "</p>";
                }
                else if (oFicha.getElementsByTagName("Composicion").item(0).text != null) {
                    //document.getElementById(iProducto + '_composicion').innerHTML += oFicha.getElementsByTagName("Composicion").item(0).text;
                    document.getElementById(iProducto + '_descripcion').innerHTML += "<p>"+ oFicha.getElementsByTagName("Composicion").item(0).text + "</p>";
                }
                else {
                    //document.getElementById(iProducto + '_composicion').innerHTML += ""
                }
            }

            try {
                if (oFicha.getElementsByTagName("Cuidados") != null && oFicha.getElementsByTagName("Cuidados").length > 0) {
                    if (oFicha.getElementsByTagName("Cuidados").item(0).lastChild != null && oFicha.getElementsByTagName("Cuidados").item(0).lastChild.nodeValue != null) {
                        //document.getElementById(iProducto + '_cuidados').innerHTML += oFicha.getElementsByTagName("Cuidados").item(0).lastChild.nodeValue;
                        document.getElementById(iProducto + '_descripcion').innerHTML += "<p>"+ oFicha.getElementsByTagName("Cuidados").item(0).lastChild.nodeValue + "</p>";
                    }
                    else if (oFicha.getElementsByTagName("Cuidados").item(0).text != null) {
                        //document.getElementById(iProducto + '_cuidados').innerHTML += oFicha.getElementsByTagName("Cuidados").item(0).text;
                        document.getElementById(iProducto + '_descripcion').innerHTML += "<p>"+ oFicha.getElementsByTagName("Cuidados").item(0).text + "</p>";
                    }
                    else {
                        //document.getElementById(iProducto + '_cuidados').innerHTML += ""
                    }
                }
            }
            catch (e) {
            }

            if (oFicha.getElementsByTagName("Referencia") != null && oFicha.getElementsByTagName("Referencia").length > 0) {
                if (oFicha.getElementsByTagName("Referencia").item(0).lastChild != null && oFicha.getElementsByTagName("Referencia").item(0).lastChild.nodeValue != null) {
                    document.getElementById(iProducto + '_descripcion').innerHTML += "<p>" + "Ref: " + oFicha.getElementsByTagName("Referencia").item(0).lastChild.nodeValue+"<p>";
                }
                else if (oFicha.getElementsByTagName("Referencia").item(0).text != null) {
                    document.getElementById(iProducto + '_descripcion').innerHTML += "<p>" + "Ref: " + oFicha.getElementsByTagName("Referencia").item(0).text+"</p>";
                }
                else {
                    document.getElementById(iProducto + '_descripcion').innerHTML += "<p>" + "Ref: "+"</p>";
                }
            }

            document.getElementById(iProducto + '_descripcionPop').innerHTML = document.getElementById(iProducto + '_descripcion').innerHTML

            document.getElementById(iProducto + '_recomendar').innerHTML = '<a style="cursor:pointer;" href="JavaScript:recomendarProducto(\'' + nombreEstilismo + '\',' + _productoTempId + ',' + zonaId + ',' + idiomaId + ',' + paisId + ',\'' + sPrecioDescuento   /*+ ' ' + monedaEst*/ + '\');">&nbsp;&nbsp;' + oFicha.getAttribute("RecomendarAmigo") + '</a>';

           // document.getElementById("viewzoom_" + iProducto).onclick = function () { openZoomMascotas(_productoTempId, idiomaId, zonaId, paisId, _estilismoId); }


        }
    }
    else {
        if (xmlDocResp.getElementsByTagName("raiz") != null && xmlDocResp.getElementsByTagName("raiz").length > 0) {
            var oResultado = xmlDocResp.getElementsByTagName("raiz").item(0);

            if (oResultado.getElementsByTagName("Error") != null && oResultado.getElementsByTagName("Error").length > 0) {
                if (oResultado.getElementsByTagName("Error").item(0).lastChild != null && oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue != null) {
                    MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue, "Default.aspx");
                }
                else if (oResultado.getElementsByTagName("Error").item(0).lastChild.text != null) {
                    MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.text, "Default.aspx");
                }
            }
        }
    }
}

/***************************************************
 **  Funciones genéricas ajax
 ***************************************************/

function crearInstanciaAjax() 
{
    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 crearInstanciaDOM() 
{
    var xmldom=false;
         
    try
    {
        xmldom=new ActiveXObject("Msxml2.DOMDocument"); 
    } 
    catch(e)
    { 
        try    
        {
            xmldom=new ActiveXObject("Microsoft.XMLDOM"); 
        } 
        catch(E) 
        { 
            xmldom=false; 
        } 
    } 

    converUTF8 = false;
    if (!xmldom && typeof XMLHttpRequest!='undefined') { 
        xmldom=document.implementation.createDocument("", "", null); 
        converUTF8=true;
    } 
        
    return xmldom; 
}

function crearInstanciaDOMResp(textResp) 
{
    var xmldom=false;
         
    try
    {
        xmldom=new ActiveXObject("Msxml2.DOMDocument");
        xmldom.loadXML(textResp) 
    } 
    catch(e)
    { 
        try    
        {
            xmldom=new ActiveXObject("Microsoft.XMLDOM"); 
            xmldom.loadXML(textResp)
        } 
        catch(E) 
        { 
            xmldom=false; 
        } 
    } 

    if (!xmldom && typeof XMLHttpRequest!='undefined') { 
        xmldom=document.implementation.createDocument("", "", null); 
        var parser = new DOMParser(); 
        xmldom = parser.parseFromString(textResp, "text/xml"); 
    } 
        
    return xmldom; 
}

function AjaxStockEntiendas(ldpId,tiendaId,divId,ref14){
    var http_request  = crearInstanciaAjax();
    var url = '../../ajax/cargaStock.aspx';
  
   if (!http_request){
        return false;
    }
     
    document.getElementById(divId).innerHTML = "Cargando stock...";
    http_request.open("GET", url + "?ldpId=" + ldpId + "&tiendaId=" + tiendaId  + "&ref14=" +ref14, false);
    http_request.send(null);
    
    var contenido = http_request.responseText;
    
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            
            if (!contenido) {
                document.getElementById(divId).innerHTML = "No se ha podido completar la petición. " + "<input type='button' id='but_" + ldpId + "' value='Reintentar' onclick=\"javascript:AjaxStockEntiendas(" + ldpId + "," + tiendaId + ", 'div_tiendas_" + ldpId + "'," + ref14 + ");\">";;
            }
            else{
                    document.getElementById(divId).innerHTML = contenido;
            }
        }
        else{
            document.getElementById(divId).innerHTML = "Se ha producido un error en la petición. " + "<input type='button' id='but_" + ldpId + "' value='Reintentar' onclick=\"javascript:AjaxStockEntiendas(" + ldpId + "," + tiendaId + ", 'div_tiendas_" + ldpId + "'," + ref14 + ");\">";;
        }
    }
    else{
        document.getElementById(divId).innerHTML = "La solicitu no ha podido ser completada. " + "<input type='button' id='but_" + ldpId + "' value='Reintentar' onclick=\"javascript:AjaxStockEntiendas(" + ldpId + "," + tiendaId + ", 'div_tiendas_" + ldpId + "'," + ref14 + ");\">";
    }
}





/***********************************************
************************************************
Bego nuevos métodos para compara estilismo

************************************************
************************************************/

function AjxDameNombreProducto(_productoTemporadaId,_campo) {
    var http_request = crearInstanciaAjax();
    var url = 'ajax/datosProductoIdioma.ashx';

    if (!http_request) {
        return false;
    }


    var xmlDoc = crearInstanciaDOM();

    if (!xmlDoc) {
        return false;
    }

    var date = new Date()
    var ticks = date.getTime()

    http_request.open("GET", url + "?PRODUCTOID=" + _productoTemporadaId + "&" + ticks, true);

    http_request.onreadystatechange = function () {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var _dato = http_request.responseText;

                if (_dato == null) {
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }

                document.getElementById(_campo).innerHTML = _dato;

            }
        }
    }

    http_request.send(null);
}


function AjxRecuperaPrecio(_productoId, _campo, _hsPrecioDescuento, _hmonedaEst, _hsoloExperience, _hsPrecioAnt, _hperiodotarifaid, _clienteLogado) {
    //fAnyadirCompra('_" + iProducto + "','" + _productoId + "',document.getElementById('sPrecioDescuento_" + iProducto + "').value,document.getElementById('monedaEst_" + iProducto + "').value,'anyadirCompra_" + iProducto + "',document.getElementById('soloExperience_" + iProducto + "').value,document.getElementById('sPrecioAnt_" + iProducto + "').value,document.getElementById('_periodotarifaid_" + iProducto + "').value)\" />";
//http_request.open("GET", url + "?ANYADIRCESTA=S&productoTemporadaId=" + productoTemporadaId + "&varianteId=" + varianteId + "&tallaid=" + tallaid + "&cantidad=1&precio=" + precio + "&moneda=" + moneda + "&butAnyadir=" + butAnyadir + "&soloExperience=" + soloExperience + "&sPrecioAnt=" + sPrecioAnt + "&periodotarifaId=" + periodotarifaId+"&" + ticks, true);

    var http_request = crearInstanciaAjax();
    var url = 'ajax/recuperaPrecio.ashx';
    if (!http_request) {
        alert("No se pudo realizar la llamada al servidor.");
        return false;
    }

    var date = new Date()
    var ticks = date.getTime()

    http_request.open("GET", url + "?PRODUCTOID=" + _productoId + "&PRECIO=S&CLIENTELOGADO=" + _clienteLogado + "&" + ticks, true);

    http_request.onreadystatechange = function () {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {


                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);

                if (!xmlDocResp) {
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = true;

                if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0) {
                    var oResultado = xmlDocResp.getElementsByTagName("resultado").item(0);

                    if (oResultado.getElementsByTagName("fichaProducto") != null && oResultado.getElementsByTagName("fichaProducto").length > 0) {
                        var oFicha = oResultado.getElementsByTagName("fichaProducto").item(0)

                        var sPrecioR = "";
                        var sTituloR = "";
                        var sPrecioDescuento = "";
                        var monedaEst = "";
                        var soloExperience = "N";
                        var sPrecioAnt = "";
                        if (oFicha.getElementsByTagName("Precio") != null && oFicha.getElementsByTagName("Precio").length > 0 && oFicha.getElementsByTagName("Moneda") != null && oFicha.getElementsByTagName("Moneda").length > 0) {
                            if (oFicha.getElementsByTagName("Moneda").item(0).lastChild != null && oFicha.getElementsByTagName("Moneda").item(0).lastChild.nodeValue != null) {
                                monedaEst = oFicha.getElementsByTagName("Moneda").item(0).lastChild.nodeValue
                            }
                            else if (oFicha.getElementsByTagName("Moneda").item(0).text != null) {
                                monedaEst = oFicha.getElementsByTagName("Moneda").item(0).text
                            }

                            var sPrecio = ""
                            if (oFicha.getElementsByTagName("Precio").item(0).lastChild != null && oFicha.getElementsByTagName("Precio").item(0).lastChild.nodeValue != null) {
                                sPrecio = oFicha.getElementsByTagName("Precio").item(0).lastChild.nodeValue
                            }
                            else if (oFicha.getElementsByTagName("Precio").item(0).text != null) {
                                sPrecio = oFicha.getElementsByTagName("Precio").item(0).text
                            }


                            _decimales = sPrecio.substring(sPrecio.length - 3, sPrecio.length - 2);
                            sPrecio = Math.round(parseFloat(sPrecio.replace(",", ".")));
                            sPrecio += _decimales + '00'

                            sPrecioAnt = sPrecio;



                            if (oFicha.getElementsByTagName("PrecioR") != null && oFicha.getElementsByTagName("PrecioR").length > 0) {

                                if (oFicha.getElementsByTagName("PrecioR").item(0).lastChild != null && oFicha.getElementsByTagName("PrecioR").item(0).lastChild.nodeValue != null) {
                                    sPrecioR = oFicha.getElementsByTagName("PrecioR").item(0).lastChild.nodeValue
                                }
                                else if (oFicha.getElementsByTagName("PrecioR").item(0).text != null) {
                                    sPrecioR = oFicha.getElementsByTagName("PrecioR").item(0).text
                                }

                                if (oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("TituloPrecioR") != null) {
                                    sTituloR = oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("TituloPrecioR")
                                }

                                sPrecio = sPrecioR
                                if (oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("soloExperienceR") == null || oFicha.getElementsByTagName("PrecioR").item(0).getAttribute("soloExperienceR") != "S") {
                                    soloExperience = "N";
                                }
                                else {
                                    soloExperience = "S";
                                }

                                _decimales = sPrecioR.substring(sPrecioR.length - 3, sPrecioR.length - 2);
                                sPrecioR = Math.round(parseFloat(sPrecioR.replace(",", ".")));
                                sPrecioR += _decimales + '00'


                            }

                            var sTituloD = "";
                            if (oFicha.getElementsByTagName("PrecioD") != null && oFicha.getElementsByTagName("PrecioD").length > 0) {

                                if (oFicha.getElementsByTagName("PrecioD").item(0).lastChild != null && oFicha.getElementsByTagName("PrecioD").item(0).lastChild.nodeValue != null) {
                                    sPrecioDescuento = oFicha.getElementsByTagName("PrecioD").item(0).lastChild.nodeValue
                                }
                                else if (oFicha.getElementsByTagName("PrecioD").item(0).text != null) {
                                    sPrecioDescuento = oFicha.getElementsByTagName("PrecioD").item(0).text
                                }

                                if (oFicha.getElementsByTagName("PrecioD").item(0).getAttribute("TituloPrecioD") != null) {
                                    sTituloD = oFicha.getElementsByTagName("PrecioD").item(0).getAttribute("TituloPrecioD")
                                }

                                _decimales = sPrecioDescuento.substring(sPrecioDescuento.length - 3, sPrecioDescuento.length - 2);
                                sPrecioDescuento = Math.round(parseFloat(sPrecioDescuento.replace(",", ".")));
                                sPrecioDescuento += _decimales + '00'


                            }
                            else {
                                sPrecioDescuento = sPrecio
                            }
                        }


                        var _periodotarifaid = 0

                        if (oFicha.getElementsByTagName("periodotarifaid") != null && oFicha.getElementsByTagName("periodotarifaid").length > 0) {

                            if (oFicha.getElementsByTagName("periodotarifaid").item(0).lastChild != null && oFicha.getElementsByTagName("periodotarifaid").item(0).lastChild.nodeValue != null) {
                                _periodotarifaid = oFicha.getElementsByTagName("periodotarifaid").item(0).lastChild.nodeValue;
                            }
                            else if (oFicha.getElementsByTagName("periodotarifaid").item(0).text) {
                                _periodotarifaid = oFicha.getElementsByTagName("periodotarifaid").item(0).text;
                            }

                        }


                        document.getElementById(_hsPrecioDescuento).value = sPrecioDescuento;
                        document.getElementById(_hmonedaEst).value = monedaEst;
                        document.getElementById(_hsoloExperience).value = soloExperience;
                        document.getElementById(_hsPrecioAnt).value = sPrecioAnt;
                        document.getElementById(_hperiodotarifaid).value = _periodotarifaid;

                        document.getElementById(_campo).innerHTML = sPrecioDescuento + " " + monedaEst;
                    }
                }
                else {
                    if (xmlDocResp.getElementsByTagName("raiz") != null && xmlDocResp.getElementsByTagName("raiz").length > 0) {
                        var oResultado = xmlDocResp.getElementsByTagName("raiz").item(0);

                        if (oResultado.getElementsByTagName("Error") != null && oResultado.getElementsByTagName("Error").length > 0) {
                            if (oResultado.getElementsByTagName("Error").item(0).lastChild != null && oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue != null) {
                                MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue, "Default.aspx");
                            }
                            else if (oResultado.getElementsByTagName("Error").item(0).lastChild.text != null) {
                                MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.text, "Default.aspx");
                            }
                        }
                    }
                }
            }
        }
    }
    http_request.send(null);
}

function AjxRecuperaColores(_productoId, _campo, _hVarianteId, _imgProd,_textColor, _hColorElegido) {
    
    var http_request = crearInstanciaAjax();
    var url = 'ajax/recuperaColores.ashx';
    if (!http_request) {
        alert("No se pudo realizar la llamada al servidor.");
        return false;
    }

    var date = new Date()
    var ticks = date.getTime()

    http_request.open("GET", url + "?PRODUCTOID=" + _productoId + "&COLOR=S&" + ticks, true);

    http_request.onreadystatechange = function () {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {


                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);

                if (!xmlDocResp) {
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = true;

                if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0) {
                    var oResultado = xmlDocResp.getElementsByTagName("resultado").item(0);

                    if (oResultado.getElementsByTagName("fichaProducto") != null && oResultado.getElementsByTagName("fichaProducto").length > 0) {
                        var oFicha = oResultado.getElementsByTagName("fichaProducto").item(0)


                        if (oFicha.getElementsByTagName("colores") != null && oFicha.getElementsByTagName("colores").length > 0) {
                            var oColores = oFicha.getElementsByTagName("colores").item(0);

                            if (oColores.getElementsByTagName("color") != null && oColores.getElementsByTagName("color").length > 0) {
                                for (var i = 0; i < oColores.getElementsByTagName("color").length; i++) {
                                    var oColor = oColores.getElementsByTagName("color").item(i);

                                    var _descColor = "";
                                    var _colorVarianteId = "";
                                    var _rgb_ruta = "";
                                    var _imagenDetalleV = ""; 
                                    var _imagenDetalleM = "";
                                    var _identificadorPantoneid = "";

                                    if (oColor.getElementsByTagName("descripcionColor").item(0).lastChild != null && oColor.getElementsByTagName("descripcionColor").item(0).lastChild.nodeValue != null) {
                                        _descColor = oColor.getElementsByTagName("descripcionColor").item(0).lastChild.nodeValue;
                                    }
                                    else if (oColor.getElementsByTagName("descripcionColor").item(0).text != null) {
                                        _descColor = oColor.getElementsByTagName("descripcionColor").item(0).text;
                                    }

                                    if (oColor.getElementsByTagName("colorVarianteId").item(0).lastChild != null && oColor.getElementsByTagName("colorVarianteId").item(0).lastChild.nodeValue != null) {
                                        _colorVarianteId = oColor.getElementsByTagName("colorVarianteId").item(0).lastChild.nodeValue;
                                    }
                                    else if (oColor.getElementsByTagName("colorVarianteId").item(0).text != null) {
                                        _colorVarianteId = oColor.getElementsByTagName("colorVarianteId").item(0).text;
                                    }

                                    if (oColor.getElementsByTagName("rgb_ruta").item(0).lastChild != null && oColor.getElementsByTagName("rgb_ruta").item(0).lastChild.nodeValue != null) {
                                        _rgb_ruta = oColor.getElementsByTagName("rgb_ruta").item(0).lastChild.nodeValue;
                                    }
                                    else if (oColor.getElementsByTagName("rgb_ruta").item(0).text != null) {
                                        _rgb_ruta = oColor.getElementsByTagName("rgb_ruta").item(0).text;
                                    }

                                    if (oColor.getElementsByTagName("imagenDetalleV").item(0).lastChild != null && oColor.getElementsByTagName("imagenDetalleV").item(0).lastChild.nodeValue != null) {
                                        _imagenDetalleV = oColor.getElementsByTagName("imagenDetalleV").item(0).lastChild.nodeValue;
                                    }
                                    else if (oColor.getElementsByTagName("imagenDetalleV").item(0).text != null) {
                                        _imagenDetalleV = oColor.getElementsByTagName("imagenDetalleV").item(0).text;
                                    }

                                    if (oColor.getElementsByTagName("imagenDetalleM").item(0).lastChild != null && oColor.getElementsByTagName("imagenDetalleM").item(0).lastChild.nodeValue != null) {
                                        _imagenDetalleM = oColor.getElementsByTagName("imagenDetalleM").item(0).lastChild.nodeValue;
                                    }
                                    else if (oColor.getElementsByTagName("imagenDetalleM").item(0).text != null) {
                                        _imagenDetalleM = oColor.getElementsByTagName("imagenDetalleM").item(0).text;
                                    }

                                    if (oColor.getElementsByTagName("identificadorPantoneid").item(0).lastChild != null && oColor.getElementsByTagName("identificadorPantoneid").item(0).lastChild.nodeValue != null) {
                                        _identificadorPantoneid = oColor.getElementsByTagName("identificadorPantoneid").item(0).lastChild.nodeValue;
                                    }
                                    else if (oColor.getElementsByTagName("identificadorPantoneid").item(0).text != null) {
                                        _identificadorPantoneid = oColor.getElementsByTagName("identificadorPantoneid").item(0).text;
                                    }

                                    if ((oColor.getElementsByTagName("tipo").item(0).lastChild != null && oColor.getElementsByTagName("tipo").item(0).lastChild.nodeValue != null && oColor.getElementsByTagName("tipo").item(0).lastChild.nodeValue == "C") || (oColor.getElementsByTagName("tipo").item(0).text != null && oColor.getElementsByTagName("tipo").item(0).text == "C")) {
                                        document.getElementById(_campo).innerHTML += '<span id="' + _campo + '_' + _colorVarianteId + '" style="background:#' + _rgb_ruta + ';cursor:pointer;border-bottom-color: #C4C1C1;border-bottom-style: solid;border-bottom-width: 1px;border-left-color-ltr-source: physical;border-left-color-rtl-source: physical;border-left-color-value: #C4C1C1;border-left-style-ltr-source: physical;border-left-style-rtl-source: physical;border-left-style-value: solid;border-left-width-ltr-source: physical;border-left-width-rtl-source: physical;border-left-width-value: 1px;border-right-color-ltr-source: physical;border-right-color-rtl-source: physical;border-right-color-value: #C4C1C1;    border-right-style-ltr-source: physical;    border-right-style-rtl-source: physical;border-right-style-value: solid;border-right-width-ltr-source: physical;border-right-width-rtl-source: physical;border-right-width-value: 1px;border-top-color: #C4C1C1;border-top-style: solid;border-top-width: 1px;float: left;height: 18px !important;margin-right: 6px;padding-bottom: 2px;padding-left: 2px;padding-right: 2px;    padding-top: 2px;width: 18px !important;" onmouseout="restaurarImagenColorEstilismoCompleto(\'' + _imgProd + '\', \'' + _hColorElegido + '\');" onmouseover="mostrarColorEstilismoCompleto(\'' + _imagenDetalleM + '\',\'' + _imgProd + '\');" onclick="seleccionaColorEstilismoCompleto(this.id,\'' + _campo + '\',\'' + _hVarianteId + '\',\'' + _imgProd + '\',\'' + _colorVarianteId + '\',\'' + _imagenDetalleM + '\',\'' + _textColor + '\',\'' + _descColor + '\', \'' + _hColorElegido + '\');"><img src=img/transparent.gif style="  height: 18px !important;width: 18px !important;" alt="' + _descColor + '" title="' + _descColor + '"/></span>';
                                    }
                                    else {
                                        document.getElementById(_campo).innerHTML += '<span id="' + _campo + '_' + _colorVarianteId + '" style="cursor:pointer;border-bottom-color: #C4C1C1;border-bottom-style: solid;border-bottom-width: 1px;border-left-color-ltr-source: physical;border-left-color-rtl-source: physical;border-left-color-value: #C4C1C1;border-left-style-ltr-source: physical;border-left-style-rtl-source: physical;border-left-style-value: solid;border-left-width-ltr-source: physical;border-left-width-rtl-source: physical;border-left-width-value: 1px;border-right-color-ltr-source: physical;border-right-color-rtl-source: physical;border-right-color-value: #C4C1C1;    border-right-style-ltr-source: physical;    border-right-style-rtl-source: physical;border-right-style-value: solid;border-right-width-ltr-source: physical;border-right-width-rtl-source: physical;border-right-width-value: 1px;border-top-color: #C4C1C1;border-top-style: solid;border-top-width: 1px;float: left;height: 18px !important;margin-right: 6px;padding-bottom: 2px;padding-left: 2px;padding-right: 2px;    padding-top: 2px;width: 18px !important;" onmouseout="restaurarImagenColorEstilismoCompleto(\'' + _imgProd + '\', \'' + _hColorElegido + '\');" onmouseover="mostrarColorEstilismoCompleto(\'' + _imagenDetalleM + '\',\'' + _imgProd + '\');" onclick="seleccionaColorEstilismoCompleto(this.id,\'' + _campo + '\',\'' + _hVarianteId + '\',\'' + _imgProd + '\',\'' + _colorVarianteId + '\',\'' + _imagenDetalleM + '\',\'' + _textColor + '\',\'' + _descColor + '\', \'' + _hColorElegido + '\');"><img src="' + _rgb_ruta + '" style="  height: 18px !important;width: 18px !important;" alt="' + _descColor + '" title="' + _descColor + '"/></span>';
                                    }

                                    if ((oColor.getElementsByTagName("esPrincipal").item(0).lastChild != null && oColor.getElementsByTagName("esPrincipal").item(0).lastChild.nodeValue != null && oColor.getElementsByTagName("esPrincipal").item(0).lastChild.nodeValue == "true") || (oColor.getElementsByTagName("tipo").item(0).text != null && oColor.getElementsByTagName("tipo").item(0).text == "true")) {
                                        document.getElementById(_campo + '_' + _colorVarianteId).click();
                                    }
                                }
                            }
                        }

                        if (oFicha.getElementsByTagName("colorPid") != null && oFicha.getElementsByTagName("colorPid").length > 0) {
                            var _colorPid = "";
                            var _colorPdesc = "";

                            if (oFicha.getElementsByTagName("colorPid").item(0).lastChild != null && oFicha.getElementsByTagName("colorPid").item(0).lastChild.nodeValue != null) {
                                _colorPid = oFicha.getElementsByTagName("colorPid").item(0).lastChild.nodeValue;
                            }
                            else if (oFicha.getElementsByTagName("colorPid").item(0).text) {
                                _colorPid = oFicha.getElementsByTagName("colorPid").item(0).text;
                            }

                            if (oFicha.getElementsByTagName("colorPdesc").item(0).lastChild != null && oFicha.getElementsByTagName("colorPdesc").item(0).lastChild.nodeValue != null) {
                                _colorPdesc = oFicha.getElementsByTagName("colorPdesc").item(0).lastChild.nodeValue;
                            }
                            else if (oFicha.getElementsByTagName("colorPdesc").item(0).text) {
                                _colorPdesc = oFicha.getElementsByTagName("colorPdesc").item(0).text;
                            }

                            //document.getElementById('sColorSelec_'+ iProducto).innerHTML = _colorPdesc
                            document.getElementById(_hVarianteId).value = _colorPid;
                            document.getElementById(_textColor).innerHTML = _colorPdesc;
                        }

                        if (oFicha.getElementsByTagName("colorPImg") != null && oFicha.getElementsByTagName("colorPImg").length > 0) {
                            if (oFicha.getElementsByTagName("colorPImg").item(0).lastChild != null && oFicha.getElementsByTagName("colorPImg").item(0).lastChild.nodeValue != null) {
                                loadImage(document.getElementById(_imgProd), oFicha.getElementsByTagName("colorPImg").item(0).lastChild.nodeValue, 0);
                            }
                            else if (oFicha.getElementsByTagName("colorPImg").item(0).text != null) {
                                loadImage(document.getElementById(_imgProd), oFicha.getElementsByTagName("colorPImg").item(0).text, 0);
                            }
                        }

                    }
                }
                else {
                    if (xmlDocResp.getElementsByTagName("raiz") != null && xmlDocResp.getElementsByTagName("raiz").length > 0) {
                        var oResultado = xmlDocResp.getElementsByTagName("raiz").item(0);

                        if (oResultado.getElementsByTagName("Error") != null && oResultado.getElementsByTagName("Error").length > 0) {
                            if (oResultado.getElementsByTagName("Error").item(0).lastChild != null && oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue != null) {
                                MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue, "Default.aspx");
                            }
                            else if (oResultado.getElementsByTagName("Error").item(0).lastChild.text != null) {
                                MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.text, "Default.aspx");
                            }
                        }
                    }
                }
            }
        }
    }
    http_request.send(null);
}

function AjxRecuperaTallas(_productoId, _campo, _hTallaId,_textTalla) {

    var http_request = crearInstanciaAjax();
    var url = 'ajax/recuperaTallas.ashx';
    if (!http_request) {
        alert("No se pudo realizar la llamada al servidor.");
        return false;
    }

    var date = new Date()
    var ticks = date.getTime()

    http_request.open("GET", url + "?PRODUCTOID=" + _productoId + "&TALLA=S&" + ticks, true);

    http_request.onreadystatechange = function () {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var xmlDocResp = crearInstanciaDOMResp(http_request.responseText);

                if (!xmlDocResp) {
                    alert("No se pudo crear el documento xml para procesar la respuesta.");
                    return false;
                }
                xmlDocResp.async = true;

                if (xmlDocResp.getElementsByTagName("resultado") != null && xmlDocResp.getElementsByTagName("resultado").length > 0) {
                    var oResultado = xmlDocResp.getElementsByTagName("resultado").item(0);

                    if (oResultado.getElementsByTagName("fichaProducto") != null && oResultado.getElementsByTagName("fichaProducto").length > 0) {
                        var oFicha = oResultado.getElementsByTagName("fichaProducto").item(0)


                        var _agotado = false;
                        var msgAgotado = ""
                        try {
                            if (oFicha.getElementsByTagName("agotado") != null && oFicha.getElementsByTagName("agotado").length > 0) {
                                if (oFicha.getElementsByTagName("agotado").item(0).lastChild != null && oFicha.getElementsByTagName("agotado").item(0).lastChild.nodeValue != null) {
                                    if (oFicha.getElementsByTagName("agotado").item(0).lastChild.nodeValue.length > 0) {
                                        _agotado = true;
                                        msgAgotado = oFicha.getElementsByTagName("agotado").item(0).lastChild.nodeValue;
                                    }

                                }
                                else if (oFicha.getElementsByTagName("agotado").item(0).text != null) {
                                    if (oFicha.getElementsByTagName("agotado").item(0).text.length > 0) {
                                        _agotado = true;
                                        msgAgotado = oFicha.getElementsByTagName("agotado").item(0).text;
                                    }
                                }

                            }
                        }
                        catch (e) {
                        }

                        var stalla = "<select id=selectTalla_" + _campo + " style=width:80px "

                        if (!_agotado) {
                            stalla += "onChange=seleccionaTallaEstilismoCompleto(this,'" + _hTallaId  + "','"+ _textTalla +"')";
                        }
                        else {
                            stalla += " disabled=true "
                        }

                        stalla += ">"


                        if (oFicha.getElementsByTagName("tallas") != null && oFicha.getElementsByTagName("tallas").length > 0) {
                            var otallas = oFicha.getElementsByTagName("tallas").item(0);

                            if (otallas.getElementsByTagName("talla") != null && otallas.getElementsByTagName("talla").length > 0) {
                                if (otallas.getElementsByTagName("talla").length > 1) {
                                    stalla += "<option value=0>" + otallas.getAttribute("etiqueta") + "</option>";
                                }
                                for (var i = 0; i < otallas.getElementsByTagName("talla").length; i++) {
                                    var otalla = otallas.getElementsByTagName("talla").item(i);

                                    var _tallaD = "";
                                    var _tallaId = "";

                                    if (otalla.getElementsByTagName("valuetalla").item(0).lastChild != null && otalla.getElementsByTagName("valuetalla").item(0).lastChild.nodeValue != null) {
                                        _tallaId = otalla.getElementsByTagName("valuetalla").item(0).lastChild.nodeValue;
                                    }
                                    else if (otalla.getElementsByTagName("valuetalla").item(0).text) {
                                        _tallaId = otalla.getElementsByTagName("valuetalla").item(0).text;
                                    }

                                    if (otalla.getElementsByTagName("texttalla").item(0).lastChild != null && otalla.getElementsByTagName("texttalla").item(0).lastChild.nodeValue != null) {
                                        _tallaD = otalla.getElementsByTagName("texttalla").item(0).lastChild.nodeValue;
                                    }
                                    else if (otalla.getElementsByTagName("texttalla").item(0).text) {
                                        _tallaD = otalla.getElementsByTagName("texttalla").item(0).text;
                                    }

                                    stalla += "<option value=" + _tallaId + ">" + _tallaD + "</option>";

                                    if (otallas.getElementsByTagName("talla").length == 1) {
                                        document.getElementById(_hTallaId).value = _tallaId;
                                        document.getElementById(_textTalla).innerHTML =" / " + _tallaD ;
                                    }
                                }
                            }
                            else {
                                stalla += "<option value=0>Tallas</option>";
                            }
                        }
                        else {
                            stalla += "<option value=0>Tallas</option>";
                        }
                        stalla += "</select>"
                        document.getElementById(_campo).innerHTML = stalla;

                       
                    }
                }
                else {
                    if (xmlDocResp.getElementsByTagName("raiz") != null && xmlDocResp.getElementsByTagName("raiz").length > 0) {
                        var oResultado = xmlDocResp.getElementsByTagName("raiz").item(0);

                        if (oResultado.getElementsByTagName("Error") != null && oResultado.getElementsByTagName("Error").length > 0) {
                            if (oResultado.getElementsByTagName("Error").item(0).lastChild != null && oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue != null) {
                                MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.nodeValue, "Default.aspx");
                            }
                            else if (oResultado.getElementsByTagName("Error").item(0).lastChild.text != null) {
                                MessageAndFrameRedirect(oResultado.getElementsByTagName("Error").item(0).lastChild.text, "Default.aspx");
                            }
                        }
                    }
                }
            }
        }
    }
    http_request.send(null);
}
