$(document).ready(function() {
	atualizajs();
});

function atualizajs() {
	$("input[type=text][name*=cep]").mask("99999-999");
	$("input[type=text][name*=data]").mask("99/99/9999");
	$("input[type=text][name*=nascimento]").mask("99/99/9999");
	$("input[type=text][name*=_fone_]").mask("(99) 9999-9999");
	$("input[type=text][name*=_telefone]").mask("(99) 9999-9999");
}


function passa(dir,div,pg) {
	if(dir=='D') { dirs = new Array("right","left"); }
	else if(dir=='E') { dirs = new Array("left","right"); }
	$("#"+div).hide("slide", { direction: dirs[0] }, 1000, function(){ 
		$.get(pg+'?dir='+dir, function(r){ 
					$("#"+div).html(r); 
					$("#prLoad1").slideUp();
					$("#"+div).show("slide", { direction: dirs[1] }, 1000);
		});
	});
}
function SetF(id, vv) {
	try { $(id)[0].type; }
	catch(e) {return}
	if(!$(id)[0].type) {
		var type = $("input[@name="+id.replace("#","")+"]")[0].type;
		var o = $("input[@name="+id.replace("#","")+"]");
	} else {
		var type = $(id)[0].type;
		var o = $(id);
	}
	if(typeof vv == "string" || typeof vv == "number"){
		v = []; 
		v.push(vv); 
	}
	else v = vv;
	switch(type) {
		case "radio":
		case "checkbox":
		case "select-multiple":
		case "select-one":
				o.val(v);
				break;
		default:
			o.val(v.join(','));
	}
}

function checkCadNews() {
	var erro = '';
	$("#msgNewsE").html('');
	if($("#fnews_nome").val()=='' || $("#fnews_nome").val()=='Digite seu nome') { erro = 'Preencha seu nome'; }
	else if($("#fnews_email").val()=='' || $("#fnews_email").val()=='Digite seu e-mail') { erro = 'Preencha seu e-mail'; }
	else if(CheckMail($("#fnews_email").val())) { erro = 'E-mail incorreto, verifique!'; }

	if(erro!='') {
		$("#msgNewsE").html(erro);
		$("#msgNewsE").effect("pulsate", { times: 1 }, 500);	
	} else {
		$.post("_lateralNewsletter.php",{newsAct:'add',fnews_nome:$("#fnews_nome").val(),fnews_email:$("#fnews_email").val()}, function(r){ $("#msgNewsE").html(r); $("#fnews_nome,#fnews_email").val(''); });	
	}
	return false;
}

function cadastropessoa(tipo) {
	if (tipo=="fisica")	{
		$("#tdnome").html("<strong>Nome Completo</strong>");
		$("#tdcpf").html("<strong>CPF</strong>");
		$("#tdrg").html("R.G.");
		$("#tddata").html("<strong>Data de Nascimento</strong>");
		$("#trdata").show();
		$("#trsexo").show();
	}
	if (tipo=="juridica")	{
		$("#tdnome").html("<strong>Razão Social</strong>");
		$("#tdcpf").html("<strong>CNPJ</strong>");
		$("#tdrg").html("Inscrição Estadual");
		$("#trdata").hide();
		$("#trsexo").hide();
	}

}

function validaFreteConsulta() {
	if ($('#sul_quantidade').val()=='') {
		alert("Preencha a quantidade desejada");
		$('#sul_quantidade').focus();
		return false;
	}
	if ($('#sul_cep').val()=='') {
		alert("Preencha o Cep de Destino");
		$('#sul_cep').focus();
		return false;
	}
	if ($('#sul_nome').val()=='') {
		alert("Preencha o Nome do cotnato");
		$('#sul_nome').focus();
		return false;
	}
	if ($('#sul_email').val()=='') {
		alert("Preencha o Email do contato");
		$('#sul_email').focus();
		return false;
	}
	if ($('#sul_telefone').val()=='') {
		alert("Preencha o Telefone do contato");
		$('#sul_telefone').focus();
		return false;
	}
	if ($('#sul_cidade').val()=='') {
		alert("Preencha a Cidade do contato");
		$('#sul_cidade').focus();
		return false;
	}
	if ($('#sul_uf').val()=='') {
		alert("Preencha o Estado do contato");
		$('#sul_uf').focus();
		return false;
	}
	var dadosform = $('form#formConFrete').serialize();

	$.get("_sendavisoproduto.php",dadosform, function(r){ $("#consutafrete").html(r); });			
	return true;
}

