/* json para ie7 e ie6*/
if (!this.JSON) { JSON = function() { function f(n) { return n < 10 ? '0' + n : n } Date.prototype.toJSON = function() { return this.getUTCFullYear() + '-' + f(this.getUTCMonth() + 1) + '-' + f(this.getUTCDate()) + 'T' + f(this.getUTCHours()) + ':' + f(this.getUTCMinutes()) + ':' + f(this.getUTCSeconds()) + 'Z' }; var m = { '\b': '\\b', '\t': '\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\' }; function stringify(value, whitelist) { var a, i, k, l, r = /["\\\x00-\x1f\x7f-\x9f]/g, v; switch (typeof value) { case 'string': return r.test(value) ? '"' + value.replace(r, function(a) { var c = m[a]; if (c) { return c } c = a.charCodeAt(); return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16) }) + '"' : '"' + value + '"'; case 'number': return isFinite(value) ? String(value) : 'null'; case 'boolean': case 'null': return String(value); case 'object': if (!value) { return 'null' } if (typeof value.toJSON === 'function') { return stringify(value.toJSON()) } a = []; if (typeof value.length === 'number' && !(value.propertyIsEnumerable('length'))) { l = value.length; for (i = 0; i < l; i += 1) { a.push(stringify(value[i], whitelist) || 'null') } return '[' + a.join(',') + ']' } if (whitelist) { l = whitelist.length; for (i = 0; i < l; i += 1) { k = whitelist[i]; if (typeof k === 'string') { v = stringify(value[k], whitelist); if (v) { a.push(stringify(k) + ':' + v) } } } } else { for (k in value) { if (typeof k === 'string') { v = stringify(value[k], whitelist); if (v) { a.push(stringify(k) + ':' + v) } } } } return '{' + a.join(',') + '}' } } return { stringify: stringify, parse: function(text, filter) { var j; function walk(k, v) { var i, n; if (v && typeof v === 'object') { for (i in v) { if (Object.prototype.hasOwnProperty.apply(v, [i])) { n = walk(i, v[i]); if (n !== undefined) { v[i] = n } } } } return filter(k, v) } if (/^[\],:{}\s]*$/.test(text.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { j = eval('(' + text + ')'); return typeof filter === 'function' ? walk('', j) : j } throw new SyntaxError('parseJSON') } } } () }
/* conjunto generico */
function ConjuntoGenerico() { this.Tabela = new Array(); this.contem = ConjuntoGenerico_Contem; this.adiciona = ConjuntoGenerico_Adiciona; this.remove = ConjuntoGenerico_Remover; this.getChaves = ConjuntoGenerico_Chaves; this.getObjetos = ConjuntoGenerico_Objetos; this.tamanho = ConjuntoGenerico_Tamanho };
function ConjuntoGenerico_Contem(chave) { if (chave == null) { throw "NullPointerException {" + chave + "}"; }; if (this.Tabela[chave] != null) { return true }; return false };
function ConjuntoGenerico_Adiciona(chave, objeto) { if (chave == null || objeto == null) { throw "NullPointerException {" + chave + "},{" + objeto + "}" }; if (this.contem(chave)) { return }; this.Tabela[chave] = objeto };
function ConjuntoGenerico_Remover(chave) { if (chave == null) { throw "NullPointerException {" + chave + "}"; } var obj = this.Tabela[chave]; this.Tabela[chave] = null; return obj };
function ConjuntoGenerico_Chaves() { var chaves = new Array(); for (var chave in this.Tabela) { if (this.Tabela[chave] != null) { chaves.push(chave) } }; return chaves };
function ConjuntoGenerico_Objetos() { var objetos = new Array(); for (var chave in this.Tabela) { if (this.Tabela[chave] != null) { objetos.push(this.Tabela[chave]) } }; return objetos };
function ConjuntoGenerico_Tamanho() { var quantidade = 0; for (var chave in this.Tabela) { if (this.Tabela[chave] != null) { quantidade = quantidade + 1 } }; return quantidade };
/* gerenciador de acessorios */
function GerenciadorAcessorios(skuEscolhidoInicial) { this.acessorios = new ConjuntoGenerico(); this.getAcessorios = GerenciadorAcessorios_GetAcessorios; this.skuEscolhido = skuEscolhidoInicial; this.getSkuEscolhido = GerenciadorAcessorios_GetSkuEscolhido; this.setSkuEscolhido = GerenciadorAcessorios_SetSkuEscolhido; this.getPrecoTotal = GerenciadorAcessorios_GetPrecoTotal; this.getPrecoTotalAsString = GerenciadorAcessorios_GetPrecoTotalAsString; this.getTodosIds = GerenciadorAcessorios_GetTodosIds; this.formatarInteiro = GerenciadorAcessorios_FormatarInteiro };
function GerenciadorAcessorios_GetAcessorios() { return this.acessorios; };
function GerenciadorAcessorios_GetSkuEscolhido() { return this.skuEscolhido; };
function GerenciadorAcessorios_SetSkuEscolhido(novoSkuEscolhido) { this.skuEscolhido = novoSkuEscolhido; };
function GerenciadorAcessorios_GetPrecoTotal() { if (this.getSkuEscolhido() == null) { throw "NullPointerException {'Nenhum sku escolhido.'}" }; var precoTotal = this.getSkuEscolhido().getPreco(); if (this.getAcessorios().tamanho() > 0) { var skusAcessorios = this.getAcessorios().getObjetos(); for (var acessorio in skusAcessorios) { precoTotal += skusAcessorios[acessorio].getPreco() } }; return precoTotal };
function GerenciadorAcessorios_GetPrecoTotalAsString() { var totalFloat = this.getPrecoTotal(); var totalString = "" + totalFloat; var totalSplited = totalString.split("."); var inteiroString = "0"; if (totalSplited.length > 0) { inteiroString = totalSplited[0]; if (inteiroString.length > 3) { inteiroString = this.formatarInteiro(inteiroString) } }; var decimalString = "00"; if (totalSplited.length > 1) { decimalString = totalSplited[1]; if (decimalString.length == 1) { decimalString = decimalString + "0" } }; return inteiroString + "," + decimalString };
function GerenciadorAcessorios_GetTodosIds() { var todosIds = new Array(); if (this.getSkuEscolhido() == null) { throw "NullPointerException {'Nenhum sku escolhido.'}"; }; var skusAcessorios = this.getAcessorios().getObjetos(); for (var acessorio in skusAcessorios) { todosIds.push(skusAcessorios[acessorio].getId()) }; return todosIds };
function GerenciadorAcessorios_FormatarInteiro(inteiroString) { var inteiroStringLocal = inteiroString; var tokens = new Array(); var startToken = inteiroString; var lastStart = inteiroStringLocal.length; for (var i = inteiroString.length - 3; i >= 1; i = i - 3) { startToken = inteiroStringLocal.substring(0, i); var token = inteiroStringLocal.slice(i, lastStart); lastStart = i; tokens.push("." + token) }; for (var j = tokens.length - 1; j >= 0; j = --j) { startToken = startToken + tokens[j] }; return startToken };
/* sku */
function Sku(id, preco) { if (id == null || preco == null) { throw "NullPointerException {" + id + "},{" + preco + "}" }; this.id = id; this.getId = Sku_GetId; this.setId = Sku_SetId; this.preco = preco; this.getPreco = Sku_GetPreco; this.setPreco = Sku_SetPreco };
function Sku_GetId() { return this.id };
function Sku_SetId(novoId) { this.id = novoId };
function Sku_GetPreco() { return this.preco };
function Sku_SetPreco(novoPreco) { this.preco = novoPreco };
/* js interno pagina produto */
var gerAcessorios = null; var idSku = null;
function AcertaAoVoltar() { $(":checkbox").each(function(i) { var fncMarca = $(this).attr("onclick"); if (("" + fncMarca).search("MarcarCompra") > 0) { $(this).attr("checked", ""); } }) };
function ConfiguraControleAcessorios() { setIdFieldsetSelecaoSku(fieldsetselecaosku); if ($(".bt-comprar-indisponivel") == null) { return; }; btnComprarIntens = $(".bt-comprar-indisponivel"); idBotaoComprar = btnComprarIntens.attr("id"); btnComprarIntens.bind("click", ".bt-comprar-indisponivel", Produto_onClickBtnComprarItensSelecionado); if ($("#ctl00_Conteudo_listadesku") == null) { return }; atualizaPrecoAtualizadoItens(); AcertaAoVoltar(); };
function MarcarCompra(id, preco, addOrRemove) { var sku = new Sku(id, preco); if (addOrRemove) { if (!gerAcessorios.getAcessorios().contem(sku.getId())) { gerAcessorios.getAcessorios().adiciona(sku.getId(), sku) }; btnComprarIntens.removeClass("bt-comprar-indisponivel"); btnComprarIntens.addClass("bt-comprar-disponivel") } else { if (gerAcessorios.getAcessorios().contem(sku.getId())) { gerAcessorios.getAcessorios().remove(sku.getId()) }; if (gerAcessorios.getAcessorios().tamanho() == 0) { btnComprarIntens.removeClass("bt-comprar-disponivel"); btnComprarIntens.addClass("bt-comprar-indisponivel") } }; atualizaPrecoAtualizadoItens(null); };
//function atualizaPrecoAtualizadoItens(sku){if(gerAcessorios==null){CriarGerenciadorAcessorios()};if(sku!=null){alert(sku); gerAcessorios.setSkuEscolhido(sku)};var valor=gerAcessorios.getPrecoTotalAsString();valor=valor.replace(".","");valor=valor.replace(",",".");valor=FormataMoeda(valor);$("#precoAtual").text("R$ " + valor);if (document.getElementById("ctl00_Conteudo_Customizacao1_hddPrecoProdutoSelecionado") != null && typeof (document.getElementById("ctl00_Conteudo_Customizacao1_hddPrecoProdutoSelecionado")) != "undefined") { var precoCustomizacao = document.getElementById("ctl00_Conteudo_Customizacao1_hddPrecoProdutoSelecionado").value;if (precoCustomizacao == "") { precoCustomizacao = 0}; precoCustomizacao = precoCustomizacao.replace(".", "");precoCustomizacao = precoCustomizacao.replace(",", "."); valor = valor.replace(".", "");valor = valor.replace(",", "."); $("#precoAtual").text("R$ " + (parseFloat(valor) + parseFloat(precoCustomizacao)));} else { $("#precoAtual").text("R$ " + FormataMoeda(valor);} };
function atualizaPrecoAtualizadoItens(sku)
{
	if(gerAcessorios==null)
	{
		CriarGerenciadorAcessorios()
	};
	if(sku!=null){ gerAcessorios.setSkuEscolhido(sku) };
	var valor=gerAcessorios.getPrecoTotalAsString();
	valor = valor.replace(".","");
	valor = valor.replace(",",".");

	var precoCustomizacao = "0.00";
	var controleJason = document.getElementById("ctl00_Conteudo_Customizacao1_hddParamUrlProdutoCustomizado");
	if (controleJason != null && typeof (controleJason) != "undefined") {
		if (controleJason.value != null && controleJason.value != "") {
			//Converter o valor para objeto JSON
			json = eval('(' + controleJason.value + ')');
			//Varrer o array somando os valores de todos os grupos
			for (var i = 0; i < json.skuCustoms.length; i++) {
				var preco = json.skuCustoms[i].preco;
				preco = preco.replace(".", "");
				preco = preco.replace(",", ".");
				precoCustomizacao = parseFloat(preco) + parseFloat(precoCustomizacao);
			}
			valor = (parseFloat(valor) + parseFloat(precoCustomizacao));
		}
	}
	valor = Util.ArredondarFloat(valor);
	valor = Util.FormatarDinheiro(valor);
	$("#precoAtual").text("R$ " + valor);
};
function FormataMoeda(valor) { var strValor = valor.toString(); var len = strValor.length; if (!(len > 0)) { return "0,00"; }; var valorFormatado = ""; var stop = false; for (i = 0; i <= len; i++) { if (stop) { break; }; var c = strValor.substr(i, 1); if (c == ".") { var cont = 0; for (i++; i <= len; i++) { if (++cont <= 2) { c = strValor.substr(i, 1); valorFormatado += c; } else { stop = true }; if (stop) { break } } } else { valorFormatado += c } }; len = valorFormatado.length; var valorFinal = ""; if ((len <= 2)) { valorFinal = "0," + valorFormatado; }; if ((len > 2) && (len <= 5)) { valorFinal = valorFormatado.substr(0, len - 2) + ',' + valorFormatado.substr(len - 2, len) }; if ((len >= 6) && (len <= 8)) { valorFinal = valorFormatado.substr(0, len - 5) + '.' + valorFormatado.substr(len - 5, 3) + ',' + valorFormatado.substr(len - 2, len) }; if ((len >= 9) && (len <= 11)) { valorFinal = valorFormatado.substr(0, len - 8) + '.' + valorFormatado.substr(len - 8, 3) + '.' + valorFormatado.substr(len - 5, 3) + ',' + valorFormatado.substr(len - 2, len) }; if ((len >= 12) && (len <= 14)) { valorFinal = valorFormatado.substr(0, len - 11) + '.' + valorFormatado.substr(len - 11, 3) + '.' + valorFormatado.substr(len - 8, 3) + '.' + valorFormatado.substr(len - 5, 3) + ',' + valorFormatado.substr(len - 2, len) }; if ((len >= 15) && (len <= 17)) { valorFinal = valorFormatado.substr(0, len - 14) + '.' + valorFormatado.substr(len - 14, 3) + '.' + valorFormatado.substr(len - 11, 3) + '.' + valorFormatado.substr(len - 8, 3) + '.' + valorFormatado.substr(len - 5, 3) + ',' + valorFormatado.substr(len - 2, len) }; return valorFinal };
function Produto_onClickBtnComprarItensSelecionado(btnId) {
    var autorizacaoCompraCustomizada = true;
    var controleJason = document.getElementById("ctl00_Conteudo_Customizacao1_hddParamUrlProdutoCustomizado");
    if (controleJason != null && typeof (controleJason) != "undefined") {
        if (controleJason.value != null && controleJason.value != "") {
            autorizacaoCompraCustomizada = false;
            autorizacaoCompraCustomizada = confirm(__mensagemAlertaProdutoCustomizado);
        }
    }
    if (autorizacaoCompraCustomizada == false) { return false; };
    if (gerAcessorios.getAcessorios().tamanho() == 0 && (autorizacaoCompraCustomizada == false)) {
        return false
    };
    var LnkComprarItens = document.getElementById(btnId);
    var href = LnkComprarItens.href;
    if (gerAcessorios.getAcessorios().tamanho() > 0) {
        href += "," + gerAcessorios.getTodosIds()
    };
    LnkComprarItens.href = href;
    return true;
}
function onClickBtnComprar(btnId) { if (gerAcessorios.getAcessorios().tamanho() == 0) { return true }; var href = $("#" + btnId).attr("href"); href += "&idsAcessorios=" + gerAcessorios.getTodosIds(); $("#" + id).attr("href", href); return true };
$(document).ready(function() { CriarGerenciadorAcessorios(); ConfiguraVejaNestaPagina(); tabsProducDetails(); });
function CriarGerenciadorAcessorios() { idSku = document.getElementById(varIdSku).value; valor = parseFloat(document.getElementById(valorSku).value); gerAcessorios = new GerenciadorAcessorios(new Sku(idSku, valor)) };
function onEndRequest(sender, args) { CriarGerenciadorAcessorios(); ConfiguraControleAcessorios(); tb_init('a.thickbox, area.thickbox, input.thickbox , a.lnkPop'); tabs(); tabsProducDetails(); bnfFlags(); };
function comprar(url) { var result = confirm('O modelo selecionado Ã©: ' + document.getElementById(tResult).value + '\n\rColocar no carrinho?'); if (result) { document.location = url + '&source=' + escape(document.location) }; return result };
function comprarServico() { alert('O modelo selecionado é: ' + document.getElementById(tResult).value + '.\n\r') };
function comprarGarantia() { alert('O modelo selecionado é: ' + document.getElementById(tResult).value + '.\n\r') };
function verificaCheckBoxAvisoGarantiaEstendida() { var oCheckBox = document.getElementById(idOCheckBox); if (!oCheckBox.checked) { alert("O regulamento deve ser lido e aceito."); return false }; return true };
function adicionarListaCasamento() { var result = confirm('O modelo selecionado é: ' + document.getElementById(tResult).value + '\n\rColocar na lista de casamento?'); return result };
function tabs() { $('body.sku .tabs').each(function() { $(this).next().children().css("display", 'none'); $('a', this).click(function() { $(this).parents("ul").children("li").removeClass("selected"); $(this).parent("li").addClass("selected"); $(this).parents("ul").next().children("li").removeClass("selected"); var idArray = $(this).attr("href").split("#"); var id = idArray[1]; $("#" + id).addClass("selected").css('display', 'block'); $(this).parents("ul").next().children("li").css("display", 'none'); $(this).parents("ul").next().children('li.selected').css("display", 'block'); return false; }); }); $("#produto ul.tabsCont .tit").css("display", 'none'); $("#produto ul.tabsCont li.tabCont.selected").css("display", 'block'); $("#produto .tabs").css('display', 'block') };
function tabsProducDetails() { if (abasDetalhesProdutoAtiva == 1) { var numDetalhes = 1; $('body.sku .detalhesProduto .caracteristicasGerais').each(function() { $(this).wrapInner("<ul class=\"tabsCont\"></ul>"); var liTabs = ""; var contadorAbas = 1; $("h3", this).each(function() { if (contadorAbas == 1) { var selecionado = "selected"; } else { var selecionado = ""; }; liTabs += "<li class=\"" + selecionado + "\"><a href=\"#tab" + numDetalhes + "" + contadorAbas + "\">" + $(this).html() + "</a></li>"; $(this).parent().wrap("<li id=\"tab" + numDetalhes + "" + contadorAbas + "\" class=\"tabCont " + selecionado + "\"></li>"); contadorAbas++; }); $(this).prepend("<ul class=\"tabs\">" + liTabs + "</ul>"); numDetalhes++; }); tabs(); } };


var Util =
{
    BuscarElemento: function(id) {
        return document.getElementById(id);
    },
    RemoverCifrao: function(texto) {
        var novoTexto;
        //Se for um número
        if (!isNaN(texto)) {
            novoTexto = texto;
        }
        else {
            if (texto.indexOf("R$") >= 0) {
                novoTexto = texto.replace("R$", "");
            } else {
                novoTexto = texto;
            }
        }
        return Util.Trim(novoTexto);
    },
    RemoverPonto: function(texto) {
        var novoTexto;
        //Se for um número
        if (!isNaN(texto)) {
            novoTexto = texto;
        }
        else {
            if (texto.indexOf(".") >= 0) {
                novoTexto = texto.replace(".", "");
            } else {
                novoTexto = texto;
            }
        }
        return Util.Trim(novoTexto);
    },
    TrocarVirgulaPorPonto: function(texto) {
        var novoTexto;
        //Se for um número
        if (!isNaN(texto)) {
            novoTexto = texto;
        }
        else {
            if (texto.indexOf(",") >= 0) {
                novoTexto = texto.replace(",", ".");
            } else {
                novoTexto = texto;
            }
        }
        return Util.Trim(novoTexto);
    },
    ConverterParaFloat: function(texto) {
        texto = this.RemoverCifrao(texto);
        texto = this.RemoverPonto(texto);
        texto = this.TrocarVirgulaPorPonto(texto);
        return parseFloat(texto);
    },
    SomarValoresFloat: function(valor1, valor2) {
        return this.ConverterParaFloat(valor1) + this.ConverterParaFloat(valor2);
    },
    SubtrairValoresFloat: function(valor1, valor2) {
        return this.ConverterParaFloat(valor1) - this.ConverterParaFloat(valor2);
    },
    VerificarSeNulo: function(elemento) {
        if (elemento == null || typeof (elemento) == "undefined") {
            return true;
        }
        return false;
    },
    Trim: function(text) {
        return text.replace(/^\s+|\s+$/g, "");
    },
    Ltrim: function(text) {
        return text.replace(/^\s+/, "");
    },
    Rtrim: function(text) {
        return text.replace(/\s+$/, "");
    },
    CheckIfSelected: function(idRadio, idHidden) {
        var radio = Util.BuscarElemento(idRadio);
        var hidden = Util.BuscarElemento(idHidden);
        if (!Util.VerificarSeNulo(radio)) {
            if (!Util.VerificarSeNulo(hidden)) {
                return (hidden.value == idRadio);
            }
        }
    },
    FormatarDinheiro2: function(mnt) {
        mnt -= 0;
        mnt = (Math.round(mnt * 100)) / 100;
        return (mnt == Math.floor(mnt)) ? mnt + ',00'
                  : ((mnt * 10 == Math.floor(mnt * 10)) ?
                           mnt + '0' : mnt);
    },
    FormatarDinheiro: function(valor) {
        return this.NumberFormat(valor, 2, ',', '.');
    },
    NumberFormat: function(number, decimals, dec_point, thousands_sep) {
        // *     example 1: number_format(1234.56);
        // *     returns 1: '1,235'
        // *     example 2: number_format(1234.56, 2, ',', ' ');
        // *     returns 2: '1 234,56'
        // *     example 3: number_format(1234.5678, 2, '.', '');
        // *     returns 3: '1234.57'
        // *     example 4: number_format(67, 2, ',', '.');
        // *     returns 4: '67,00'
        // *     example 5: number_format(1000);
        // *     returns 5: '1,000'
        // *     example 6: number_format(67.311, 2);
        // *     returns 6: '67.31'
        // *     example 7: number_format(1000.55, 1);
        // *     returns 7: '1,000.6'
        // *     example 8: number_format(67000, 5, ',', '.');
        // *     returns 8: '67.000,00000'
        // *     example 9: number_format(0.9, 0);
        // *     returns 9: '1'
        // *     example 10: number_format('1.20', 2);
        // *     returns 10: '1.20'
        // *     example 11: number_format('1.20', 4);
        // *     returns 11: '1.2000'
        // *     example 12: number_format('1.2000', 3);
        // *     returns 12: '1.200'
        var n = number, prec = decimals;

        var toFixedFix = function(n, prec) {
            var k = Math.pow(10, prec);
            return (Math.round(n * k) / k).toString();
        };

        n = !isFinite(+n) ? 0 : +n;
        prec = !isFinite(+prec) ? 0 : Math.abs(prec);
        var sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep;
        var dec = (typeof dec_point === 'undefined') ? '.' : dec_point;

        var s = (prec > 0) ? toFixedFix(n, prec) : toFixedFix(Math.round(n), prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;

        var abs = toFixedFix(Math.abs(n), prec);
        var _, i;

        if (abs >= 1000) {
            _ = abs.split(/\D/);
            i = _[0].length % 3 || 3;

            _[0] = s.slice(0, i + (n < 0)) +
          _[0].slice(i).replace(/(\d{3})/g, sep + '$1');
            s = _.join(dec);
        } else {
            s = s.replace('.', dec);
        }

        var decPos = s.indexOf(dec);
        if (prec >= 1 && decPos !== -1 && (s.length - decPos - 1) < prec) {
            s += new Array(prec - (s.length - decPos - 1)).join(0) + '0';
        }
        else if (prec >= 1 && decPos === -1) {
            s += dec + new Array(prec).join(0) + '0';
        }
        return s;
    },
    SetarValorHidden: function(hddId, value) {
        var hdd = Util.BuscarElemento(hddId);
        if (!Util.VerificarSeNulo(hdd)) {
            hdd.value = value;
        }
    },
    BuscarValorHidden: function(hddId) {
        var hdd = Util.BuscarElemento(hddId);
        if (!Util.VerificarSeNulo(hdd)) {
            return hdd.value;
        }
        return null;
    },
    RemoverSelecaoRadio: function(idRadio) {
        var radio = Util.BuscarElemento(idRadio);
        if (!Util.VerificarSeNulo(radio)) {
            if (radio.checked) {
                radio.checked = false;
            }
        }
    },
    QueryString: function(ID, paramUrl) {
        //var URL = document.location.href;
        var URL = paramUrl;
        if (URL.indexOf('?' + ID + '=') > -1) {
            var qString = URL.split('?');
            var keyVal = qString[1].split('&');
            for (var i = 0; i < keyVal.length; i++) {
                if (keyVal[i].indexOf(ID + '=') == 0) {
                    var val = keyVal[i].split('=');
                    return val[1];
                }
            }
            return "";
        }
        else {
            return "";
        }
    },
    ArredondarFloat: function(valor) {
        if (valor.toString().indexOf('.') >= 0) {
            var valorSplit = valor.toString().split('.');
            if (valorSplit.length == 2) {
                if (valorSplit[1].length > 2) {
                    return parseFloat(valorSplit[0] + '.' + valorSplit[1].substring(0, 2));
                }
            }
        }
        return parseFloat(valor.toString());
    }
};

//DropDownList Garantia Estendida
function OnIndexChangeGarantiaEstendida(ctrlDropDownList, ctrlButton, codOrigemGES) {
    var ddlGarantia = document.getElementById(ctrlDropDownList);
    var btnComprar = document.getElementById(ctrlButton);

    if (ddlGarantia != null && btnComprar != null) {
        var idSkuServico = ddlGarantia.options[ddlGarantia.selectedIndex].value;
        if (idSkuServico > 0)
            btnComprar.href = 'http://carrinho.' + document.domain + '/Site/Carrinho.aspx?codOrigemGES=' + codOrigemGES + '&IdSku=' + idSku + '&IdSkuServico=' + idSkuServico;
        else
            btnComprar.href = 'http://carrinho.' + document.domain + '/Site/Carrinho.aspx?IdSku=' + idSku;

        //btnComprar.setAttribute('onClick', 'comprarGarantia();return verificaCheckBoxAvisoGarantiaEstendida();');        
    }
}
