var vai = null;var pagina = function(a){$('pagina').value = a;$('subm').click();};function relocar(a){document.location = a;clearInterval(vai);vai = 1;}function AdicionarProduto(id,obj){if(obj.checked == true){olink = "adicionar";$('s'+id).innerHTML = 'Está na cesta';}else{olink = "removerProdutoId";$('s'+id).innerHTML = 'Colocar na cesta';}olink = "?cesta=1&parar=1&"+olink+"="+id;if($("preload")){b = document.getElementById("iframe");if(b){$("iframe").src = olink;}else{$("preload").innerHTML += "<iframe id='iframe' name='iframe' src='"+olink+"'></iframe>";}}}function fechar_imagem(){document.getElementById("preto").style.display = "none";document.getElementById("preto2").style.display = "none";document.getElementById("area_principal").style.display = "";document.getElementById("rodape").style.display = "";if(document.getElementById("banner_topo")){document.getElementById("banner_topo").style.display = "";}if(document.getElementById("fl_topo")){document.getElementById("fl_topo").style.display = "";}}function popup_imagem(url){document.getElementById("preto").style.display = "";document.getElementById("preto2").style.display = "";document.getElementById("area_principal").style.display = "none";document.getElementById("rodape").style.display = "none";if(document.getElementById("banner_topo")){document.getElementById("banner_topo").style.display = "none";}if(document.getElementById("fl_topo")){document.getElementById("fl_topo").style.display = "none";}}function ver(obj){if($(obj)){if($(obj).style.display == 'none'){$(obj).style.display = '';}else{$(obj).style.display = 'none';}}}function Sobre_Imagem(a){if($(a)){if($("preload")){$("preload").innerHTML += "<img src='"+$(a).src.replace(".jpg","_on.jpg")+"' alt='Preload'>";}$(a).onmouseover = function(){this.src = this.src.replace(".jpg","_on.jpg");};$(a).onmouseout = function(){this.src = this.src.replace("_on.jpg",".jpg");};}}function Sobre_ImagemSrc(fonte){ourl = "";imagens = document.getElementsByTagName('img');for(var i=0;i<imagens.length;i++){if(imagens[i].src.indexOf(fonte) > -1){ourl = imagens[i].src;imagens[i].onmouseover = function(){this.src = this.src.replace(".jpg","_on.jpg");this.src = this.src.replace(".gif","_on.gif");};imagens[i].onmouseout = function(){this.src = this.src.replace("_on.jpg",".jpg");this.src = this.src.replace("_on.gif",".gif");};}}if(ourl != ""){if($("preload")){$("preload").innerHTML += "<img src='"+ourl.replace(".","_on.")+"' alt='Preload'>";}}}function KeyUpCalculoTransporte(obj){obj.value = obj.value.replace(/[^0-9]/gi,'');if(obj.value.length>7){CalculaTransporte(obj.value);}}function RecebeFreteMenor(valor){if(valor == "gratis"){d = $("valor_total").value.replace(",",".");$("total").innerHTML = "R$" + Moeda(d);$("total_frete").innerHTML = "Grátis";}else{if(valor == "cep invalido"){$("total_frete").innerHTML = "CEP inválido.";}else{if(valor != "indisponivel"){valor = Moeda(valor);$("total_frete").innerHTML = "R$" + valor + "";d = $("valor_total").value.replace(",",".");v = valor.replace(",",".");t = ((Number(d)*100)+(Number(v)*100))/100;$("total").innerHTML = "R$" + Moeda(t);}else{$("total_frete").innerHTML = "Indisponível";}}}}function Moeda(valor){if(valor < 0){valor *= -1;}valor = ("" +((valor*100)/100)).replace('.',',');if(valor.lastIndexOf(',') == -1){valor += ",00";}if(valor.lastIndexOf(',') == valor.length-2){valor += "0";}if(valor.lastIndexOf(',')<valor.length-3){valor = valor.substring(0,valor.lastIndexOf(',')+3);}return valor;}function KeyUpQtdP(obj){obj.value = Number(obj.value.replace(/[^0-9]/gi,''));$("atualiza").style.display = 'block';}function Mudou_Opcao_Observacao(texto){$("novo_preco").innerHTML = texto;}function Mudou_Opcao(){selects = document.getElementsByTagName("select");total = 0;obs = "";  for(var i=0; i<selects.length; i++){j = selects[i].selectedIndex;valor = selects[i].options[j].value;reais = valor.substring(1);texto = selects[i].options[j].text;if(reais != ""){reais = parseInt(reais);}else{reais = 0;}if(valor.charAt(0) == "+"){total += reais;}if(valor.charAt(0) == "-"){total -= reais;}if(selects[i].options[j].title!=""){obs = selects[i].options[j].title;}}if(total > 0){$("novo_preco").innerHTML = '<span class="textoInternoPreco2">Acrescimo de ';}if(total < 0){$("novo_preco").innerHTML = '<span class="textoInternoPreco2">Desconto de ';}if(total != 0){pp = parseFloat($("guarda_preco").value.replace(",","."))*100;ptotal = parseFloat(total)*100;tpreco = pp + ptotal;tpreco /= 100;$("novo_preco").innerHTML += '</span><span class="textoInternoPreco1">R$' + Moeda(total) + '</span><span class="textoInternoPreco2"> Totalizando: </span><span class="textoInternoPreco1">R$' + Moeda(tpreco);$("novo_preco").innerHTML += "</span>";}else{$("novo_preco").innerHTML = "";}if(obs!=""){$("novo_preco").innerHTML += '<br/><br/><span class="textoInternoPreco1">'+obs+'</span>';}}function comprar(url){saida = "";variaveis = "";selects = document.getElementsByTagName("select");cont = "";for(var i=0; i<selects.length; i++){j = selects[i].selectedIndex;valor = selects[i].options[j].value;texto = selects[i].options[j].text;oitem = selects[i].id.substring(3);if(texto == "Selecione"){if(selects[i].options.length == 2){selects[i].selectedIndex++;Mudou_Opcao();}else{saida = "Voce deve selecionar as características do produto primeiro.";}}if(texto.indexOf(" - Esgotado") > -1){cont = "&esgotado=1";}texto = texto.replace(" - Esgotado","");variaveis += oitem + "+..+" + texto + "|||";}if(saida != ""){alert(saida);}else{if(variaveis != "" && variaveis != null){window.location = url + "?personalizacao=" + variaveis + cont;}else{window.location = url + cont;}}}function RastreiaEntrega(cod,retorno){cod = cod.replace(" ","");$(retorno).innerHTML = "tentando";}function XML(url){ if(window.XMLHttpRequest){var Loader = new XMLHttpRequest(); Loader.open("GET", url ,false); Loader.send(null); return Loader.responseXML; }else if(window.ActiveXObject){ var Loader = new ActiveXObject("Msxml2.DOMDocument.3.0"); Loader.async = false; Loader.load(url); return Loader;}}function rastro(p){$("if").innerHTML = p;}var aguardo = null;function PrazoDeRetorno(){aguardo = setInterval("JaDeu();",1000);}function JaDeu(){clearInterval(aguardo);if($("if").innerHTML == "Procurando o envio nos site dos Correios..."){$("if").innerHTML = 'Site dos Correios não responde. Tente clicar no botão acima, para abrir o site dos Correios pessoalmente.';}else{}}function Input_Especial(quais){if(quais=="todos"){input = document.getElementsByTagName("input");for(var i=0;i<input.length;i++){if(input[i].type == "text" || input[i].type == "password"){if(input[i].className != "normal"){if(input[i].id.indexOf("preco") == 0){input[i].onblur = function (){PrecoBlur(this);this.className = "input_comum";};input[i].onkeyup = function (){PrecoKeyUp(this);};}else{input[i].onblur = function(){this.className = "input_comum";};}input[i].onfocus = function(){this.className = "input_comum_sobre";}; }}if(input[i].id == "cepOrigem"){CriarCookie("cep","",1);input[i].onkeyup = function () {if(LerCookie("cep")!=this.value && this.value.length>0){this.value = this.value.replace(/[^0-9]/gi,'');if(this.value.length > 7){this.value = this.value.substring(0,8);CriarCookie("cep",this.value,1);if($("MSG"+this.id)){$("MSG"+this.id).innerHTML = "Por favor, aguarde...";}Lcep(this.value);}}}}}}}function LimpaString(a){return a.replace(/[&;]/gi,'');}function PrecoBlur(obj){PrecoKeyUp(obj);a = obj.value;if(a.indexOf(',') == -1){if(a.length == 0){a = "0,00";}else{a += ",00";}}else{a += "00";a = a.slice(0,a.indexOf(",")+3);}if(a.indexOf(',') == 0){a = "0" + a;}obj.value = a;}var ultimo_obj;var ultimo_valor;function PrecoKeyUp(obj){if(ultimo_obj == obj && ultimo_valor == obj.value){return 0;}a = obj.value.replace(/[^0-9|.,]/gi,'').replace(/[.]/gi,',');total_virgulas = 0;b = "";for(var i=0; i<a.length; i++){if(a.charAt(i) == ","){if(total_virgulas == 0){if(a.length == 1){b+= "0";}b += a.charAt(i);}total_virgulas++;}else{if(total_virgulas == 0){if(b.length<6){b += a.charAt(i);}}else{if(b.length<9){b += a.charAt(i);}}}}obj.value = b.replace(/[:]/gi,',');ultimo_obj = obj;ultimo_valor = obj.value;}erro = new Array();erro['email'] = "Desculpe, mas o e-mail deve ser v"+String.fromCharCode(225)+"lido.";erro['str'] = "Desculpe, este campo dever ser v"+String.fromCharCode(225)+"lido.";erro['num'] = "Desculpe, mas este campo obrigatorio aceita apenas numeros.";erro['preco'] = "Desculpe, mas é obrigatório por um preço.";erro['string'] = erro['str'];erro['texto2'] = erro['str'];erro['texto'] = erro['str'];erro['integer'] = erro['num'];erro['cep'] = "Desculpe, o CEP deve ter 8 numeros.";erro['telefone'] = "Desculpe, coloque o DDD seguido do numero do telefone.";erro['cnpj'] = "Desculpe, o CNPJ deve ser v"+String.fromCharCode(225)+"lido";erro['cpf'] = "Desculpe, o CPF deve ser v"+String.fromCharCode(225)+"lido.";erro['senha'] = "Desculpe, mas é necessário colocar uma senha";erro['data'] = "Desculpe, mas o formato da data é DD/MM/AAAA, exemplo: 25/12/1970. E o dia deve existir.";erro['endereco'] = "Desculpe, voce deve colocar o nome da rua ou avenida.";erro['bairro'] = "Desculpe, mas é necessário por o bairro.";erro['cidade'] = "Desculpe, mas é necessário colocar o nome da Cidade.";erro['estado'] = "Desculpe, mas é necessário colocar o estado.";erro['confirmar'] = "Desculpe, voce deve digitar exatamente igual, para garantir que não há erro de digitação.";function email(texto){a = texto.indexOf("@");ab = texto.lastIndexOf(".");return (a>0 && ab>a);}function igual(texto){k = -99;l = 0;for(i=0;i<texto.length;i++){if(k != texto.charAt(i)){l++;k = texto.charAt(i);}}if(l == 1){return true;}else{return false;}}function str(texto){ return (texto.length>0);}function preco(texto){ return (texto.length>0);}function num(texto){ return ((texto.length>0) && !texto.match(/[^0-9]/gi));}function string(texto){return str(texto);}function string(texto){return str(texto);}function texto2(texto){ return str(texto);}function texto(texto){return str(texto);}function integer(texto){ return num(texto);}function senha(texto){ return str(texto);}function endereco(texto){ return str(texto);}function bairro(texto){return str(texto);}function cidade(texto){return str(texto);}function estado(texto){return str(texto);}function cep(texto){ return (texto.length>=8);}function telefone(texto){ a = texto.replace(/[^0-9]/gi,'');return (a.length>=8);}function cnpj(texto){texto = '' + texto.replace(/[^0-9]/gi,'');if(texto.length<14 || igual(texto)){return false;} s = texto; var i; var c = s.substr(0,12); var dv = s.substr(12,2); var d1 = 0; for (i = 0; i < 12; i++) { d1 += c.charAt(11-i)*(2+(i % 8)); }if (d1 == 0) return false;d1 = 11 - (d1 % 11);if (d1 > 9) d1 = 0;if (dv.charAt(0) != d1){ return false;} d1 *= 2; for (i = 0; i < 12; i++){ d1 += c.charAt(11-i)*(2+((i+1) % 8));}d1 = 11 - (d1 % 11);if (d1 > 9) d1 = 0;if (dv.charAt(1) != d1){ return false;} return true;}function cpf(texto){ strcpf = texto; str_aux = ""; for (i = 0; i <= strcpf.length - 1; i++) if ((strcpf.charAt(i)).match(/\d/))  str_aux += strcpf.charAt(i); else if (!(strcpf.charAt(i)).match(/[\.\-]/)) { return false; } if (str_aux.length != 11 || igual(str_aux)) { return false; } soma1 = soma2 = 0; for (i = 0; i <= 8; i++) { soma1 += str_aux.charAt(i) * (10-i); soma2 += str_aux.charAt(i) * (11-i); } d1 = ((soma1 * 10) % 11) % 10; d2 = (((soma2 + (d1 * 2)) * 10) % 11) % 10; if ((d1 != str_aux.charAt(9)) || (d2 != str_aux.charAt(10))) { return false; } return true;}function confirmar(obj,texto){if(obj.id.indexOf("confirmar_email") == 0){objetos = document.getElementsByTagName("input");for(i=0;i<objetos.length;i++){if(objetos[i].id.indexOf("email") == 0){if(texto == objetos[i].value){return true;}}}}if(obj.id.indexOf("confirmar_senha") == 0){objetos = document.getElementsByTagName("input");for(i=0;i<objetos.length;i++){if(objetos[i].id.indexOf("senha") == 0){if(texto == objetos[i].value){return true;}}}}return false;}function data(texto){texto = '' + texto.replace(/[^0-9]/gi,'');if(texto.length<8)return false;dia = texto.substring(0,2);mes = texto.substring(2,4);ano = texto.substring(4,8);mes--;dias = new Array(31,28,31,30,31,30,31,31,30,31,30,31);if((ano%4) == 0)dias[1] = 29;if(dia<0 || dia>dias[mes])return false;if(ano<1900 || ano > 2050)return false;return true;}function Chamar(a,b){if((b.style.display != "none") && (b.type == "text" || b.type == "password")){if(a == "confirmar"){return confirmar(b,b.value); }else{return eval(a)(b.value); }}if(a == "texto" || a == "texto2"){return eval(a)(b.value); }return true;}function submeter(a){if(validar_formulario(a)){$(a).submit();}}/*// in: string ("id" de um <form>)// out: void// desc: valida o formulário de acordo com o // prefixo do "name" do <input> dentro// do Form. <input name="emailAlgo"/> irá validar como "email"*/function validar_formulario(a){b = $(a);if(!b) { b = a; a =1;}if(!b) return 0;tipos = new Array("email","str","num","preco","string","texto2","texto","integer","cep","telefone","cnpj","cpf","senha","data","endereco","bairro","cidade","estado","confirmar");temp = b.getElementsByTagName("input");temp2 = b.getElementsByTagName("textarea");objects = new Array();j = 0;for(var i=0; i<temp.length; i++){objects[j] = temp[i];j++;}for(var i=0; i<temp2.length; i++){objects[j] = temp2[i];j++;}possivel_div = b.getElementsByTagName("div");possivel_span = b.getElementsByTagName("span");for (var i = 0; i < objects.length; i++){ for(var j=0; j < tipos.length; j++){if(objects[i].name.indexOf(tipos[j]) == 0){c = null;for(var k=0;k<possivel_div.length;k++){if(possivel_div[k].id == "MSG"+objects[i].name){c = possivel_div[k];}}for(var k=0;k<possivel_span.length;k++){if(possivel_span[k].id == "MSG"+objects[i].name){c = possivel_span[k];}}if(c){if(objects[i].alt != "Sem blur"){c.innerHTML = "&nbsp;";}c.className = "alerta";}if(!Chamar(tipos[j],objects[i])){if(objects[i].alt != "Sem blur"){if(typeof(erro) == "object"){if(c){c.innerHTML = erro[tipos[j]];}else{alert(erro[tipos[j]]);}}else{if(c){c.innerHTML = "Desculpe, este campo dever ser v&aacute;lido.";}else{alert("Desculpe, este campo dever ser v"+String.fromCharCode(225)+"lido.");}}}if(objects[i].alt != "Sem blur"){objects[i].onblur = function(){if(this.type != "textarea"){this.className = "input";}};}if(objects[i].type != "textarea"){objects[i].className = "input_erro";objects[i].focus();}return false;}}}}if(a==1){return true;}else{b.submit();}}function deletar(url){if(confirm("Voce tem certeza que deseja deletar este ítem?")){window.location = url;}}function deletar2(url){if(confirm("Voce tem certeza que deseja retirar este produto da sua Cesta de Compras?")){window.location = url;}}function CEP(endereco,bairro,cidade,uf){if(endereco == ""){if($("MSGcepOrigem")){$("MSGcepOrigem").innerHTML = "CEP inexistente.";}else{alert("CEP inexistente.");}$("cepOrigem").focus();}else{if($("MSGcepOrigem")){$("MSGcepOrigem").innerHTML = "";}}if($("strEndereco")){$("strEndereco").value = endereco;}if($("strBairro")){$("strBairro").value = bairro;}if($("strCidade")){$("strCidade").value = cidade;}if($("strUf")){$("strUf").value = uf;}}function CriarCookie(name,value,days) {name = LimpaString(name);if (days) {var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = "; expires="+date.toGMTString();}else var expires = "";document.cookie = name+"="+value+expires+"; path=/";}function LerCookie(name) {name = LimpaString(name);var nameEQ = name + "=";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++) {var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length);if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}return null;}function ApagarCookie(name) {name = LimpaString(name);CriarCookie(name,"",-1);}function logar(){if(email($("le").value)){if(senha($("ls").value)){$("le").name = "emailEmail";$("ls").name = "senhaSenha";return true;}else{alert(erro['senha']);$("ls").focus();return false;}}else{alert(erro['email']);$("le").focus();return false;}}function ApenasNumPontoTraco(obj){obj.value = obj.value.replace(/[^0-9.-]/gi,'');}function ApenasNumBarraTraco(obj){obj.value = obj.value.replace(/[^0-9-\/]/gi,'');}function MSGemBranco(){divs = document.getElementsByTagName("div");for(i=0;i<divs.length;i++){if(divs[i].id.indexOf("MSG") == 0){campo = divs[i].innerHTML;campo = campo.replace("&nbsp;","");campo = campo.replace(" ","");if(campo.length > 0){alert('Ainda há campos inválidos, verifique a informação de alerta abaixo do campo, para tornar válido o formulário. ');return false;}}}return true;}function $p(a){return document.getElementById(a);}