function validaIntermediacao() {
	if ($('#sul_quantidade').val()=='') {
		alert("Preencha a quantidade desejada");
		$('#sul_quantidade').focus();
		return false;
	}
	if ($('#sul_cep').val()=='') {
		alert("Preencha o Cep de Destino");
		$('#sul_cep').focus();
		return false;
	}
	if ($('#sul_nome').val()=='') {
		alert("Preencha o Nome do cotnato");
		$('#sul_nome').focus();
		return false;
	}
	if ($('#sul_email').val()=='') {
		alert("Preencha o Email do contato");
		$('#sul_email').focus();
		return false;
	}
	if ($('#sul_telefone').val()=='') {
		alert("Preencha o Telefone do contato");
		$('#sul_telefone').focus();
		return false;
	}
	if ($('#sul_cidade').val()=='') {
		alert("Preencha a Cidade do contato");
		$('#sul_cidade').focus();
		return false;
	}
	if ($('#sul_uf').val()=='') {
		alert("Preencha o Estado do contato");
		$('#sul_uf').focus();
		return false;
	}
	var dadosform = $('form#formIntermedia').serialize();

	$.get("_sendavisoproduto.php",dadosform, function(r){ $("#intermediacao").html(r); });			
	return true;
}

function votaEnq(id,pos) {
	if (!$('input[type=radio][name*=resp]:checked').val()) {
		$("#msgEnq").html('Selecione uma opção!');
		$("#msgEnq").effect("pulsate", { times: 1 }, 500);	
	} else {
		$("#msgEnq").html('');
		$.get("_lateralEnquetes.php",{act:'votar',ide:id,posi:pos,resp:$('input[type=radio][name*=resp]:checked').val()}, function(r){ $("#boxEnquetes").html(r); });			
	}
	return false;
}



function UnSetF(slist) {
	var l = slist.split(',');
	for(var i=0; i < l.length; i++)	{ SetF(l[i],''); }
}


function checkBoxMarcarTodos(){
    t = document.form_pedidos;
    for(x = 0; x < t.elements.length; x++) {
       if ( t.elements[x].type == 'checkbox') {
            t.elements[x].checked = t.todos_pedidos.checked;
       }
    }
}

function checap(idcheck) {
	if($('#'+idcheck).is(":checked")==false) { $('#'+idcheck).attr('checked',true); }
//	if(!$(idcheck).checked){ $(idcheck).checked = "checked"; }
}


function getAJAX(url,parametros,localdiv) {
	$('#carregando').show();
	$.get(url+'?'+parametros, function(r){ $("#"+localdiv).html(r); $('#carregando').hide(); });
}

function getAJAXc(url,parametro,localdiv) {
	$.get(url+'?'+parametro, function(r){ $("#"+localdiv).html(r); });
}


function verificacep() {
	if ($('#cep').val().length==9) {
		return true;
	} else {
		alert('Preencha o CEP corretamente');
		return false;
	}
}

function verificacupom() {
	if ($('#cupom').val().length==18) {
		return true;
	} else {
		alert('Preencha o código do Cupom de Desconto corretamente');
		return false;
	}
}

function chamaResumo(url,parametro,localdiv,ativo,inativo) {
	$('#tr_'+ativo).className = 'selecionado';
	$('#a_'+ativo).className = 'linkbranco';
	$('#tr_'+inativo).className = 'nselecionado';
	$('#a_'+inativo).className = 'linkazul';
	getAJAX(url,parametro,localdiv);
}

function postData() {
	$('carregando').show();
	$('botsalvar').disabled = true;
	$('botcancelar').disabled = true;
	$('mensagem').hide();
	$('formData').submit();
}

function checaopcrelatorio() {
	var ar = $('caixadarelato').getElementsByTagName('input');
	var tem = false;
	for(var i=0; i < ar.length; i++) {
		if(ar[i].checked){ 
			tem = true;
		}
	}
	if(tem == false) { 
		alert("Selecione uma opção de relatorio!"); 
		return false; 
	} 
	return true;
}

