function Finalizar(Grupo,SubGrupo,Modelo) {
	var width = 775;
   var height = 500;
   var left = 99;
   var top = 99;
	//var confirma = confirm("Confirma remoçao desta imagem?")
	
	
		var URL = "FinalizarCompra.php?Grupo="+Grupo+"&Metodo="+Modelo
	
	window.open(URL,'UPLOAD', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, 			location=no, directories=no, menubar=no, resizable=yes, fullscreen=no');

}
function carregaAtu2(Chaves) {
		var Chavs=Chaves.split("F");
		var Valr = "";
		for($i = 0; $i < (Chavs.length - 1); $i++){
			Valr = Valr + document.getElementById("QTR"+Chavs[$i]).value + "F";
			//alert(document.getElementById("QTR"+Chavs[$i]).value);
		}
		carrega('carrinho.php?Metodo=Atualizar&Chaves='+Chaves+'&Valores='+Valr,'Prod')
}
function carregaAtu(Chaves) {
		var Chavs=Chaves.split("F");
		var Valr = "";
		for($i = 0; $i < (Chavs.length - 1); $i++){
			Valr = Valr + document.getElementById("QTR"+Chavs[$i]).value + "F";
			//alert(document.getElementById("QTR"+Chavs[$i]).value);
		}
		//alert(document.getElementById("CEP1").value.length);
		if(document.getElementById("CEP1").value.length < 5 ) {
			alert("O campo CEP nao foi preenchido corretamente.");
			document.getElementById("CEP1").focus();
			return false;
			
		}
		if(document.getElementById("CEP2").value.length < 3 ) {
			alert("O campo CEP nao foi preenchido corretamente.");
			document.getElementById("CEP2").focus();
			return false;
			
		}
		alert('carrinho.php?Metodo=Atualizar&Chaves='+Chaves+'&Valores='+Valr+'&Tipo='+document.getElementById("Tipo").value+'&Cep1='+document.getElementById("CEP1").value+'&Cep2='+document.getElementById("CEP2").value);
		carrega('carrinho.php?Metodo=Atualizar2&Chaves='+Chaves+'&Valores='+Valr+'&Tipo='+document.getElementById("Tipo").value+'&Cep1='+document.getElementById("CEP1").value+'&Cep2='+document.getElementById("CEP2").value,'Prod')
}
	var JGCookie = {
  date: new Date(),
  set: function(name, content, days) {
    var expires = "";
    if(days) {
	  this.date.setTime(this.date.getTime()+(days*24*60*60*1000));
      expires = this.date.toGMTString() + "; ";
	}
	document.cookie = name + "=" + content + "; " + expires + "path=/";
	return true;
  },
  get: function( name ) {
  	var nameE = name + "=";
	var cookies = document.cookie.split(";");
	for(var i = 0, Cookie; Cookie = cookies[i]; i++) {
	  while(Cookie.charAt(0) == " ") {
	  	Cookie = Cookie.substring(1,Cookie.length);
	  }
	  if(Cookie.indexOf(nameE) == 0) {
	  	return Cookie.substring(nameE.length,Cookie.length);
	  }
	}
	return false;
  },
  unset: function( name ) {
  	this.set(name, "", -1);
  	return true;
  }
}
function Leu() {
	JGCookie.set("Lucas", 0, 36000);
}
	function carrega1(URL,Target,Grupo,SubGrupo) {
		document.getElementById("Banner2").style.display = "none";
		document.getElementById("Banner").style.display = "none";
		document.getElementById("BannerZ").style.display = "";
		var conteudo=document.getElementById("BannerZ");
    	if(JGCookie.get("Lucas") == false) {
			JGCookie.set("Lucas", 0, 36000); // Setamos (nome, valor, duracao)
		}
		//JGCookie.unset("Lucas");
		if(JGCookie.get("Lucas") != Grupo) {
			//alert("Mudou a Bagaça");
			JGCookie.set("Lucas", Grupo, 36000);
			conteudo.innerHTML= '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="731" height="206"> <param name="movie" value="Top.swf?Grupo='+Grupo+'&SubGrupo='+SubGrupo+'" />  <param name="quality" value="high" /><embed src="Top.swf?Grupo='+Grupo+'&SubGrupo='+SubGrupo+'" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="731" height="206"></embed></object>';
		}
		//alert(JGCookie.get("Lucas"));
		
		
		
		carrega(URL,Target);
	}
	function ChecaNome() {
		if(document.getElementById("Nome").value == "Digite sua busca.") {
			document.getElementById("Nome").value = "";
		} 
		
	}
	function ChecaNome2() {
		if(document.getElementById("Nome").value == "") {
			document.getElementById("Nome").value = "Digite sua busca.";
		} 
		
	}
	function Exibe(Chave) {
		document.getElementById("Menu"+Chave).style.display = "none";
		document.getElementById("OMenu"+Chave).style.display = "";
		document.getElementById("Cont"+Chave).style.display = "";
	}
	function Oculta(Chave) {
		document.getElementById("Menu"+Chave).style.display = "";
		document.getElementById("OMenu"+Chave).style.display = "none";
		document.getElementById("Cont"+Chave).style.display = "none";
	}
	function OcultaSem(Chave) {
		document.getElementById("Menu"+Chave).style.display = "none";
		document.getElementById("OMenu"+Chave).style.display = "none";
		document.getElementById("Cont"+Chave).style.display = "none";
		document.getElementById("SMenu"+Chave).style.display = "";

	}
	function EscondeCarr() {
		//document.getElementById("Carregando").style.display = "none";
	}
	function Envia2(){
			prim = document.getElementById("textfield2").value.indexOf("@");
			if(prim < 2) {
				alert("O e-mail informado parece não estar correto.");
				document.getElementById("textfield2").focus();
				document.getElementById("textfield2").select();
				return false;
			}
			if(document.getElementById("textfield2").value.indexOf("@",prim + 1) != -1) {
				alert("O e-mail informado parece não estar correto.");
				document.getElementById("textfield2").focus();
				document.getElementById("textfield2").select();
				return false;
			}
			if(document.getElementById("textfield2").value.indexOf(".") < 1) {
				alert("O e-mail informado parece não estar correto.");
				document.getElementById("textfield2").focus();
				document.getElementById("textfield2").select();
				return false;
			}
			
			if(document.getElementById("textfield2").value.indexOf(" ") != -1) {
				alert("O e-mail informado parece não estar correto.");
				document.getElementById("textfield2").focus();
				document.getElementById("textfield2").select();
				return false;
			}
			
			if(document.getElementById("textfield2").value.indexOf("zipmeil.com") > 0) {
				alert("O e-mail informado parece não estar correto.");
				document.getElementById("textfield2").focus();
				document.getElementById("textfield2").select();
				return false;
			}
			if(document.getElementById("textfield2").value.indexOf("hotmeil.com") > 0) {
				alert("O e-mail informado parece não estar correto.");
				document.getElementById("textfield2").focus();
				document.getElementById("textfield2").select();
				return false;
			}
			if(document.getElementById("textfield2").value.indexOf(".@") > 0) {
				alert("O e-mail informado parece não estar correto.");
				document.getElementById("textfield2").focus();
				document.getElementById("textfield2").select();
				return false;
			}

			if(document.getElementById("textfield2").value.indexOf("@.") > 0) {
				alert("O e-mail informado parece não estar correto.");
				document.getElementById("textfield2").focus();
				document.getElementById("textfield2").select();
				return false;
			}
				
			if(document.getElementById("textfield2").value.indexOf(".com.br.") > 0) {
				alert("O e-mail informado parece não estar correto.");
				document.getElementById("textfield2").focus();
				document.getElementById("textfield2").select();
				return false;
			}
			
			if(document.getElementById("textfield2").value.indexOf("/") > 0) {
				alert("O e-mail informado parece não estar correto.");
				document.getElementById("textfield2").focus();
				document.getElementById("textfield2").select();
				return false;
			}
			
			if(document.getElementById("textfield2").value.indexOf("[") > 0) {
				alert("O e-mail informado parece não estar correto.");
				document.getElementById("textfield2").focus();
				document.getElementById("textfield2").select();
				return false;
			}			
			if(document.getElementById("textfield2").value.indexOf("]") > 0) {
				alert("O e-mail informado parece não estar correto.");
				document.getElementById("textfield2").focus();
				document.getElementById("textfield2").select();
				return false;
			}			
			if(document.getElementById("textfield2").value.indexOf("(") > 0) {
				alert("O e-mail informado parece não estar correto.");
				document.getElementById("textfield2").focus();
				document.getElementById("textfield2").select();
				return false;
			}			
			if(document.getElementById("textfield2").value.indexOf(")") > 0) {
				alert("O e-mail informado parece não estar correto.");
				document.getElementById("textfield2").focus();
				document.getElementById("textfield2").select();
				return false;
			}
			if(document.getElementById("textfield2").value.indexOf("..") > 0) {
				alert("O e-mail informado parece não estar correto.");
				document.getElementById("textfield2").focus();
				document.getElementById("textfield2").select();
				return false;
			}
			carrega("SalvaNews.php?Email="+document.getElementById("textfield2").value,"Central");


	}
	function Envia() {
	//alert(window.location.hash.substring(1)); 
		Mess = "Os seguintes erros foram encontrados:\n\n"
		if(document.getElementById("Nome").value == "Digite sua busca.") {
			Mess = Mess + "- O Campo busca não foi preenchido";
			//alert(Mess);
		}
		if(document.getElementById("select").value == 0){
			Link = "Busca.php?Busca="+document.getElementById("Nome").value;
		}else{
						
			Link = "Busca.php?Busca="+document.getElementById("Nome").value+"&Secao="+document.getElementById("select").value;
			if(document.getElementById("select").value == 1) {
				//alert(document.getElementById("select1").value);
				if(document.getElementById("select1").value != 0) {
					Link = Link + "&Area="+document.getElementById("select1").value;
				}
			}
			if(document.getElementById("select").value == 2) {
				if(document.getElementById("select2").value != 0) {
					Link = Link + "&Area="+document.getElementById("select2").value;
				}
			}
		}
		if(Mess != "Os seguintes erros foram encontrados:\n\n") {
			alert(Mess);
		}else{
			carrega(Link,"Central");
		}
	}
	function Muda(Chave) {
		if(Chave == 0) {
		document.getElementById("select1").style.display = "none";
		document.getElementById("select2").style.display = "none";	
			document.getElementById("p").style.display = "";
			
		}else{
		document.getElementById("p").style.display = "none";		
		document.getElementById("select1").style.display = "none";
		document.getElementById("select2").style.display = "none";
		document.getElementById("select"+Chave).style.display = "";
		}
	}
	function CarregaColuna() {
		if(document.getElementById("Coluna").value != 0) {
			Chave = document.getElementById("Coluna").value;
			carrega("Busca1.php?Chave="+Chave,"Central");
		}else{
			return false;
		}
	}

// JavaScript Document

<!--
function extraiScript(texto){
//Maravilhosa função feita pelo SkyWalker.TO do imasters/forum
//http://forum.imasters.com.br/index.php?showtopic=165277
    // inicializa o inicio ><
    var ini = 0;
    // loop enquanto achar um script
    while (ini!=-1){
        // procura uma tag de script
        ini = texto.indexOf('<script', ini);
        // se encontrar
        if (ini >=0){
            // define o inicio para depois do fechamento dessa tag
            ini = texto.indexOf('>', ini) + 1;
            // procura o final do script
            var fim = texto.indexOf('</script>', ini);
            // extrai apenas o script
            codigo = texto.substring(ini,fim);
            // executa o script
            //eval(codigo);
            /**********************
            * Alterado por Micox - micoxjcg@yahoo.com.br
            * Alterei pois com o eval não executava funções.
            ***********************/
            novo = document.createElement("script")
            novo.text = codigo;
            document.body.appendChild(novo);
        }
    }
}
function desloga(tempo){
   setTimeout("go_now()",10);
}

function go_now () {
   window.location.href = "login.php?erro=4";
}
//-->



atual=0
function carrega(n,t){
try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}
function ajax_js(){
                /* Por Tiago Araujo Silva 2007.16.02 */
        var scripts = document.getElementById('scripts');
        if(scripts){
                    var corpo = window.document.getElementsByTagName('body')[0];
                    var js = window.document.createElement('script');
                    js.text = scripts.innerHTML;
                    js.type = 'text/javascript';
                    corpo.appendChild(js);    
        }
    }

    //Exibe o texto carregando no div conteúdo
   
	var conteudo=document.getElementById(t);
    conteudo.innerHTML='<div class="Texto">&nbsp;<img src="img/Loading.gif">carregando...</div>';
	//alert(n);
    //Guarda a página escolhida na variável atual
    atual=n;

    //Abre a url
   var previneCache = new Date().getTime();
   xmlhttp.open("GET",n,true);

    //Executada quando o navegador obtiver o código
    xmlhttp.onreadystatechange=function() {

        if (xmlhttp.readyState==4){

            //Lê o texto
            var texto=xmlhttp.responseText;
			extraiScript(texto)
            //Desfaz o urlencode
           
			texto=texto.replace(/\+/g," ");
            texto=unescape(texto);
			texto=texto.replace("&amp;","&");
			//alert(texto);

            //Exibe o texto no div conteúdo
            // alert(texto);
			var conteudo=document.getElementById(t);
        
		 conteudo.innerHTML=texto;
		    ajax_js();
			
            

         
        }
    }
    xmlhttp.send(null)
}