//esse arquivo é a versão de desenvolvimento não minimizada do arquivo
//após alterá-lo mudar ser nome funcoes_product.js e passa-lo pelo www.bananascript.com


// JScript File
//###############################################
// Funções utilizadas na pagina product.asp
// Desenvolvida por: Hélvio Júnior
// Data de Criação: 2007-08-16
// Data da Última alteração: 2007-08-16
//###############################################
//

//===============================================
// Variants
// Neste bloco de código estão todas as funções que se referem as variants
// Obs.: Não é neste bloco de código que estão definido as funções de imagens do produto, somente das variants

//Variaveis
var oListVariants = null;
var oListVariantsAttr1 = new Array();
var oListVariantsAttr2 = new Array();
var showVariantImages = false;
var listVariantIndex = 0;
var hasTwoVariants = false;
var ssku = "";
var defaultAttrValue1 = "";
var defaultAttrValue2 = "";
var cAjax = new Ajax();

//Função que terá como parametro o texto no padrão JSON, e define o objeto oListImages com este texto.
function setVariantList(jsonList, attrValue1, attrValue2, jsonList2){
    oListVariants = eval('(' + jsonList + ')');
    oAttrImages = jsonList2;
    listVariantIndex;
    
    
    if (oListVariants.length == 1) {
        setVariantDefaultIndex();
        setObjectList();
        montaVariantesComprar();
        
        montaPrecos();
    }
    else 
        if (oListVariants.length > 1) {
            setVariantDefaultIndex();
            setObjectList();
            montaVariantesComprar();
            montaPrecos();
        }
    
    if ((attrValue1 == 'null') || (attrValue1 == '')) {
        attrValue1 = null
    }
    if ((attrValue2 == 'null') || (attrValue2 == '')) {
        attrValue2 = null
    }
}


//Função que irá disparar todas as funções necessárias no momento da alteração da variant
function changeVariant(){
    setListVariantIndex();
    setImages(oListVariants[listVariantIndex].sku);
    montaVariantesComprar();
    montaPrecos();
    loadParcel('');
}