function checaopcpagamento() {
	var boolValid = false;
	var sele;
	$('.opcPagamento').each(function() {
		if ( $(this).is(':checked') ) {
			boolValid = true;
			sele = $(this).val();
		}
	});
	if(boolValid == false) { 
		alert("Selecione uma opção pagamento!"); 
		return false; 
	} 
	if ($('#interface_'+sele).val()=='pgto_visa') {
		$('#formPgto').attr('target','mpg_popup');
		mpg_popup = window.open("", "mpg_popup","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,screenX=0,screenY=0,left=0,top=0,width=765,height=540");
		window.location="https://www.retemaferramentas.com.br/redirecionacbp.php";
	}
	if ($('#interface_'+sele).val()=='pgto_mastercielo') {
		$('#formPgto').attr('target','mpg_popup');
		mpg_popup = window.open("", "mpg_popup","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,screenX=0,screenY=0,left=0,top=0,width=765,height=540");
		window.location="https://www.retemaferramentas.com.br/redirecionacbp.php";
	}
	if ($('#interface_'+sele).val()=='pgto_mastercard') {
		$('#formPgto').attr('target','mpg_popup');
		mpg_popup = window.open("", "mpg_popup","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,screenX=0,screenY=0,left=0,top=0,width=780,height=540");
		window.location="aguardemaster.php";
	}
	if ($('#interface_'+sele).val()=='pgto_diners') {
		$('#formPgto').attr('target','mpg_popup');
		mpg_popup = window.open("", "mpg_popup","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,screenX=0,screenY=0,left=0,top=0,width=780,height=540");
		window.location="aguardediners.php";
	}
	if ($('#interface_'+sele).val()=='pgto_itaushop') {
		$('#formPgto').attr('target','mpg_popup');
		mpg_popup = window.open('', 'mpg_popup', 'toolbar=yes,menubar=yes,resizable=yes,status=no,scrollbars=yes,width=675,height=485');	
		window.location="aguardeitau.php";
	}
	if ($('#interface_'+sele).val()=='pgto_caixadeb') {
		$('#formPgto').attr('target','mpg_popup');
		mpg_popup = window.open('', 'mpg_popup', 'toolbar=yes,menubar=yes,resizable=yes,status=no,scrollbars=yes,width=675,height=485');	
		window.location="aguardecaixa.php";
	}

	return true;
}

function checaopcproduto() {

	var boolValid = false;
	$('.opcProd').each(function() {
		if ( $(this).is(':checked') ) {
			boolValid = true;
			$('#opcid').val($(this).val());
		}
	});

	if ($('#quant').val()<1)	{
		alert("A quantidade deve ser maior que zero"); 
		return false; 
	}
	if(boolValid == false) { 
		alert("Selecione uma opção do produto!"); 
		return false; 
	} 
	return true;
}

function editaopc(id,tipo1,valor1,valor1f,tipo2,valor2,valor2f,preco,peso,cubico,estoque,limitestoque,ref) {
	$('#opc_id').val(id);
	$('#opc_tipo1').val(tipo1);
	$('#opc_valor1').val( valor1);
	$('#opc_valor1f').val(valor1f);
	$('#opc_tipo2').val(tipo2);
	$('#opc_valor2').val(valor2);
	$('#opc_valor2f').val(valor2f);
	$('#opc_preco').val(preco);
	$('#opc_peso').val(peso);
	$('#opc_cubico').val(cubico);
	$('#opc_estoque').val(estoque);
	$('#opc_limitestoque').val(limitestoque);
	$('#opc_ref').val(ref);
}

function limpaopc() {
	$('#opc_id').val('0');
	$('#opc_tipo1').val('');
	$('#opc_valor1').val('');
	$('#opc_valor1f').val('');
	$('#opc_tipo2').val('');
	$('#opc_valor2').val('');
	$('#opc_valor2f').val('');
	$('#opc_preco').val('');
	$('#opc_peso').val('');
	$('#opc_cubico').val('');
	$('#opc_estoque').val('');
	$('#opc_limitestoque').val('');
	$('#opc_ref').val('');
	$('#opcimagem').val('');
}

function atualizafrete(prazo,peso,volume,frete,obsfrete) {
	if (frete=='0,00') {
        frete = 'Gr&aacute;tis';
	} else {
		frete = 'R$ '+frete;
	}

	$('div_ped_prazo').innerHTML = prazo+' dias';
	$('div_ped_peso').innerHTML = peso+' kg';
	$('div_ped_volume').innerHTML = volume+' cm3';
	$('div_ped_valfrete').innerHTML = frete;
	$('div_ped_obsfrete').innerHTML = obsfrete;
}
function atualizavalores(frete,total) {
	if (frete=='0,00') {
        frete = 'Gr&aacute;tis';
	} else {
		frete = 'R$ '+frete;
	}
	$('div_totfrete').innerHTML = '(+) '+frete;
	$('div_totvalor').innerHTML = '(=) R$ '+total;
}


