var opcSaida = "";

	function abrir(pagina,rolagem,largura,altura) {
	  w = screen.width;
	  h = screen.height;
	  meio_w = w/2;
	  meio_h = h/2;
	  altura2 = altura/2;
	  largura2 = largura/2;
	  meio1 = meio_h-altura2;
	  meio2 = meio_w-largura2;
	  window.open(pagina,'','scrollbars='+ rolagem +',toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,height=' + altura + ',width=' + largura + ',top='+meio1+',left='+meio2+''); 
	}	

function campoVazio(ObjSel,Campo) {
 if (ObjSel.value == '') {
   alert("Favor preencha o campo '"+ Campo +"' para continuar.");
   ObjSel.focus();
   return false;}
}

//Limpa campos do formulário de orçamento
function limpaorcamento()
{
	document.orcamento.Nome.value = '';
	document.orcamento.Email.value = '';
	document.orcamento.CidadeUF.value = '';
	document.orcamento.CEP.value = '';
	document.orcamento.CNPJCPF.value = '';
	document.orcamento.IERG.value = '';
	document.orcamento.FoneFax.value = '';
	document.orcamento.Contato.value = '';
}

//Valida formulário de orçamento
function validaorcamento()
{
	if (document.orcamento.Nome.value == ''){
	  alert('Preencha o nome!');
	  document.orcamento.Nome.focus();
	  return false;
	}
	if (document.orcamento.Email.value == ''){
	  alert('Preencha o Email!');
	  document.orcamento.Email.focus();
	  return false;
	}
	if (document.orcamento.CidadeUF.value == ''){
	  alert('Preencha a cidade/uf!');
	  document.orcamento.CidadeUF.focus();
	  return false;
	}
	if (document.orcamento.FoneFax.value == ''){
	  alert('Preencha o fone/fax!');
	  document.orcamento.FoneFax.focus();
	  return false;
	}
	if (document.orcamento.Contato.value == ''){
	  alert('Preencha o Contato!');
	  document.orcamento.Contato.focus();
	  return false;
	}
	listaSCat('orcamento');
	//Aguarde(1);
	//setTimeout ( 'Aguarde(0)', 5000);
	//Modalbox.show('orcamento_finaliza.asp', {title: 'Orcamento...', width: 600});
    //window.scrollTo(0, 0);
	abrir('orcamento_finaliza.asp', 'yes', '610', '620');
}

//Função de impressão
 function f_imprimir()
 {
    if (!window.print){ 
      alert("Use o Netscape  ou Internet Explorer \n nas versőes 4.0 ou superior!") 
      return
    } 
      window.print()
 }

//Exibe foto do detalhe do produto
function mostraFoto(cod)
{
  var det = document.frmProduto.fotoDetalhe.value;
  if (det!='') {
	Modalbox.show('fotoproduto.asp?Produto='+cod+'&det='+det, {title: 'Foto do produto...', width: 600});  
  }else{
    Modalbox.show('fotoproduto.asp?Produto='+cod, {title: 'Foto do produto...', width: 600});
  }
}

//Envia a requisição ao servidor, de acordo com a ação do usuário
function Loja(secao, parametro) {
	window.scrollTo(0, 0);
	Aviso(1); //exibe aviso "Aguarde..."
    var url="detalhaproduto.asp?"+secao+"="+encodeURIComponent(parametro);
    requisicaoHTTP("GET",url,true);
}

function Exibir(pag, onde) {
	opcSaida = onde;
	Aviso(1); //exibe aviso "Aguarde..."
    requisicaoHTTP("GET",pag,true);
}


function Assi(secao, parametro) {
	window.scrollTo(0, 0);
	Aviso(1); //exibe aviso "Aguarde..."
    var url="listaAssistenciaTecnicaDet.asp?"+secao+"="+encodeURIComponent(parametro);
    requisicaoHTTP("GET",url,true);
}

//Exibe ou oculta a mensagem de espera
function Aviso(exibir) {
	var saida = document.getElementById("avisos");
	if(exibir){
		//saida.className = "aviso";
		//saida.innerHTML = "Aguarde... Processando!";
		//Exibe globo
		var imagem = document.createElement("img");
		imagem.setAttribute("src", "carregando.gif");
		imagem.setAttribute("alt", "Carregando...");
		imagem.style.cssText = 'display:block; width:50px; height:50px; margin:60px auto;'; 
		saida.appendChild(imagem);
	} else {
	  saida.className = "";
	  saida.innerHTML = "";
	}
}

function Aguarde(exibir) {
	var saida = document.getElementById("aguarde");
	if(exibir){
		saida.className = "aviso";
		saida.innerHTML = "Aguarde... Processando!";
	} else {
	  saida.className = "";
	  saida.innerHTML = "";
	}
}

function temporizador(onde)
{
  	setTimeout ( 'msgAguarde(0, "'+onde+'")', 5000);
}

function msgAguarde(exibir, onde) {
    var saida = document.getElementById(onde);
	if(exibir){
		saida.className = "aviso";
		saida.innerHTML = "Aguarde... Processando!";
	} else {
	  saida.className = "";
	  saida.innerHTML = "";
	}
	temporizador(onde);
}

//Exibe a resposta do servidor
function trataDados(){
  var info = ajax.responseText;
  if (opcSaida==""){
    var saida = document.getElementById("principal");
  }else{
	var saida = document.getElementById(opcSaida);
  }
  saida.innerHTML = info;
  v_salvaEstado(); //salva o novo conteúdo na cache*********NOVO****************
  Aviso(0);
}

// ]]>

