function waitPreloadPage() {
	document.getElementById('carregando').style.visibility='hidden';
}

//////////////////////////////////////////////////////////////////
////Função para verificar se o campo está com dados digitados/////
//////////////////////////////////////////////////////////////////
function checkrequired(which) {
	var pass=true;
		if (document.images) {
			for (i=0;i<which.length;i++) {
				var tempobj=which.elements[i];
					if (tempobj.name.substring(0,8)=="required") {
							if (((tempobj.type=="text"||tempobj.type=="textarea"||tempobj.type=="hidden"||tempobj.type=="file")&&
								 tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
								 tempobj.selectedIndex==0)) {
								 pass=false;
								  break;
						   }
					}
			 }
		}

	if (!pass) {
	 shortFieldName=tempobj.name.substring(8,30).toUpperCase();
	 alert("O campo "+shortFieldName+" deve ser preenchido.");
	 return false;
	}
	else
	 return true;
}


function verifica_tipo_pessoa(tipo){
	if(tipo == "1"){
		document.getElementById('requiredcpf_cnpj').value = "";
		document.getElementById('tipo_escolhido').innerHTML = "";
		document.getElementById('tipo_escolhido').innerHTML = "<input type=\"text\" name=\"requiredcpf_cnpj\" id=\"requiredcpf_cnpj\" onkeyup=\"formata_cpf(this);\">";
	}else{
		if(tipo == "2"){
			document.getElementById('requiredcpf_cnpj').value = "";
			document.getElementById('tipo_escolhido').innerHTML = "";
			document.getElementById('tipo_escolhido').innerHTML = "<input type=\"text\" name=\"requiredcpf_cnpj\" id=\"requiredcpf_cnpj\" onkeyup=\"formata_cnpj(this);\">";
		}
	}
}



//////////////////////////////////////////////////////////////////
////Função para verificar se o campo está com dados digitados/////
//////////////////////////////////////////////////////////////////

function somente_numero(campo){
	var digits="0123456789"
	var campo_temp 
	for (var i=0;i<campo.value.length;i++){
	  campo_temp=campo.value.substring(i,i+1)	
	  if (digits.indexOf(campo_temp)==-1){
			campo.value = campo.value.substring(0,i);
			break;
	   }
	}
}


////////////////////////////////////////////////////////////
//mask: O caracter '?' define que só ser&aacute; permitido números
//mask: O caracter '!' define que é permitido qualquer caracter
////////////////////////////////////////////////////////////

function formata(Campo, mask, teclapres) {
	var tecla = teclapres.keyCode;
	var vr = new String(Campo.value);
	vr = vr.replace("/", "");
	vr = vr.replace("/", "");
	vr = vr.replace("/", "");
	tam = vr.length + 1;
	if (tecla != 8 && tecla != 8)
	{
		if (tam > 0 && tam < 2)
			Campo.value = vr.substr(0, 2) ;
		if (tam > 2 && tam < 4)
			Campo.value = vr.substr(0, 2) + '/' + vr.substr(2, 2);
		if (tam > 4 && tam < 7)
			Campo.value = vr.substr(0, 2) + '/' + vr.substr(2, 2) + '/' + vr.substr(4, 7);
	}
	if(tam == 9){
		return false;
	}
}


/////////////////////////////////////////////////////////////
///Função para alerta de mensagem de exclusão de registro////
/////////////////////////////////////////////////////////////
function programa(programa,Acao,Fase,destino){
   if(Acao == 'exclui'){
	  if(confirm('Deseja realmente excluir este registro?') == true){
		 document.location = destino+'?msg=3&status=Excluir&id='+programa;
	  }
   }
}
function limpa_quem_somos(id){
	if(confirm("Tem certeza que deseja deletar o conteúdo de Quem Somos?") == true){
		document.location = 'listar_quem_somos.php?acao=ExcluirQS&id_excluir='+id;
	}
}
function valida_comentario(id,destino,tipo){
	if(tipo == '1'){
		var tipo_saida = "Tem certeza que deseja APROVAR este comentário?";	
	}else{
		var tipo_saida = "Tem certeza que deseja NÃO APROVAR este comentário?";	
	}
	  if(confirm(tipo_saida) == true){
		 document.location = destino+'&acao=Aprovacao&id_aprovar='+id+'&tipo_aprovacao='+tipo;
	  }
}
function valida_exclusao_comentario(id,destino){
	  if(confirm('Deseja realmente excluir este comentario?') == true){
		 document.location = destino+'&acao=Excluir&id_excluir='+id;
	  }
}
function valida_exclusao_video(id,destino){
	  if(confirm('Deseja realmente excluir este registro?') == true){
		 document.location = destino+'?acao=ExcluirV&id_excluir='+id;
	  }
}
function valida_exclusao(id,destino){
	  if(confirm('Deseja realmente excluir este registro?') == true){
		 document.location = destino+'?acao=Excluir&id_excluir='+id;
	  }
}
function valida_newsletter(){
	  var valor = document.getElementById('email_news').value;
	  if((!valor)||(valor == "Seu e-mail")){
		  alert('Você deve digitar um e-mail Válido!');
		  document.getElementById('email_news').focus();
		  return false;
	  }else{
		  return true;
	  }
}
function valida_busca(){
	  var valor = document.getElementById('CampoBusca').value;
	  if(!valor){
		  alert('Você deve digitar uma palavra-chave para no campo de Busca!');
		  document.getElementById('CampoBusca').focus();
		  return false;
	  }else{
		  return true;
	  }
}