function retValChecked(obj) {
	if (obj.checked){ 
		return obj.value;
	} else {
		return "";
	}
}
	
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function montaFlash(swf, width, height, id, wmode, cache) {
noCache = cache || cache == undefined ? "" : "?" + new Date();
monta_swf = "";
monta_swf += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" id=\""+ id +"\" width=\""+ width +"\" height=\""+ height +"\" title=\"\">";
monta_swf += "<param name=\"movie\" value=\""+ swf + noCache +"\" />";
monta_swf += "<param name=\"wmode\" value=\""+ wmode +"\" />";
monta_swf += "<param name=\"quality\" value=\"high\" />";
monta_swf += "<param name=\"menu\" value=\"false\" />";
monta_swf += "<param name=\"volume\" value=\"1\" />";
monta_swf += "<embed src=\""+ swf + noCache +"\" quality=\"high\" wmode=\""+ wmode +"\" volume=\"100\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" menu=\"false\" id=\""+ id +"\" width=\""+ width +"\" height=\""+ height +"\"></embed>";
monta_swf += "</object>";
document.write(monta_swf);
}

function validar(Form) {
	var invalid, s;
	invalid = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

	var s;


// inicio de verificacao de cnpj ou cpf
	if (Form.value.length == 0) {
		alert("O CNPJ/CPF é um campo obrigatório !");
		Form.focus();
		return false;	}
		
	s = limpa_string(Form.value);
	
	
	// checa se é cpf	
	if (s.length == 11) {
		if (valida_CPF(Form.value) == false ) {
			alert("O CPF não é válido !");
			Form.focus();
			return false;	}
     }
     
     // checa se é cgc
	else if (s.length == 14) {
		if (valida_CGC(Form.value) == false ) {
			alert("O CNPJ não é válido !");
			Form.focus();
			return false;	}
			}
		else {
			alert("O CPF/CNPJ não é válido !");
			Form.focus();
			return false;
		}

     return true;
}
	
function limpa_string(S){
	// Deixa so' os digitos no numero
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";

	for (var i=0; i<S.length; i++)	{
		digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0)	{
			temp=temp+digito	}
	} //for

	return temp
}
// fim da funcao


function valida_CPF(s)	{
	var i;
	s = limpa_string(s);
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
        if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
        return true;
}

function valida_CGC(s)
{
	var i;
	s = limpa_string(s);
	var c = s.substr(0,12);
	var dv = s.substr(12,2);
	var d1 = 0;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
        if (d1 == 0) return false;
        d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
	return true;
}

function tomaius(obje) {
	texto = eval("document.formins."+obje+".value");
	eval("document.formins."+obje+".value=texto.toUpperCase()");
}

function enderecoEntrega() {
	if($('#end_igual').is(":checked")==true) {
		$('#usu_entcep').val($('#usu_cep').val());
		$('#usu_entendereco').val($('#usu_endereco').val());
		$('#usu_entnumero').val($('#usu_numero').val());
		$('#usu_entcomplemento').val($('#usu_complemento').val());
		$('#usu_entbairro').val($('#usu_bairro').val());
		$('#usu_entcidade').val($('#usu_cidade').val());
		$('#usu_entestado').val($('#usu_estado').val());
	} else {
		$('#usu_entcep,#usu_entendereco,#usu_entnumero,#usu_entcomplemento,#usu_entbairro,#usu_entcidade,#usu_entestado').val('');
	}
}

function apenasNumero(objCampo,e) {
	var scan	= getKey(e);
	var tecla	= String.fromCharCode(scan);
	var mask	= "0123456789"
	if (scan == 13 || scan == 8 || scan == 0) return true;
	if (mask.indexOf(tecla) == -1) {
		return false;
	}
	return true;
}

function apenasValor(objCampo,e) {
	var scan	= getKey(e);
	var tecla	= String.fromCharCode(scan);
	var mask	= "0123456789."
	if (scan == 13 || scan == 8 || scan == 0) return true;
	if (mask.indexOf(tecla) == -1) {
		return false;
	}
	return true;
}
function getKey(e)
{
	return (window.event) ? event.keyCode : e.which
}
function popWin(URL,NAME,WIDTH,HEIGHT,RESIZE,SCROLL) {
	winId = window.open(URL, "popUp","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,screenX=0,screenY=0,left=0,top=0,width="+WIDTH+",height="+HEIGHT);
//	window.location = URL;
/*
   winId = window.open(URL,NAME,'width='+WIDTH+',height='+HEIGHT+',resizable='+RESIZE+',scrollbars='+SCROLL+',menubar=no,toolbar=no,location=no,directories=no,status=no');
*/
	var clientWidth = screen.availWidth;
	var clientHeight = screen.availHeight;
	var xPos = (clientWidth - WIDTH)/2;
	var yPos = (clientHeight - HEIGHT)/2;
	winId.moveTo(xPos,yPos);
}