function setListVariantIndex(){
    var attr_value1 = "";
    var attr_value2 = "";
    
    if (document.getElementById('cboAttrValue1')) 
        attr_value1 = document.getElementById('cboAttrValue1').options[document.getElementById('cboAttrValue1').selectedIndex].value;
    
    if (document.getElementById('cboAttrValue2')) 
        attr_value2 = document.getElementById('cboAttrValue2').options[document.getElementById('cboAttrValue2').selectedIndex].value;
    
    for (i = 0; i < oListVariants.length; i++)
        if (oListVariants[i].attr_value1 == attr_value1.replace(/\"/gi, "&quot;") && oListVariants[i].attr_value2 == attr_value2.replace(/\"/gi, "&quot;")) {
            listVariantIndex = i;
            break;
        }
}

function montaPrecos(){

    var prod_price_text1 = "";
    
    if (oListVariants[listVariantIndex].on_sale) {
        prod_price_text1 = '<span class="font_cinza">de:</span> '
        prod_price_text1 += '<span class="font_cinza2">'
        prod_price_text1 += oListVariants[listVariantIndex].list_price
        prod_price_text1 += '</span>'
    }
    else {
        prod_price_text1 = ""
    }
    
    var titulo = "";
    
    titulo = oListVariants[listVariantIndex].name;
    
    if (oListVariants[listVariantIndex].Display_pf_id == "S") 
        titulo = titulo + '&nbsp;-&nbsp;' + oListVariants[listVariantIndex].pf_id
    
    if (oListVariants[listVariantIndex].attr_value1 != '' && !oListVariants[listVariantIndex].kit && oListVariants[listVariantIndex].attr_value1 != null) 
        titulo += "&nbsp;" + oListVariants[listVariantIndex].attr_value1
    
    if (oListVariants[listVariantIndex].attr_value2 != '' && !oListVariants[listVariantIndex].kit && oListVariants[listVariantIndex].attr_value2 != null) 
        titulo += "&nbsp;" + oListVariants[listVariantIndex].attr_value2
    
    var prod_price_text2 = "";
    var prod_price_text3 = "";
    
    if (oListVariants[listVariantIndex].on_sale) {
        if (oListVariants[listVariantIndex].parcelamento == "S" && oListVariants[listVariantIndex].parcela_semjuros > 1) {
            prod_price_text2 = '<span class="font_verde">'
            prod_price_text2 += 'Por: '
            prod_price_text2 += oListVariants[listVariantIndex].sale_price
            prod_price_text2 += '</span>&nbsp;'
            prod_price_text2 += '<span class="fontv1">'
            if (oListVariants[listVariantIndex].desconto_avista > 0) 
                prod_price_text2 += '(+ ' + oListVariants[listVariantIndex].desconto_avista + '% de desconto para pagamentos por boleto &agrave; vista)'
            
            prod_price_text2 += '</span>'
            prod_price_text3 = '<span class="font_cinza">';
            prod_price_text3 += '<img class="noborder" src="' + iTemplateFolder + '/bt_parcelamento.gif" onClick="showParcel();" style="cursor: pointer; float: right; margin-top:5px" border="0" alt="clique para visualizar as opções de parcelamento">'
            prod_price_text3 += '<span class="produto_vezes">ou ' + oListVariants[listVariantIndex].parcela_semjuros + 'x</span> '
            prod_price_text3 += '<span class="produto_preco">' + oListVariants[listVariantIndex].valor_venda + '</span>'
            
            prod_price_text3 += '</span>'
            prod_price_text3 += '</span>'
        }
        else {
            prod_price_text2 = '<span class="font_verde">Preço:</span><br />'
            prod_price_text2 += '<span class="font_verde_grande">'
            prod_price_text2 += oListVariants[listVariantIndex].valor_venda
            prod_price_text2 += '</span><br />'
        }
    }
    else {
        if (oListVariants[listVariantIndex].parcela_semjuros > 1 && oListVariants[listVariantIndex].parcelamento == "S") {
            prod_price_text2 = '<span class="font_verde">'
            prod_price_text2 += "Por: "
            prod_price_text2 += oListVariants[listVariantIndex].sale_price
            prod_price_text2 += '</span> '
            prod_price_text2 += '<span class="fontv1">'
            if (oListVariants[listVariantIndex].desconto_avista > 0) 
                prod_price_text2 += '(+ ' + oListVariants[listVariantIndex].desconto_avista + '% de desconto para pagamentos por boleto à vista)'
            prod_price_text2 += '</span>'
            prod_price_text3 = '<span class="font_cinza">';
            prod_price_text3 += '<img class="noborder" src="' + iTemplateFolder + '/bt_parcelamento.gif" onClick="showParcel();" style="cursor: pointer; float: right; margin-top:5px" border="0" alt="clique para visualizar as opções de parcelamento">'
            prod_price_text3 += '<span class="produto_vezes">ou ' + oListVariants[listVariantIndex].parcela_semjuros + 'x</span> '
            prod_price_text3 += '<span class="produto_preco">' + oListVariants[listVariantIndex].valor_venda + '</span>'
            prod_price_text3 += '</span>'
            prod_price_text3 += '</span>'
        }
        else {
            prod_price_text2 = '<span class="font_verde">Preço:</span><br />'
            prod_price_text2 += '<span class="font_verde_grande">'
            prod_price_text2 += oListVariants[listVariantIndex].valor_venda
            prod_price_text2 += '</span><br />'
        }
    }
    
    var bonus = '';
    bonus = 'Bônus: ' + oListVariants[listVariantIndex].bonus
    bonus += '<A href="javascript:;" onClick="AbrePop();"> <FONT class="linkV1">(O que é?) </FONT></A>';
    
    document.getElementById('prod_tit').innerHTML = titulo
	if(document.getElementById('price_text1'))
    document.getElementById('price_text1').innerHTML = prod_price_text1;
	if(document.getElementById('price_text2'))
    document.getElementById('price_text2').innerHTML = prod_price_text2;
	if(document.getElementById('price_text3'))
    document.getElementById('price_text3').innerHTML = prod_price_text3;
	if(document.getElementById('bonus'))
    document.getElementById('bonus').innerHTML = bonus;
}

function AbrePop(theURL, winName, features){
    window.open('../help_bonus.asp', '', 'width=300,height=450,toolbar=no,menubar=no,resizable=no,status=no,scrollbars=yes');
}

function setVenda(sku, attr_value1, attr_value2, temVariante){
    if (temVariante && (attr_value1 == 'null' || (attr_value2 == 'null' && hasTwoVariants))) {
        var HTMLErro = '<div class="erro_cor">É necessário selecionar '; //guarda o erro pelos atributos
        if (attr_value1 == 'null') 
            HTMLErro += oListVariants[0].attr_label1;
        
        if ((attr_value2 == 'null' && hasTwoVariants)) 
            if (attr_value1 == 'null') 
                HTMLErro += ' e ' + oListVariants[0].attr_label2;
            else 
                HTMLErro += oListVariants[0].attr_label2;
        
        HTMLErro += ' do seu produto</div>';
        
        document.getElementById("erro_cor").innerHTML = HTMLErro;
    }
    else {
        if (attr_value1 == 'null')
            attr_value1 = ''
         
        if (attr_value2 == 'null')
            attr_value2 = '' 
            
        document.frm_produto.sku.value = sku;
        document.frm_produto.attr_value1.value = attr_value1;
        document.frm_produto.attr_value2.value = attr_value2;
        document.frm_produto.submit();
    }
}

function setEncomenda(sku, attr_value1, attr_value2){
    if (sku == '') {
		var HTMLErro = '<div class="erro_cor">É necessário selecionar '; //guarda o erro pelos atributos
		if (attr_value1 == 'null') 
			HTMLErro += oListVariants[0].attr_label1;
		
		if ((attr_value2 == 'null' && hasTwoVariants)) 
			if (attr_value1 == 'null') 
				HTMLErro += ' e ' + oListVariants[0].attr_label2;
			else 
				HTMLErro += oListVariants[0].attr_label2;
		
		HTMLErro += ' do seu produto</div>';
		
		document.getElementById("erro_cor").innerHTML = HTMLErro;
	}
	else {
    document.getElementById('sku1').value = sku;
    document.prod_encomenda.submit();
}
}


//Efetua um loop em todos os registros das variants verificando qual é o default
function setVariantDefaultIndex(){
    for (i = 0; i < oListVariants.length; i++) {
        if (oListVariants[i].default_var) {
            listVariantIndex = i;
            defaultAttrValue1 = oListVariants[i].attr_value1;
            defaultAttrValue2 = oListVariants[i].attr_value2;
            break;
        }
    }
}

//Função que verifica se o um item existe no objeto
function exists(object, item, valor){
    var retorno = false;
    
    for (io = 0; io < object.length; io++) {
        if (object[io][item] == valor) {
            retorno = true;
            break;
        }
    }
    return retorno;
}

//Função que monta o objeto com os dados que irão para os combos
function setObjectList(){
    var lastImage = '';
    for (i = 0; i < oListVariants.length; i++) {
        if (!exists(oListVariantsAttr1, 'attr_value1', oListVariants[i].attr_value1)) {
            oListVariantsAttr1.push({
                attr_value1: oListVariants[i].attr_value1,
                attr_label1: oListVariants[i].attr_label1,
                pf_id: oListVariants[i].pf_id,
                default_var: oListVariants[i].default_var
            })
        }
        
        if (!exists(oListVariantsAttr2, 'attr_value2', oListVariants[i].attr_value2) && (oListVariants[i].attr_label2 != "" && oListVariants[i].attr_label2 != null)) {
            oListVariantsAttr2.push({
                attr_value2: oListVariants[i].attr_value2,
                attr_label2: oListVariants[i].attr_label2,
                pf_id: oListVariants[i].pf_id,
                default_var: oListVariants[i].default_var
            })
        }
        
        if (oAttrImages.length > 0) {
            showVariantImages = true;
        }
        
        lastImage = oListVariants[i].image_file;
    }
    
    //especifica que há 2 variantes nesse produto
    if (oListVariantsAttr2.length > 0) 
        hasTwoVariants = true;
}


/*
 * Função que monta o html das combos das variantes e o botão comprar
 */
function montaVariantesComprar(){
    var objVariants = document.getElementById('buttons');// a div que recebe o html gerado
    var defaultAttr = ""; //para ser consumido no primeiro atributo, contem o atributo padrão na hora da renderização da página
    var HTML = ''; // variável que guarda o html que está dentro da div buttons
    var V1OLD = ''; // variável de controle do loop do primeiro atributo
    var V2OLD = ''; // variável de controle do segundo atributo
    var selectedSku = ""; //guarda o sku selecionado
    var selectedAttrValue1 = null; //guarda o primeiro atributo selecionado
    var selectedAttrValue2 = null; //guarda o segundo atributo selecionado
    var selectedStock = true; //guarda a informação se a variante selecionada está em estoque
    var selected; //variável que seleciona a combo
    var temVariantes; //variável que guarda se o produto tem variantes ou não
    temVariantes = !((oListVariants[0].attr_label1 == '' || oListVariants[0].attr_label1 == null) && (oListVariants[0].attr_label2 == '' || oListVariants[0].attr_label2 == null));
    
	/*
	 * limpa a caixa de erros
	 */
	
	document.getElementById("erro_cor").innerHTML = '';
	
	
    /*
     * início da exibição da caixa das variantes
     */
    HTML += '<img src="' + iTemplateFolder + '/var_topo.gif" border="0" alt="Escolha aqui seu modelo"/>';
    HTML += '<table class="tab_variantes" cellspacing="0" cellpadding="3"><tbody>';
    
    if (temVariantes) {
        var htmlAttr1 = ''; //html do combo do atributo 1
        var htmlAttr2 = ''; //html do combo do atributo 2
        var temAttr1 = !(oListVariants[0].attr_label1 == '' || oListVariants[0].attr_label1 == null); // verifica se tem atributo 1
        var temAttr2 = !(oListVariants[0].attr_label1 == '' || oListVariants[0].attr_label2 == null); // verifica se tem atributo 2
        if (temAttr1) {
        
            if (document.getElementById('cboAttrValue1')) {
                selectedAttrValue1 = document.getElementById('cboAttrValue1').options[document.getElementById('cboAttrValue1').selectedIndex].value.replace(/\"/gi, "&quot;");
				if(selectedAttrValue1 == "")
				    selectedAttrValue1 = null;
			}
            
            htmlAttr1 += '<tr class="variantes_cor1">';
            htmlAttr1 += '<td align="center"><img src="' + iTemplateFolder + '/var_1.gif" border="0" alt="Passo 1"/></td>';
            htmlAttr1 += '<td>';
            
            htmlAttr1 += '<select name="cboAttrValue1" id="cboAttrValue1" onChange="changeVariant();">';
            htmlAttr1 += '<option value=""';
            if (selectedAttrValue1 == null) 
                htmlAttr1 += ' SELECTED ';
            htmlAttr1 += '>Escolha o ' + oListVariants[0].attr_label1 + '</option>';
        }
        
        if (temAttr2) {
        
            if (document.getElementById('cboAttrValue2')) {
                selectedAttrValue2 = document.getElementById('cboAttrValue2').options[document.getElementById('cboAttrValue2').selectedIndex].value.replace(/\"/gi, "&quot;");
				if (selectedAttrValue2 == "") 
					selectedAttrValue2 = null;
			}
            
            htmlAttr2 += '<tr class="variantes_cor2">';
            if (temAttr1) 
                htmlAttr2 += '<td align="center"><img src="' + iTemplateFolder + '/var_2.gif" border="0" alt="Passo 2"/></td>';
            else 
                htmlAttr2 += '<td align="center"><img src="' + iTemplateFolder + '/var_1.gif" border="0" alt="Passo 1"/></td>';
            htmlAttr2 += '<td>';
            
            htmlAttr2 += '<select name="cboAttrValue2" id="cboAttrValue2" onChange="changeVariant();">';
            htmlAttr2 += '<option value=""';
            if (selectedAttrValue2 == null) 
                htmlAttr2 += ' SELECTED ';
            htmlAttr2 += '>Escolha o ' + oListVariants[0].attr_label2 + '</option>';
            
        }
        
        var attr1Controle = ''; //variável de controle para a exibição do atributo 1
        var attr2Controle = ''; //variável de controle para a exibição do atributo 2
        for (i = 0; i < oListVariants.length; i++) {
            if (temAttr1) {
                if ((oListVariants[i].attr_value1 != attr1Controle || attr1Controle == '') && (oListVariants[i].attr_value2 == selectedAttrValue2 || selectedAttrValue2 == null)) {
                    var msgForaEstoque = ""; //variável que guarda a mensagem caso a variante esteja fora de estoque
                    var classForaEstoque = ""; //variável que guarda o estilo caso a variante esteja fora de estoque
                    if ((!temAttr2) && ((oListVariants[i].quantity <= 0 && oListVariants[i].VendeProdForaEstoque == "N") || (oListVariants[i].bloqueado == "P"))) {
                        msgForaEstoque = ' (Indisponível, avise-me quando chegar.)';
                        classForaEstoque = ' class="indisponivel" ';
                    }
                    
                    if (!temAttr2) {
                        htmlAttr1 += '<option value="' + oListVariants[i].attr_value1 + '"' + classForaEstoque
                        if (selectedAttrValue1 == oListVariants[i].attr_value1) 
                            htmlAttr1 += ' SELECTED ';
                        htmlAttr1 += '>';
                        htmlAttr1 += oListVariants[i].attr_value1 + msgForaEstoque;
                        htmlAttr1 += '</option>';
                    }
                    else {
                        if (oListVariants[i].attr_value2 == selectedAttrValue2 || selectedAttrValue2 == null) {
                            htmlAttr1 += '<option value="' + oListVariants[i].attr_value1 + '"' + classForaEstoque
                            if (selectedAttrValue1 == oListVariants[i].attr_value1) 
                                htmlAttr1 += ' SELECTED ';
                            htmlAttr1 += '>';
                            htmlAttr1 += oListVariants[i].attr_value1 + msgForaEstoque;
                            htmlAttr1 += '</option>';
                        }
                    }
                    attr1Controle = oListVariants[i].attr_value1;
                }
            }
            
            if (temAttr2) {
                if ((oListVariants[i].attr_value2 != attr2Controle || attr2Controle == '') && (oListVariants[i].attr_value1 == selectedAttrValue1)) {
                
                    var msgForaEstoque = ""; //variável que guarda a mensagem caso a variante esteja fora de estoque
                    var classForaEstoque = ""; //variável que guarda o estilo caso a variante esteja fora de estoque
                    if ((oListVariants[i].quantity <= 0 && oListVariants[i].VendeProdForaEstoque == "N") || (oListVariants[i].bloqueado == "P")) {
                        msgForaEstoque = ' (Indisponível, avise-me quando chegar.)';
                        classForaEstoque = ' class="indisponivel" ';
                    }
                    
                    htmlAttr2 += '<option value="' + oListVariants[i].attr_value2 + '"' + classForaEstoque
                    if (selectedAttrValue2 == oListVariants[i].attr_value2) 
                        htmlAttr2 += ' SELECTED ';
                    htmlAttr2 += '>';
                    htmlAttr2 += oListVariants[i].attr_value2 + msgForaEstoque;
                    htmlAttr2 += '</option>';
                    
                    attr2Controle = oListVariants[i].attr_value2;
                }
            }
            
            if (ifNull(oListVariants[i].attr_value1, "") == ifNull(selectedAttrValue1, "") && ifNull(oListVariants[i].attr_value2, "") == ifNull(selectedAttrValue2, "")) {
                selectedSku = oListVariants[i].sku;
                selectedStock = ((oListVariants[i].bloqueado == "P") || (oListVariants[i].quantity <= 0 && oListVariants[i].VendeProdForaEstoque == "S") || oListVariants[i].quantity > 0);
            }
        }
        
        
        if (temAttr1) {
            htmlAttr1 += '</select>';
            htmlAttr1 += '	</td>';
            htmlAttr1 += '</tr>';
        }
        
        if (temAttr2) {
            htmlAttr2 += '</select>';
            htmlAttr2 += '	</td>';
            htmlAttr2 += '</tr>';
        }
        
        HTML += htmlAttr1;
        HTML += htmlAttr2;
    }
    else {
        /*
         * como só há uma variante no objeto, pode ser pega a variante 0
         */
        selectedSku = oListVariants[0].sku;
        selectedStock = ((oListVariants[0].bloqueado == "P") || (oListVariants[0].quantity <= 0 && oListVariants[0].VendeProdForaEstoque == "S") || oListVariants[0].quantity > 0);
    }
    
    /*
     * fim área de exibição das variantes
     *
     * início exibição do botão comprar
     */
    HTML += '<tr>';
    
	if(temVariantes)
	    if (hasTwoVariants) 
	        HTML += '<td width="45" align="center"><img src="' + iTemplateFolder + '/var_3.gif" border="0" alt="Passo 3"/></td>';
	    else 
	        HTML += '<td width="45" align="center"><img src="' + iTemplateFolder + '/var_2.gif" border="0" alt="Passo 2"/></td>';
    else
		HTML += '<td width="45" align="center"></td>';
		
    HTML += '<td>';
    if (temVariantes) 
        if (selectedAttrValue1 == null || (selectedAttrValue2 == null && hasTwoVariants)) 
			if(((oListVariants[0].bloqueado == "P") || (oListVariants[0].product_quantity <= 0 && oListVariants[0].VendeProdForaEstoque == "S") || oListVariants[0].product_quantity > 0))
	            HTML += '	<a href="javascript:setVenda(\'' + selectedSku + '\',\'' + selectedAttrValue1 + '\',\'' + selectedAttrValue2 + '\',' + temVariantes + ');"><img src="' + iTemplateFolder + '/bt_comprar.gif" border="0" alt="Comprar"/></a>';
			else
				HTML += '	<a href="javascript:setEncomenda(\'\',\'' + selectedAttrValue1 + '\',\'' + selectedAttrValue2 + '\');"><img src="' + iTemplateFolder + '/bt_encomendar.gif" border="0" alt="clique para solicitar aviso quando o produto estiver disponivel"/></a>';
        else {
			 if(oListVariants[listVariantIndex].listadesejosFM == "S" && oListVariants[listVariantIndex].listadesejosGeral == "S") 
				 HTML += '	<a href="javascript:addLista(\'' + selectedSku + '\');"><img align="right" vspace="3" hspace="5" src="' + iTemplateFolder + '/bt_add_lista.gif" border="0" alt="Adicionar a lista" hspace="5"/></a>';
            
            if (selectedStock) 
                HTML += '	<a href="javascript:setVenda(\'' + selectedSku + '\',\'' + selectedAttrValue1 + '\',\'' + selectedAttrValue2 + '\',' + temVariantes + ');"><img src="' + iTemplateFolder + '/bt_comprar.gif" border="0" alt="Comprar"/></a>';
            else 
                HTML += '	<a href="javascript:setEncomenda(\'' + selectedSku + '\',\'\',\'\');"><img src="' + iTemplateFolder + '/bt_encomendar.gif" border="0" alt="clique para solicitar aviso quando o produto estiver disponivel"/></a>';
        }
    else {
		if(oListVariants[listVariantIndex].listadesejosFM == "S" && oListVariants[listVariantIndex].listadesejosGeral == "S") 
			HTML += '	<a href="javascript:addLista(\'' + selectedSku + '\');"><img align="right" vspace="3" hspace="5" src="' + iTemplateFolder + '/bt_add_lista.gif" border="0" alt="Adicionar a lista" hspace="5"/></a>';
        
        if (selectedStock) 
            HTML += '	<a href="javascript:setVenda(\'' + selectedSku + '\',\'' + selectedAttrValue1 + '\',\'' + selectedAttrValue2 + '\',' + temVariantes + ');"><img src="' + iTemplateFolder + '/bt_comprar.gif" border="0" alt="Comprar"/></a>';
        else 
            HTML += '	<a href="javascript:setEncomenda(\'' + selectedSku + '\');"><img src="' + iTemplateFolder + '/bt_encomendar.gif" border="0" alt="clique para solicitar aviso quando o produto estiver disponivel"/></a>';
        
    }
    HTML += '</td>';
    
    /* 
     * fim da área de exibição do botão comprar
     */
    HTML += '</tbody></table>';
    objVariants.innerHTML = HTML;
}

function ifNull(value1, value2){
	return (value1 == null ? value2: value1);
}


function selectComboItem(value2){
    var cboAttrValue1 = document.getElementById('cboAttrValue1')
    var cboAttrValue2 = document.getElementById('cboAttrValue2')
    
    if ((value2 != null) && (value2 != undefined) && (cboAttrValue2)) {
        for (i = 0; i < cboAttrValue2.options.length; i++) {
            if (cboAttrValue2.options[i].value == value2) {
                cboAttrValue2.options[i].selected = "selected";
                for (var i = 0; i < oListVariants.length; i++) {
                    if (oListVariants[i].attr_value2 == value2) 
                        if (document.getElementById(value2)) 
                            document.getElementById(value2).className = "prod_descr_img_mini_sel";
                        else 
                            if (document.getElementById(oListVariants[i].attr_value2)) 
                                document.getElementById(oListVariants[i].attr_value2).className = "prod_descr_img_mini";
                }
            }
        }
    }
    if ((value1) || (value2)) {
        if (cboAttrValue2) {
            comboClick('2', false);
        }
        else {
            comboClick('1', false);
        }
    }
}


function imgVarClick(sku){
    var iItem = getVariantIDByItem('sku', sku);
    if (iItem != -1) {
        selectComboItem(oListVariants[iItem].attr_value1, oListVariants[iItem].attr_value2);
    }
}

function comboClick(sku, nome){

    var iItem = getVariantIDByItem('sku', sku);
    listVariantIndex = iItem;
    changeVariant();
    montaPrecos();
}

function showAvaliacao(){
	
	var avaliacao = document.getElementById('avaliacao_produto')
	
	if (isIE()) {
		avaliacao.style.top = (iMouse.y - 115) + 'px';
		avaliacao.style.left = (iMouse.x - 580) + 'px';
	}else {
		avaliacao.style.top = (iMouse.y) + 'px';
		avaliacao.style.left = (iMouse.x - 430) + 'px';
	}

	avaliacao.style.display = (avaliacao.style.display == "block" ? "none" : "block") ;
	avaliacao.style.visibility = (avaliacao.style.visibility == "visible" ? "" : "visible");
	

}

// Fim Variants
//===============================================