//FUNÇÃO QUE BUSCA CEP DE ACORDO COM O VALOR DO CAMPO
function buscaEndereco(cep){
	var tam = cep.length;
	if(tam == 9){
		url= "busca_cep.php?valor="+cep;
		
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
			req.onreadystatechange = processReqChange_cep;
			req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
			req.send(null);
		// Procura por uma vers&atilde;o ActiveX (IE)
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) {
				req.onreadystatechange = processReqChange_cep;
				//alert(url);
				req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
				req.send();
			}
		}
	}
}
function processReqChange_cep(){
	//apenas quando o estado for "completado"
	if(req.readyState == 4) {
		//apenas se o servidor retornar "OK"
		if(req.status ==200) {	
			var resposta = req.responseText;		
			var pos     = resposta.indexOf("#");
			var endereco = resposta.substring(0,pos);

			var auxcidade = resposta.substring(pos+1,resposta.length);
			var pos     = auxcidade.indexOf("#");
			var cidade = auxcidade.substring(0,pos);

			var auxbairro = auxcidade.substring(pos+1,auxcidade.length);
			var pos     = auxbairro.indexOf("#");
			var bairro = auxbairro.substring(0,pos);

			var auxestado = auxbairro.substring(pos+1,auxbairro.length);
			var pos     = auxestado.indexOf("#");
			var estado = auxestado.substring(0,pos);
			document.getElementById('requiredendereco').value = endereco;
			document.getElementById('requiredbairro').value = bairro;
			document.getElementById('requiredcidade').value = cidade;
			document.getElementById('requiredestado').value = estado;

		}else{
			alert("Houve um problema ao obter os dados");
		}
	}
}


///////////////////////////////////////////////////////////////////////////////
///Função para abertura de janela pop-up/ /////////////////////////////////////
///<a href="javascript:popup('arquivo.php','nomepagina','600','500','no')">///
///////////////////////////////////////////////////////////////////////////////

function popup(caminho,nome,largura,altura,rolagem) {
	var esquerda = (screen.width - largura) / 2;
	var cima = (screen.height - altura) / 2 -50;
	window.open(caminho,nome,'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=' + rolagem + ',resizable=no,copyhistory=no,top=' + cima + ',left=' + esquerda + ',width=' + largura + ',height=' + altura);
}


///////////////////////////////////////////////////////////////////////////////
// Verifica se a data apresentada é uma data válida
// EX.: onchange="return IsDate(this.value);"
///////////////////////////////////////////////////////////////////////////////
function IsDate(data,form,campo) {

	day = data.substring(0,2); // dia da data
	month = data.substring(3,5); // mes da data
	year = data.substring(6,10); //an da data ex.: 2006

	var date = new Date();
    var blnRet = false;
    var blnDay;
    var blnMonth;
    var blnYear;

    date.setFullYear(year, month -1, day);

    blnDay   = (date.getDate()  == day);
    blnMonth = (date.getMonth() == month -1);
    blnYear  = (date.getYear()  == year);

	if (blnDay && blnMonth && (year.length==4)) {
        blnRet = true;
	} else {
		alert('ATENÇÃO!!! A data informada não é uma data válida!');
		document.getElementById(campo).value='';
		document.getElementById(campo).focus();
	}

    return blnRet;
}


///////////////////////////////////////////////////////////////////////////////
// Verifica se hor&aacute;rio digitado é um  horário válido
// EX.: onBlur="verifica_hora(this.value,nome_campo);"
///////////////////////////////////////////////////////////////////////////////
 
 function verifica_hora(valor,campo){ 
			  hrs = (valor.substring(0,2)); 
              min = (valor.substring(3,5)); 
              
              situacao = ""; 
              // verifica data e hora 
              if ((hrs < 00 ) || (hrs > 23) || ( min < 00) ||( min > 59)){ 
                  situacao = "falsa"; 
              } 
               
              if (campo == "") { 
                  situacao = "falsa"; 
              } 

              if (situacao == "falsa") { 
                  alert("Hora inválida!"); 
				  document.getElementById(campo).focus(); 
              } 
          } 
		  
///////////////////////////////////////////////////////////////////////////////
// Função para chamar a popup de seleção de cores
// EX.: onclick="popColorPicker();"
/////////////////////////////////////////////////////////////////////////////// 
function popColorPicker(field){
			//preload should contain '#' hash, followed by 6 digit hex color code
			preload = '#' + document.getElementById(field).value;
			
			//detail factor, see class.TrueColorPicker.php
			df = 64;
			//Modify these
				//Where to pop the color picker window
				_top = 230;
				_left = 220;
				//Where the index.php exists
				path = 'TrueColorPicker/';
			if(preload != ''){
				preload = encodeURIComponent(preload);
			}
			window.open(path + 'index.php?df='+df+'&preload=' + preload + '&field=' + field, null,'width=420, height=290, top='+_top+', left='+_left+', help=no, status=no, scrollbars=no, resizable=no, dependent=yes,status=no', true);
		}
