var dirSite = 'https://www.bordoncasa.com.br//loja/'; function openAjax() { var ajax; try { ajax = new XMLHttpRequest();} catch(ee) { try { ajax = new ActiveXObject('Msxml2.XMLHTTP');} catch(e) { try { ajax = new ActiveXObject('Microsoft.XMLHTTP');} catch(E) { ajax = false; } } } return ajax;} function getID(ID) { return document.getElementById(ID);}// JavaScript Document function showDiv(obj){ var tmp = window.document.getElementById(obj); if(tmp.style.display == 'none'){ tmp.style.display = ''; } else if(tmp.style.display == ''){ tmp.style.display = 'none'; } } function updateProduto(id){ var valor = getID('produto_'+id).value; location.href = dirSite+'carrinho/index.php?id='+id+'&valor='+valor+'&op=upd'; } function deleteProduto(id){ var valor = getID('produto_'+id).value; location.href = dirSite+'carrinho/index.php?id='+id+'&valor='+valor+'&op=del'; } function getFrete() { var dest = getID('return_frete'); dest.innerHTML = 'Aguarde ...'; var cep = getID('cep').value; var ajax = openAjax(); ajax.open('GET', dirSite+'carrinho/_prcss/getCalcFrete.php?cep='+cep, true); ajax.onreadystatechange = function() { if (ajax.readyState < 4) { dest.innerHTML = 'Carregando...';} if (ajax.readyState == 4) { if (ajax.status == 200) { dest.innerHTML = ajax.responseText; } } } ajax.send(null); } function getFreteProduto(id) { var dest = getID('return_frete'); dest.innerHTML = 'Aguarde ...'; var cep = getID('cep').value; var ajax = openAjax(); ajax.open('GET', dirSite+'carrinho/_prcss/getCalcFreteProduto.php?id='+id+'&cep='+cep, true); ajax.onreadystatechange = function() { if (ajax.readyState < 4) { dest.innerHTML = 'Carregando...';} if (ajax.readyState == 4) { if (ajax.status == 200) { dest.innerHTML = ajax.responseText; } } } ajax.send(null); } function getCupom(){ var dest = getID('return_cupom'); var cp = getID('cupom'); var cupom = cp.value; var ajax = openAjax(); ajax.open('GET', dirSite+'carrinho/_prcss/Descontos.php?cupom='+cupom, true); ajax.onreadystatechange = function() { if (ajax.readyState == 1) { dest.innerHTML = 'Carregando...';} if (ajax.readyState == 4) { if (ajax.status == 200) { dest.innerHTML = ajax.responseText; getCalculoValor('cupom'); } } } ajax.send(null); } function freteSelect(tipo){ var dest = getID('return_session'); var ajax = openAjax(); var frete = window.document.getElementById(tipo).value; ajax.open('GET', dirSite+'carrinho/_prcss/gravaFrete.php?frete='+frete+'&tipo='+tipo, true); ajax.onreadystatechange = function() { if (ajax.readyState < 4) {} if (ajax.readyState == 4) { if (ajax.status == 200) { getCalculoValor('frete'); } } } ajax.send(null); } function getCalculoValor(origem){ var total = window.document.getElementById('total_pedido').value; var dest = getID('return_total'); dest.innerHTML = 'Calculando...'; var ajax = openAjax(); ajax.open('GET', dirSite+'carrinho/_prcss/getCalculoTotal.php?total='+total, true); ajax.onreadystatechange = function() { if (ajax.readyState == 1) { } if (ajax.readyState == 4) { if (ajax.status == 200) { dest.innerHTML = ajax.responseText; if(origem == 'frete'){ window.document.getElementById('btn_finalizar_pedido').disabled = false; } } } } ajax.send(null); } function gravaObs(){ var observacao = window.document.getElementById('pedidoObservacoes').value; var ajax = openAjax(); ajax.open('GET', dirSite+'carrinho/_prcss/observaSession.php?obs='+observacao, true); ajax.onreadystatechange = function() { if (ajax.readyState < 4) { return (null); } if (ajax.readyState == 4) { if (ajax.status == 200) { return (null); } } } ajax.send(null); } function setPagamento(tipo,pedido){ var retorno = window.document.getElementById('retornoPagamento'); var ajax = openAjax(); ajax.open('GET', dirSite+'carrinho/_prcss/setMeioPagamento.php?tipo='+tipo+'&pedido='+pedido, true); ajax.onreadystatechange = function() { if (ajax.readyState < 4) { return (null); } if (ajax.readyState == 4) { if (ajax.status == 200) { retorno.innerHTML = ajax.responseText; } } } ajax.send(null); }