function CheckMail(str){
	var testresults
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
		testresults=false
	else { 
		testresults=true
	     }
	return (testresults)
}


function verificaIdPublico(valor,id_user) {
	
	if (valor!=id_user)
		$('age_publi').checked=true;
	
}

function enviacep() {
	if ($('#cep').val().length!=9) {
		alert('Digite o CEP corretamente');
		return false;
	}
	return true;
}


function trocaentradafile(tipo) {
	if (tipo==1) {
		$('entradafile').innerHTML = '<input name="arquivofoto" type="file" id="arquivofoto" class="field" />';
	} else {
		$('entradafile').innerHTML = '<input name="url" type="text" id="url" class="field" style="width:250px;" />';
	}
	return true;
}

function cChange(div,clas) { var a = div.split(','); for(x=0;x<=a.length-1;x++) { document.getElementById(a[x]).className = clas; } }

function checkContato() {
	$("#msgE").html('Enviando...');								 
	cChange('c_nome,c_email,c_cidade,c_tel_fixo,c_tel_celular,c_assunto,c_mensagem','fld')
	var e = new Array();
	var c = 0;
	if($("#c_nome").val()=='') { e[c++] = 'Preencha seu <b>Nome</b>'; cChange('c_nome','fldE'); }
	if($("#c_email").val()=='') { e[c++] = 'Preencha seu <b>E-mail</b>'; cChange('c_email','fldE'); }
	else if(CheckMail($("#c_email").val())) { e[c++] = 'Preencha seu <b>E-mail, corretamente</b>'; cChange('c_email','fldE'); }
	if($("#c_cidade").val()=='') { e[c++] = 'Preencha sua <b>Cidade</b>'; cChange('c_cidade','fldE'); }
	if($("#c_tel_fixo").val()=='' && $("#c_tel_celular").val()=='') { e[c++] = 'Preencha pelo menos 1 <b>Telefone</b>'; cChange('c_tel_fixo,c_tel_celular','fldE'); }
	if($("#c_assunto").val()=='') { e[c++] = 'Preencha seu <b>Assunto</b>'; cChange('c_assunto','fldE'); }
	if($("#c_mensagem").val()=='') { e[c++] = 'Preencha sua <b>Mensagem</b>'; cChange('c_mensagem','fldE'); }
	if(e.length>1) {
		$("#msgE").html('Preencha os campos em <b>Vermelho</b>');
	} else if(e.length==1) {
		$("#msgE").html(e.toString());
	} else if(e.length<=0) {
		$("#fContato").ajaxSubmit({ resetForm:false, success:function(r) { trataRetorno('fContato',r); } }); 
//		$("#fContato").ajaxSubmit({ target:"#msgE", resetForm:true, success:function() { /* alert('Thanks for your comment!'); */ }  }); 
		return false;
	}
	return false;
}

function trataRetorno(f,s) {
	var a = s.split("|"); 
	if(a[0]==0) { 
		$("#msgE").html(a[1]);
	} else if(a[0]==1) {
		$("#msgE").html(a[1]);
		$("#"+f).resetForm();
	}
}

function retornava() {

	if ($('#ava_texto').val()=='') {
		alert("Preencha seu Comentário");
		$('#ava_texto').focus();
		return false;
	}
	if ($('#ava_nome').val()=='') {
		alert("Preencha seu Nome");
		$('#ava_nome').focus();
		return false;
	}
	if ($('#ava_email').val()=='') {
		alert("Preencha seu Email");
		$('#ava_email').focus();
		return false;
	}

	getAJAXc('_comenta.php','proid='+$('#proid').val()+'&actc=insert&ava_texto='+$('#ava_texto').val()+'&ava_nome='+$('#ava_nome').val()+'&ava_email='+$('#ava_email').val()+'&ava_cidade='+$('#ava_cidade').val()+'&ava_estado='+$('#ava_estado').val(),'produto-opiniao');
}