function passColorCode(clr,field){
	document.getElementById(field).value = clr;
}

function limpa_campo(field,tipo){
	if(tipo == 1){
		if((field.value == '')||(field.value == 'Busque Seu Produto')){
			field.value = '';	
		}
	}else{
		if((field.value == '')||(field.value == 'Busque Seu Produto')){
			document.getElementById('busca').value = "Busque Seu Produto";
		}
	}
}
function valida_login(){
	var field_login = document.getElementById('user').value;
	var field_passwd = document.getElementById('passwd').value;
	if((field_login == '') || (field_passwd == '')){
		alert('Você deve preencher os campos de Login e Senha!!');
		return false;
	}else{
		document.frmLogin.submit();	
	}
}

function verifica_selecao(valor,arquivo){
	if(valor == 0){
		valor = "";
		window.location=arquivo+'?id_cidade='+valor;
	}else{
		window.location=arquivo+'?id_cidade='+valor;
	}
}

	
	function verifica_campo(valor,valor_verifica,id,tipo){
		if(tipo == "1"){//ONCLICK
			if(valor == valor_verifica){//SE NO CLICK TIVER PADRÃO
				document.getElementById(id).value = "";
			}
		}else{//ON BLUR
			if(valor == ""){//SE AO SAIR TIVER VAZIO
				document.getElementById(id).value = valor_verifica;
			}
		}
	}
	
	function formata_cpf(Campo) {
		jQuery(Campo).setMask('cpf');
	}
	function formata_cnpj(Campo) {
		jQuery(Campo).setMask('cnpj');
	}
	function formata_tel(Campo) {
		jQuery(Campo).setMask('phone');
	}
	function formata_cep(Campo) {
		jQuery(Campo).setMask('cep');
	}
	function formata_data(Campo) {
		jQuery(Campo).setMask('date');
	}
	
	
	function monta_fotos(qtd) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = "monta_fotos.php?qtd="+qtd;
		ajax_fotos(url);
	}
	function ajax_fotos(url){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_fotos;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = processReqChange_fotos;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_fotos(){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
			// procura pela div id="pagina" e insere o conteudo
			// retornado nela, como texto HTML
			document.getElementById('fotos').innerHTML = "";
			document.getElementById('fotos').innerHTML = req.responseText;
			} else {
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	
	function monta_videos(qtd) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = "monta_videos.php?qtd="+qtd;
		ajax_videos(url);
	}
	function ajax_videos(url){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_videos;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = processReqChange_videos;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_videos(){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
			// procura pela div id="pagina" e insere o conteudo
			// retornado nela, como texto HTML
			document.getElementById('videos').innerHTML = "";
			document.getElementById('videos').innerHTML = req.responseText;
			} else {
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	function paginacao(ult) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = "paginacao.php?ult="+ult;
		ajax_paginacao(url);
	}
	function ajax_paginacao(url){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_paginacao;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = processReqChange_paginacao;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_paginacao(){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
			// procura pela div id="pagina" e insere o conteudo
			// retornado nela, como texto HTML
			document.getElementById('mini_fotos').innerHTML = "";
			document.getElementById('mini_fotos').innerHTML = req.responseText;
			} else {
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	function carrega_foto(nome_foto){
		document.getElementById('foto_certa').src = "images/loja/big/"+nome_foto;
	}
	
	
	
	
function verifica_texto(campo,valor,valor2,tipo){
	if(tipo == "1"){
		if(valor==""){ 
			document.getElementById(campo).value = valor2; 
		}
	}else{
		if(valor==valor2){ 
			document.getElementById(campo).value = ''; 
		}
	}
}


function monta_sub(destino,div,get) {
	//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
	url = destino+'?'+get;
	ajax_sub(url,div);
}
function ajax_sub(url,div){
	req = null;
	// Procura por um objeto nativo (Mozilla/Safari)
	if (window.XMLHttpRequest) {
	req = new XMLHttpRequest();
	req.onreadystatechange = function() { processReqChange_sub(div)};
	req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
	req.send(null);
	// Procura por uma versão ActiveX (IE)
	} else if (window.ActiveXObject) {
	req = new ActiveXObject("Microsoft.XMLHTTP");
	if (req) {
	req.onreadystatechange = function() { processReqChange_sub(div)};
	req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
	req.send();
	}
	}
}
function processReqChange_sub(div){
	// apenas quando o estado for "completado"
	if (req.readyState == 4) {
		// apenas se o servidor retornar "OK"
		if (req.status ==200) {
			// procura pela div id="pagina" e insere o conteudo
			// retornado nela, como texto HTML
			document.getElementById(div).innerHTML = req.responseText;
		}else{
		alert("Houve um problema ao obter os dados:n" + req.statusText);
		}
	}	
}


	function action(destino,div,get) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = destino+'?'+get;
		ajax_action(url,div);
	}
	function ajax_action(url,div){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = function() { processReqChange_action(div)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = function() { processReqChange_action(div)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_action(div){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				document.getElementById(div).style.display = "block";
				document.getElementById(div).innerHTML = req.responseText;
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}



	function troca_img(destino,id,id_get) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = destino+'?id='+id+'&id_get='+id_get;
		ajax_img(url);
	}
	function ajax_img(url){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_img;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = processReqChange_img;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_img(){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
			document.getElementById('monta').innerHTML = "";
			document.getElementById('monta').innerHTML = req.responseText;
			 var options2 =
				{
					zoomWidth: 250,
					zoomHeight: 250,
					zoomType:'reverse',
					title:false
				}
	
				jQuery(".jqzoom2").jqzoom(options2);
			
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	
	
	function monta_modelos(qtd) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = "adiciona_modelos.php?qtd="+qtd;
		ajax_modelos(url);
	}
	function ajax_modelos(url){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_modelos;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = processReqChange_modelos;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_modelos(){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
			// procura pela div id="pagina" e insere o conteudo
			// retornado nela, como texto HTML
			document.getElementById('modelos').innerHTML = "";
			document.getElementById('modelos').innerHTML = req.responseText;
			} else {
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	
	
	function exclui_modelo(id) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = "exclui_modelo.php?id="+id;
		ajax_exclui_modelos(url);
	}
	function ajax_exclui_modelos(url){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_exclui_modelos;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = processReqChange_exclui_modelos;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_exclui_modelos(){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
			// procura pela div id="pagina" e insere o conteudo
			// retornado nela, como texto HTML
			document.getElementById('monta_modelos').innerHTML = "";
			document.getElementById('monta_modelos').innerHTML = req.responseText;
			} else {
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	function formaMoeda(valor){
		num = valor;
	   x = 0;
	
	   if(num<0){
	      num = Math.abs(num);
	      x = 1;
	   }
	
	   if(isNaN(num)) num = "0";
	      cents = Math.floor((num*100+0.5)%100);

	   num = Math.floor((num*100+0.5)/100).toString();
	
	   if(cents < 10) cents = "0" + cents;
	      for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	         num = num.substring(0,num.length-(4*i+3))+'.'
	               +num.substring(num.length-(4*i+3));
	
	   ret = num + ',' + cents;
	
	   if (x == 1) ret = ' - ' + ret;
	   
	   return ret;
	}
	function strlen(string){
		 var len;
		 len = string.length;
		 return len;
	}
	function verifica_valor_promocao(valor_promocao){
		valor_promocao = valor_promocao.replace(",",".");
		valor_promocao = parseFloat(valor_promocao);
		var valor_produto = document.getElementById('valor').value.replace(",",".");
		valor_produto = parseFloat(valor_produto);
		if(!valor_produto){
			alert('Primeiro preencha o valor do produto.');
			document.getElementById('valor_prom').value = "";
			document.getElementById('valor').focus();
		}else{
			if(valor_promocao == valor_produto){
				$("#res_prom").html("&nbsp;<span style='color:red;'>Valor da Promoção é igual ao valor do produto!</span>");
			}else{
				if(valor_promocao > valor_produto){
					$("#res_prom").html("&nbsp;<span style='color:red;'>Valor da Promoção é maior que o valor do produto!</span>");
				}else{
					var porcentagem = valor_promocao * 100 / valor_produto;
					var porcentagem = 100 - porcentagem;
					porcentagem = formaMoeda(porcentagem);
					$("#res_prom").html("&nbsp;<span style='color:green;'>"+porcentagem+"% de desconto!</span>");
				}
			}
		}
	}
	function action_banner(destino,div,tipo){
	//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = destino+'?tipo='+tipo;
		ajax_action_banner(url,div,tipo);
	}
	function ajax_action_banner(url,div,tipo){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = function() { processReqChange_action_banner(div,tipo)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = function() { processReqChange_action_banner(div,tipo)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_action_banner(div,tipo){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				document.getElementById(div).style.display = "block";
				document.getElementById(div).innerHTML = req.responseText;
				banner_cadastrado(tipo);
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	function monta_video(tipo){
	//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = 'monta_quem_somos.php?tipo='+tipo;
		ajax_video(url);
	}
	function ajax_video(url){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_video;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = processReqChange_video;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_video(){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				document.getElementById("galeria").innerHTML = "";
				document.getElementById("galeria").innerHTML = req.responseText;
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	function monta_video_qs(tipo,arq){
	//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = 'monta_qs.php?tipo='+tipo+'&arq='+arq;
		ajax_video_qs(url);
	}
	function ajax_video_qs(url){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_video_qs;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = processReqChange_video_qs;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_video_qs(){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				document.getElementById("galeria").innerHTML = "";
				document.getElementById("galeria").innerHTML = req.responseText;
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	function adiciona_campos_banners(valor,numBanners){
		var falta = 7 - numBanners;
		if(valor > falta){
			if(falta < 10){
				falta = "0"+falta;	
			}
			alert('Valor deve ser no máximo '+falta);
			document.getElementById('qtd_banners').value = 0;
			adiciona_campos_banners('0',numBanners);
			return false;	
		}else{
	//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = 'adiciona_campos_banner.php?valor='+valor;
		ajax_campos_banners(url);
		}
	}
	function ajax_campos_banners(url){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_campos_banners;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = processReqChange_campos_banners;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_campos_banners(div){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				document.getElementById('banners_seleciona').style.display = "block";
				document.getElementById('banners_seleciona').innerHTML = req.responseText;
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	function banner_cadastrado(tipo) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = "banner_cadastrado.php?tipo="+tipo;
		ajax_banner_cadastrado(url,tipo);
	}
	function ajax_banner_cadastrado(url,tipo){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = function(){processReqChange_banner_cadastrado(tipo)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = function(){processReqChange_banner_cadastrado(tipo)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_banner_cadastrado(tipo){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
			// procura pela div id="pagina" e insere o conteudo
			// retornado nela, como texto HTML
				if(tipo == 2){
					var resposta = req.responseText;
					var larg_alt = resposta.split(";");
					var largura = larg_alt[0];
					var altura = larg_alt[1];
					
					var img_banner = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\" width='"+largura+"' height='"+altura+"' id=\"banner\" align=\"middle\"><param name=\"allowScriptAccess\" value=\"sameDomain\ /><param name=\"allowFullScreen\" value=\"false\" /><param name=\"movie\" value=\"../../images/banner/banner.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#000000\" /><embed src=\"../../images/banner/banner.swf\" quality=\"high\" bgcolor=\"#000000\" width='"+largura+"' height='"+altura+"' name=\"banner\" align=\"middle\" allowScriptAccess=\"sameDomain\" allowFullScreen=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object>";
					
					var saida = "<tr><td colspan=\"4\">Banner Animado (SWF):</td></tr><tr><td align=\"left\" colspan=\"4\"><table width=\"100%\" cellspacing=\"1\" cellpadding=\"0\"><tr><td wdth=\"100%\" colspan=\"4\">"+img_banner+"</td></tr></table></td></tr>";
					
					document.getElementById('banner_cadastrado').innerHTML = "";
					document.getElementById('banner_cadastrado').innerHTML = saida;
				}else{
					document.getElementById('banner_cadastrado').innerHTML = "";
					document.getElementById('banner_cadastrado').innerHTML = req.responseText;
				}
			} else {
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}

/////////////////////////////////////////////////	
/*FUNÇÕES PARA CONTROLE DA PARTE VISUAL DO SITE*/
/////////////////////////////////////////////////	

	//FUNÇÃO PARA INSERIR PRODUTOS NA CESTA DE PRODUTOS
	function insere_cesta(id_produto,tema) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = 'adiciona_sessao.php?id='+id_produto+'&tema='+tema;
		ajax_cesta(url,id_produto,tema);
	}
	function ajax_cesta(url,id_produto,tema){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = function(){processReqChange_cesta(id_produto,tema)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = function(){processReqChange_cesta(id_produto,tema)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_cesta(id_produto,tema){
		var nome = "img_cesta_"+id_produto;
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				jQuery("#modifica_cesta").fadeOut(500, function(){
					jQuery("#modifica_cesta").html(req.responseText);		
				});
				jQuery("#modifica_cesta").fadeIn(500, function(){
					
				});
				jQuery("#"+nome).html("<span onclick=\"remove_cesta('"+id_produto+"','0','"+tema+"');\" title=\"Remover este produto da cesta!\"><img src=\"images/temas/"+tema+"/remove_cesta.png\" width=\"20\" height=\"19\" border=\"0\" title=\"Remover este produto da cesta!\" class=\"png_bg\" ></span>");
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	
	//FUNÇÃO PARA REMOVER PRODUTOS DA CESTA DE PRODUTOS
	function remove_cesta(id_produto,tipo,tema) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = 'remove_sessao.php?id='+id_produto+'&tema='+tema;
		ajax_remove_cesta(url,id_produto,tipo,tema);
	}
	function ajax_remove_cesta(url,id_produto,tipo,tema){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = function(){processReqChange_remove_cesta(id_produto,tipo,tema)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = function(){processReqChange_remove_cesta(id_produto,tipo,tema)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_remove_cesta(id_produto,tipo,tema){
		var nome = "img_cesta_"+id_produto;
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				jQuery("#modifica_cesta").fadeOut(500, function(){
					jQuery("#modifica_cesta").html(req.responseText);		
				});
				jQuery("#modifica_cesta").fadeIn(500, function(){
					
				});
				jQuery("#"+nome).html("<span onclick=\"insere_cesta('"+id_produto+"','"+tema+"');\" title=\"Adicionar este produto &agrave; cesta!\"><img src=\"images/temas/"+tema+"/insere_cesta.png\" border=\"0\" title=\"Adicionar este produto &agrave; cesta!\" class=\"png_bg\" ></span>");
				if(tipo == "1"){
					window.location='cesta';
				}
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	
	//FUNÇÃO PARA INSERIR PRODUTOS NA CESTA DE PRODUTOS DE DENTRO DOS DETALHES
	function adiciona_cesta_detalhes(id_produto,tema) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = 'adiciona_sessao.php?id='+id_produto+'&tema='+tema;
		ajax_adiciona_detalhes(url,id_produto,tema);
	}
	function ajax_adiciona_detalhes(url,id_produto,tema){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = function(){processReqChange_adiciona_detalhes(id_produto,tema)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = function(){processReqChange_adiciona_detalhes(id_produto,tema)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_adiciona_detalhes(id_produto,tema){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				jQuery("#modifica_cesta").fadeOut(500, function(){
					jQuery("#modifica_cesta").html(req.responseText);		
				});
				jQuery("#modifica_cesta").fadeIn(500, function(){
					
				});
				jQuery("#cesta_detalhes").html("<span onclick=\"remove_cesta_detalhes('"+id_produto+"','"+tema+"');\" title=\"Remover este produto da cesta!\"><img src=\"images/temas/"+tema+"/cesta_remove.png\" border=\"0\" title=\"Remover este produto da cesta!\" class=\"png_bg\" ></span>&nbsp;Remover este produto da Cesta!");
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	//FUNÇÃO PARA REMOVER PRODUTOS DA CESTA DE PRODUTOS DE DENTRO DOS DETALHES
	function remove_cesta_detalhes(id_produto,tema) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = 'remove_sessao.php?id='+id_produto+'&tema='+tema;
		ajax_remove_detalhes(url,id_produto,tema);
	}
	function ajax_remove_detalhes(url,id_produto,tema){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = function(){processReqChange_remove_detalhes(id_produto,tema)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = function(){processReqChange_remove_detalhes(id_produto,tema)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_remove_detalhes(id_produto,tema){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				jQuery("#modifica_cesta").fadeOut(500, function(){
					jQuery("#modifica_cesta").html(req.responseText);		
				});
				jQuery("#modifica_cesta").fadeIn(500, function(){
					
				});
				jQuery("#cesta_detalhes").html("<span onclick=\"adiciona_cesta_detalhes('"+id_produto+"','"+tema+"');\" title=\"Adicionar este produto &agrave; cesta!\"><img src=\"images/temas/"+tema+"/cesta.png\" border=\"0\" title=\"Adicionar este produto &agrave; cesta!\" class=\"png_bg\" ></span>&nbsp;Adicionar este produto &agrave; Cesta!");
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	//FUNÇÃO PARA MOSTRAR|ESCONDER AS FORMAS DE PAGAMENTO DO DETALHE DO PRODUTO
	function mostra_formas(){
		var situacao = document.getElementById('formas_pagamento').style.display;
		if(situacao == "none"){//MOSTRA
			document.getElementById('formas_pagamento').style.display = "inline";
		}else{//ESCONDE
			document.getElementById('formas_pagamento').style.display = "none";
		}
	}
	
	//FUNÇÃO QUE TROCA AS IMAGENS DAS FOTOS DO DETALHE DO PRODUTO
	function monta_galeria(id_produto,foto,nro,nome,zoom,left,top){
		var foto_ativa = document.getElementById('foto_ativa').value;
		var nro_ativa = document.getElementById('foto').value;
		var zoom_ativa = document.getElementById('zoom_ativo').value;
		var left_ativa = document.getElementById('left_ativo').value;
		var top_ativa = document.getElementById('top_ativo').value;
		if(zoom == "sim"){
			var img_big_nova = "<a href=\"images/produtos/"+id_produto+"/large/"+foto+"\" class=\"jqzoom2\" title=\""+nome+"\" id=\"jqzoom_img\"><img src=\"images/produtos/"+id_produto+"/big/"+foto+"\" border=\"0\"></a>";
			var desc_info = "Passe o mouse para o zoom <img src=\"images/zoom.png\" border=\"0\" class=\"png_bg\">";
		}else{
			var img_big_nova = "<img src=\"images/produtos/"+id_produto+"/big/"+foto+"\" border=\"0\">";
			var desc_info = "";	
		}
		
		var img_mini_nova = "<img src=\"images/produtos/"+id_produto+"/small/"+foto_ativa+"\" border=\"0\" onclick=\"monta_galeria('"+id_produto+"','"+foto_ativa+"','"+nro+"','"+nome+"','"+zoom_ativa+"','"+left_ativa+"','"+top_ativa+"');\">";
		
		jQuery("#foto_big").fadeOut(500, function(){
			jQuery("#foto_big").html(img_big_nova);
			jQuery("#desc_info").html(desc_info);
			//INICIA O ZOOM
			inicia_zoom();	
			jQuery(".foto_produto a").css("margin-left", left+"px");
			jQuery(".foto_produto a").css("margin-top", top+"px");
		});
		jQuery("#foto_big").fadeIn(500, function(){
			
		});
		jQuery("#mini"+nro).fadeOut(500, function(){
			jQuery("#mini"+nro).html(img_mini_nova);		
		});
		jQuery("#mini"+nro).fadeIn(500, function(){
			
		});
		document.getElementById('foto_ativa').value = foto;
		document.getElementById('foto').value = nro;
		document.getElementById('zoom_ativo').value = zoom;
		document.getElementById('left_ativo').value = left;
		document.getElementById('top_ativo').value = top;
	}
	
	//FUNÇÃO QUE INICIA O PROCEDIMENTO DE ZOOM DA FOTO DO PRODUTO
	function inicia_zoom(){
		jQuery('.jqzoom2').jqzoom({
			zoomType: 'reverse',
			zoomWidth: 395,
			zoomHeight: 263
		});

	}
	
	//FUNÇÃO PARA CONTROLAR OS BOTÕES DE DESCRIÇÃO|COMENTÁRIOS|VÍDEOS DOS DETALHES DO PRODUTO
	function monta_descricao(id_produto,tipo) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = 'monta_descricao.php?id='+id_produto+'&tipo='+tipo;
		ajax_descricao(url,tipo);
	}
	function ajax_descricao(url,tipo){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = function(){processReqChange_descricao(tipo)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = function(){processReqChange_descricao(tipo)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_descricao(tipo){
		
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				if(tipo == "2"){
					var resp = req.responseText;
					var resposta = "<object width=\"384\" height=\"321\"><param name=\"movie\" value=\""+resp+"\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\""+resp+"\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"384\" height=\"321\"></embed></object>";	
				}else{
					if((tipo == "1")||(tipo == "3")){
						var resposta = req.responseText;
					}
				}
				jQuery("#descricao").fadeOut(500, function(){
					jQuery("#descricao").html(resposta);	
					if(tipo == "1"){
						jQuery("#descricao").css("text-align","left");
						jQuery("#tit_desc").removeClass();	
						jQuery("#tit_desc").addClass("titulo_active");
						jQuery("#tit_video").removeClass();	
						jQuery("#tit_video").addClass("titulo");	
						jQuery("#tit_coment").removeClass();	
						jQuery("#tit_coment").addClass("titulo");	
					}else{
						if(tipo == "2"){
							jQuery("#descricao").css("text-align","center");
							jQuery("#tit_desc").removeClass();	
							jQuery("#tit_desc").addClass("titulo");
							jQuery("#tit_coment").removeClass();	
							jQuery("#tit_coment").addClass("titulo");	
							jQuery("#tit_video").removeClass();	
							jQuery("#tit_video").addClass("titulo_active");	
						}else{
							if(tipo == "3"){
								jQuery("#descricao").css("text-align","left");
								jQuery("#tit_desc").removeClass();	
								jQuery("#tit_desc").addClass("titulo");
								jQuery("#tit_coment").removeClass();	
								jQuery("#tit_coment").addClass("titulo_active");	
								jQuery("#tit_video").removeClass();	
								jQuery("#tit_video").addClass("titulo");	
							}
						}
					}	
				});
				jQuery("#descricao").fadeIn(500, function(){
				
					
				});
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	//MARCA|DESMARCA SE A PESSOA GOSTOU OU NÃO DO PRODUTO NO COMENTÁRIO
	function marca_selecionado(tipo){
		document.getElementById('selecionado').value = tipo;
		if(tipo == "1"){
			jQuery("#gostei").html("<img src=\"images/gostei_active.png\" class=\"png_bg\" border=\"0\" title=\"Gostei deste Produto!\">&nbsp;<span style=\"color:green;\">Gostei</span>");
			jQuery("#nao_gostei").html("<img src=\"images/nao_gostei.png\" class=\"png_bg\" border=\"0\" title=\"N&atilde;o gostei deste Produto!\">&nbsp;N&atilde;o Gostei");
		}else{
			if(tipo == "2"){
				jQuery("#gostei").html("<img src=\"images/gostei.png\" class=\"png_bg\" border=\"0\" title=\"Gostei deste Produto!\">&nbsp;Gostei");
				jQuery("#nao_gostei").html("<img src=\"images/nao_gostei_active.png\" class=\"png_bg\" border=\"0\" title=\"N&atilde;o gostei deste Produto!\">&nbsp;<span style=\"color:red;\">N&atilde;o Gostei</span>");
			}
		}
	}
	
	// ABRE|FECHA O FORMULÁRIO DE COMENTÁRIOS SOBRE O PRODUTO
	function abre_comentario(){
		var estado = document.getElementById('adicionar_comentario').style.display;
		if(estado == "none"){
			document.getElementById('adicionar_comentario').style.display = "block";
			document.getElementById('btnComentario').disabled = false;
			var verifica_1 = document.getElementById('verifica_1').value;
			if(verifica_1 == 0){
				enviar_form_comentarios();
				document.getElementById('verifica_1').value = "1";
			}
		}else{
			if(estado == "block"){
				document.getElementById('btnComentario').disabled = true;
				document.getElementById('adicionar_comentario').style.display = "none";
			}
		}
	}
	
	//ENVIA COMENTÁRIOS ATRAVÉS DO FORMULÁRIO DE COMENTÁRIOS DOS DETALHES DOS PRODUTOS
	function enviar_form_comentarios(){
		 jQuery('#frmComentarios').submit(function(){
		 jQuery.post('adiciona_comentario.php',{	
			id_prod : jQuery('#id_prod').val(),
			nome_comentario : jQuery('#nome_comentario').val(),
			comentario : jQuery('#comentario').val(),
			selecionado : jQuery('#selecionado').val()
								 },
			 function(resposta){
				 if((resposta == "Nome e Comentário devem ser preenchidos.")||(resposta == "Você deve selecionar se gostou ou não do produto!")){
					document.getElementById('btnComentario').disabled = false;
					jQuery('#resposta').html(resposta); 
				 }else{
					jQuery('#resposta').html(resposta);
					document.getElementById('selecionado').value = "0";
					document.getElementById('nome_comentario').value = "Nome ou Apelido...";
					document.getElementById('comentario').value = "Deixe seu Comentário...";
					jQuery("#gostei").html("<img src=\"images/gostei.png\" class=\"png_bg\" border=\"0\" title=\"Gostei deste Produto!\">&nbsp;Gostei");
					jQuery("#nao_gostei").html("<img src=\"images/nao_gostei.png\" class=\"png_bg\" border=\"0\" title=\"N&atilde;o gostei deste Produto!\">&nbsp;N&atilde;o Gostei");
				 }
			 }
		 );
		 return false;
		 });
	}
	function desabilita_botao_envio(){
		document.getElementById('resposta').innerHTML = "Salvando comentário. Aguarde..";
		document.getElementById('btnComentario').disabled = true;
	}
	
	//MONTA FOTOS MINIATURAS DO QUEM SOMOS
	function troca_minis(start,tema,tipo) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = 'troca_minis.php?start='+start+'&tema='+tema+'&tipo='+tipo;
		ajax_minis(url);
	}
	function ajax_minis(url){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_minis;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = processReqChange_minis;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_minis(){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				jQuery("#galeria").fadeOut(500, function(){
					jQuery("#galeria").html(req.responseText);		
				});
				jQuery("#galeria").fadeIn(500, function(){
					
				});
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	
	//MONTA FOTOS MINIATURAS DO QUEM SOMOS
	function troca_minis_servicos(start,tema) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = 'troca_minis_servicos.php?start='+start+'&tema='+tema;
		ajax_minis_servicos(url);
	}
	function ajax_minis_servicos(url){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_minis_servicos;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = processReqChange_minis_servicos;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_minis_servicos(){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				jQuery("#galeria").fadeOut(500, function(){
					jQuery("#galeria").html(req.responseText);		
				});
				jQuery("#galeria").fadeIn(500, function(){
					
				});
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	//MONTA FOTO GRANDE DO QUEM SOMOS
	function monta_big(id_foto,tipo,destino) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = 'monta_big.php?id='+id_foto+'&tipo='+tipo+'&destino='+destino;
		ajax_big(url);
	}
	function ajax_big(url){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_big;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = processReqChange_big;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_big(){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				jQuery("#fto").fadeOut(500, function(){
					jQuery("#fto").html(req.responseText);		
				});
				jQuery("#fto").fadeIn(500, function(){
					
				});
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
/////////////////////////////////////////////////	
/*FUNÇÕES PARA CONTROLE DA PARTE VISUAL DO SITE*/
/////////////////////////////////////////////////	

	
	//MONTA FOTO GRANDE DO QUEM SOMOS
	function troca_topico(id_topico) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = 'troca_topico.php?id='+id_topico;
		ajax_topico(url);
	}
	function ajax_topico(url){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_topico;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = processReqChange_topico;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_topico(){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				document.getElementById('troca_texto').innerHTML = "";
				document.getElementById('troca_texto').innerHTML = req.responseText;
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	//MONTA FOTO GRANDE DO QUEM SOMOS
	function troca_topico_emp(id_topico) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = 'troca_topico_emp.php?id='+id_topico;
		ajax_topico_emp(url);
	}
	function ajax_topico_emp(url){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_topico_emp;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = processReqChange_topico_emp;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_topico_emp(){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				document.getElementById('topic').innerHTML = "";
				document.getElementById('topic').innerHTML = req.responseText;
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	//MONTA FOTO GRANDE DO QUEM SOMOS
	function troca_servicos(id_topico) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = 'troca_servicos.php?id='+id_topico;
		ajax_servicos(url,id_topico);
	}
	function ajax_servicos(url,id_topico){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = function(){processReqChange_servicos(id_topico)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = function(){processReqChange_servicos(id_topico)};
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_servicos(id_topico){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				document.getElementById('troca_servicos').innerHTML = "";
				document.getElementById('troca_servicos').innerHTML = req.responseText;
				troca_titulo(id_topico);
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	
	//MONTA FOTO GRANDE DO QUEM SOMOS
	function troca_titulo(id_topico) {
		//FUNÇÃO QUE MONTA A URL E CHAMA A FUNÇÃO AJAX
		url = 'troca_titulo.php?id='+id_topico;
		ajax_titulo(url);
	}
	function ajax_titulo(url){
		req = null;
		// Procura por um objeto nativo (Mozilla/Safari)
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange_titulo;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send(null);
		// Procura por uma versão ActiveX (IE)
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
		req.onreadystatechange = processReqChange_titulo;
		req.open("GET",url+"&rand="+Math.ceil ( Math.random() * 100000 ),true);
		req.send();
		}
		}
	}
	function processReqChange_titulo(){
		// apenas quando o estado for "completado"
		if (req.readyState == 4) {
			// apenas se o servidor retornar "OK"
			if (req.status ==200) {
				// procura pela div id="pagina" e insere o conteudo
				// retornado nela, como texto HTML
				document.getElementById('troca_titulo').innerHTML = "";
				document.getElementById('troca_titulo').innerHTML = req.responseText;
			}else{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}	
	}
	
	
	
function mostra_infos(id,qtd){
	var i = 0;
	for(i=0;i<qtd;i++){
		var verifica = "infos"+i;
		if(verifica == id){
			jQuery("#"+id).slideDown();
			jQuery("#t_"+id).removeClass();
			jQuery("#t_"+id).addClass("ativo");
		}else{
			jQuery("#infos"+i).slideUp();
			jQuery("#t_infos"+i).removeClass();
			jQuery("#t_infos"+i).addClass("normal");
		}
	}
}
