﻿// Tao.Ajax

function openAjax() { 
var Ajax; 
try {Ajax = new XMLHttpRequest(); // XMLHttpRequest para browsers mais populares, como: Firefox, Safari, dentre outros. 
}catch(ee) { 
try {Ajax = new ActiveXObject("Msxml2.XMLHTTP"); // Para o IE da MS 
}catch(e) { 
try {Ajax = new ActiveXObject("Microsoft.XMLHTTP"); // Para o IE da MS 
}catch(e) {Ajax = false; 
} 
} 
} 
return Ajax; 
} 
function CallAjax(div,file) {
document.getElementById(div).innerText = "";
if(document.getElementById) { // Para os browsers complacentes com o DOM W3C. 
var exibeResultado = document.getElementById(div); // div que exibirá o resultado. 
var Ajax = openAjax(); // Inicia o Ajax. 
Ajax.open("GET", file, true); // fazendo a requisição 
Ajax.onreadystatechange = function() 
{ 
if(Ajax.readyState == 1) { // Quando estiver carregando, exibe: carregando... 
exibeResultado.innerHTML = "<div align='center'><img src='./Layout/Loading.gif'></div>"; 
} 
if(Ajax.readyState == 4) { // Quando estiver tudo pronto. 
if(Ajax.status == 200) { 
var resultado = Ajax.responseText; // Coloca o retornado pelo Ajax nessa variável 
resultado = resultado.replace(/\+/g," "); // Resolve o problema dos acentos (saiba mais aqui: http://www.plugsites.net/leandro/?p=4) 
resultado = unescape(resultado); // Resolve o problema dos acentos 
exibeResultado.innerHTML = resultado; 
// document.getElementById("A").innerHTML = ""; //"<img src='Layout/Visto.gif'>";
} else { 
exibeResultado.innerHTML = "Erro ao porcessar página.";
} 
} 
} 
Ajax.send(null); // submete 
} 
} 

function GetPage(div,page) {
CallAjax(div,page);
}

// Tao.Scripts.Functions
function x(id){
document.getElementById(id).style.borderColor = "gold";
document.getElementById(id).style.borderStyle = "solid";
document.getElementById(id).style.borderWidth = "1px";
}
function y(id){
document.getElementById(id).style.borderColor = "";
document.getElementById(id).style.borderStyle = "";
document.getElementById(id).style.borderWidth = "";
}
function MouseOverMenu(id){
document.getElementById(id).style.backgroundColor = "#fff1f1";
}
function MouseOutMenu(id){
document.getElementById(id).style.backgroundColor = "#ffffff";
}
function StatusBar() {
window.status = ":: Central de Emabalagens::";
}

function GetFrete()
{
var cep = document.getElementById("TextBoxCep").value;
var valor = document.getElementById("HiddenValor").value;
var peso = document.getElementById("HiddenPeso").value;

if(cep!=""){
GetPage("DivFrete","FuncoesAsp.asp?valor_declarado="+ valor +"&opcao=frete&cep="+ cep +"&peso="+ peso +"");
document.getElementById("DivFormaPagamento").style.visibility = "hidden";
}
else
{
alert("Digite o cep.");
}
}

function ProcessaTransacao() 
{
GetPage("DivProcessaTransacao","formVisanet.html");
}

function ShowFormaPagamento() 
{
document.getElementById("DivFormaPagamento").style.visibility = "visible";
}

function GetBoleto(id)
{
window.open('PageBoleto.aspx?id='+ id,'Boleto Funsex','width=650,top=0,left=0,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=auto,resizable=no,copyhistory=no');
}

function GetSeloSSL1()
{
if (location.protocol == "https:"){ 
document.write('<scr'+'ipt language="JavaScript" src="https://secure.comodo.net/trustlogo/javascript/trustlogo.js"></scr'+'ipt>');
}
}

  function GetSeloSSL2()
{                  
if (location.protocol == "http:"){
   var URL = document.location.toString().split('/');
   var x = ""

   for (var i=0; i < URL.length; i++) {
      if (i >= 3){
      x = x + "/" + URL[i]
      }
   }

   var NOME_LOGIN = "unimestre"
   var ENDERECO = "https://ssl308.locaweb.com.br/"+ NOME_LOGIN + x;

   document.write("<font size='1' face='verdana,arial'>Você não se encontra em um ambiente seguro.<br>Para ir ao ambiente seguro clique ")
   document.write("<a href='" + ENDERECO + "'> aqui. </a></font>")
   } else if (location.protocol == "https:"){
   TrustLogo("https://ssl308.locaweb.com.br/unimestre/funsex/LayOut/SeloSSL.gif", "SC", "none");
}
}

function OpenWindowIndique(imagem,idproduto,tipo)
{
var url = "PageIndique.aspx?imagem="+ imagem +"&idproduto=" + idproduto + "&tipo=" + tipo;
window.open(url,'CentralDeEmbalagens','width=500,height=350,top=50,left=50,toolbar=no,location=no,directories=no,titlebar=no,status=no,menubar=no,scrollbars=auto,resizable=no,copyhistory=no');
}

function Imprimir() {
print();
}

function OpenImagem(i)
{
CallAjax("DivImagem","PageImagemProduto.aspx?id=" + i);
}

function fncMapaLocalizacao() {
window.open('PageMapaLocalizacao.htm','MapaLocalizacao','width=800,height=600,top=0,left=0');
}

function carregaFlash(caminho,largura,altura)
{
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+largura+'" height="'+altura+'">');
document.write('<param name="movie" value="'+caminho+'">');
document.write('<param name="quality" value="high">');
document.write('<param name="wmode" value="transparent">');
document.write('<param name="menu" value="false">');
document.write('<embed src="'+caminho+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+largura+'" height="'+altura+'"></embed>');
document.write('</object>');
}