
VerifiqueTAB = false;

function Mostra(quem, tammax) {

	if ( (quem.value.length == tammax) && (VerifiqueTAB) ) {
		var i=0,j=0, indice=-1;
		for (i=0; i<document.forms.length; i++) {
			for (j=0; j<document.forms[i].elements.length; j++) {
				if (document.forms[i].elements[j].name == quem.name) {
					indice=i;
					break;
				}
			}

			if (indice != -1)
			break;
		}

		for (i=0; i<=document.forms[indice].elements.length; i++) {
			if (document.forms[indice].elements[i].name == quem.name) {
				while ( (document.forms[indice].elements[(i+1)].type == "hidden") &&
				(i < document.forms[indice].elements.length) ) {
					i++;
				}

				document.forms[indice].elements[(i+1)].focus();
				VerifiqueTAB=true;
				break;
			}
		}
	}
}
function confirmarExclusao(endereco,id){
	if(confirm('Voce tem certeza que deseja apagar o endereco '+endereco+'?')) {
		document.getElementById("form_" + id).submit();
	}
}

function ShowCepPopup(){
    window.open('http://www.correios.com.br/servicos/cep/cep_default.cfm','ShowCep','location=no,resize=yes, width=730,height=400,left=18,top=18,maximized=0,scrollbars=1');
}

function PararTAB(quem) { VerifiqueTAB=false; }

function ChecarTAB() { VerifiqueTAB=true; }

function openWin(page,width,height) {
	window.open(page, "","width="+ width +",height="+ height +",scrollbars=1,menubar=yes")
}

function divChangeText(divId,text) {
	if (document.getElementById) {
		document.getElementById(divId).innerHTML = text;
	}
}
<!-- FIM 1 -->

<!-- INICIO 1: Mostra iframe -->

var oTimeOut;

function ProcessHiddenAds()  { /* oTimeOut = window.setInterval("CheckAdLoaded()","4000"); */   }

function CheckAdLoaded() {
	try {
		if (document.getElementById('AdPage').style.visibility == 'visible')  {
				ToggleAd();  ClearAdInterval();
		} else {
			ToggleAd();
		}
		return;
	}
	catch (exception)  { return; }
}

function ClearAdInterval() {
	try {
		window.clearInterval(oTimeOut);
	} catch (exception) {
		return;
	}
}

var page;
function ToggleAd(link,sDisp,height) {
	var sExp='';

	if (!height) { height=200; }

	sDispImg = 'AdPageArrow';

	var text = "<IFRAME frameborder=\"0\" src=\""+ link +"\" width=100% height=100%></IFRAME>";

	try {
		if (document.getElementById(sDisp).style.visibility == 'visible' && page == text) {
			document.getElementById(sDisp).style.height='0';
			document.getElementById(sDisp).style.visibility = 'hidden';
			document.getElementById(sDisp).innerHTML = "";
		}

		else {
			page = text;
			document.getElementById(sDisp).style.height=height;
			document.getElementById(sDisp).style.visibility = 'visible';
			document.getElementById(sDisp).innerHTML = text;
		}
	}
	catch (exception)  {  }
}


<!-- INI 1 -->
/* Transforma dados no formato de moeda */
function formatCurrency(num) {
	num = replaceChar(num);
	num = num.toString().replace(/\$|\,/g,'');

	if(isNaN(num)) { num = "0"; }

	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();

	if(cents<10)
		cents = "0" + cents;

	return (((sign)?'':'-') + num + '.' + cents);
}
<!-- FIM -->

<!-- INI 1 -->
function replaceChar(entry) {
	out = ","; /* replace this */
	add = "."; /* with this */
	temp = "" + entry; /* temporary holder */

	while (temp.indexOf(out)>-1) {
		pos= temp.indexOf(out);
		temp = "" + (temp.substring(0, pos) + add +
		temp.substring((pos + out.length), temp.length));
	}
	return temp;
}
<!-- FIM -->

<!-- INI: Verifica codigo -->
// Codel Validation.
function check_code(e) {
	ok = "abcdefghijklmnopqrstuvxzyw1234567890_";

	for(i=0; i < e.length ;i++) {
		if(ok.indexOf(e.charAt(i))<0){
			return false;
		}
	}

	return true;
}
<!-- FIM -->

<!-- INI: Verifica Part Number -->
// PartNumber Validation.
function check_partnumber(e) {
	ok = "1234567890";

	for(i=0; i < e.length ;i++) {
		if(ok.indexOf(e.charAt(i))<0){
			return false;
		}
	}

	return true;
}
<!-- FIM -->

<!-- INI: Verifica email -->
// Email Validation. Written by PerlScriptsJavaScripts.com
function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){
			return (false);
		}
	}

//	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);
		}
//	}
}
<!-- FIM -->

<!-- INI: Funcao para validar CPF -->
function validaCPF(cpf) {
	erro = new String;
	var cpf = cpf.replace(/\D/g,"");
	if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n";
	var nonNumbers = /\D/;
	if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! \n\n";
	if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999") {
		erro += "Numero de CPF invalido!"
	}
	var a = [];
	var b = new Number;
	var c = 11;
	for (i=0; i<11; i++){
		a[i] = cpf.charAt(i);
		if (i < 9) b += (a[i] * --c);
	}
	if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
	b = 0;
	c = 11;
	for (y=0; y<10; y++) b += (a[y] * c--);
	if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
	if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])) {
		erro +="Digito verificador com problema!";
	}
	if (erro.length > 0){
		return false;
	}
	return true;
}

<!-- INI: Funcao para validar CNPJ -->
function validaCNPJ(CNPJ) {
	erro = new String;
	if (CNPJ.length < 14) erro += "Necessario preencher corretamente o numero do CNPJ! \n\n";
/*	if ((CNPJ.charAt(2) != ".") || (CNPJ.charAt(6) != ".") || (CNPJ.charAt(10) != "/") || (CNPJ.charAt(15) != "-")){
		if (erro.length == 0) erro += "Necessario preencher corretamente o numero do CNPJ! \n\n";
	}*/
/*	//substituir os caracteres que não são números
	if(document.layers && parseInt(navigator.appVersion) == 4){
		x = CNPJ.substring(0,2);
		x += CNPJ. substring (3,6);
		x += CNPJ. substring (7,10);
		x += CNPJ. substring (11,15);
		x += CNPJ. substring (16,18);
		CNPJ = x;
	} else {*/
		CNPJ = CNPJ.replace (".","");
		CNPJ = CNPJ.replace (".","");
		CNPJ = CNPJ.replace ("-","");
		CNPJ = CNPJ.replace ("/","");
//	}

	var nonNumbers = /\D/;
	if (nonNumbers.test(CNPJ)) erro += "A verificacao de CNPJ suporta apenas numeros! \n\n";
	var a = [];
	var b = new Number;
	var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
	for (i=0; i<12; i++){
		a[i] = CNPJ.charAt(i);
		b += a[i] * c[i+1];
	}
	if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
	b = 0;
	for (y=0; y<13; y++) {
		b += (a[y] * c[y]);
	}
	if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; }
	if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){
		erro +="Dígito verificador com problema!";
	}

	if (erro.length > 0){
		return false;
	}

	return true;
}

// Funçes adicionadas por Renato em 09/12/06

String.prototype.trim = function() { return this.replace(new RegExp("^\\s+|\\s+$", "gi"), ""); } // Remove os espaços em branco no início e final de uma string

		// Formata os nmeros digitados de acordo com o documento
		function formatDoc(element,docType) {
			var txt = element.value.replace(/\D/g,"");
			if (element.value.length > 0) {
				switch (docType) {
					case 'ie':
						element.value = txt.replace(/(\d\d\d)(\d\d\d)(\d\d\d)(\d\d\d)/, "$1.$2.$3.$4" ); break; 
					case 'cpf':
						element.value = txt.replace(/(\d\d\d)(\d\d\d)(\d\d\d)(\d\d)/, "$1.$2.$3-$4" ); break;
					case 'cnpj':
						element.value = txt.replace(/(\d\d)(\d\d\d)(\d\d\d)(\d\d\d\d)(\d\d)/, "$1.$2.$3/$4-$5" ); break;
					case 'cep':
						element.value = txt.replace(/(\d\d\d\d\d)(\d\d\d)/, "$1$2" ); break;
					case 'tel':
						element.value = txt.replace(/(\d?\d\d\d)(\d\d\d\d)/, "$1-$2" ); break;
 				}
			}
		}

		// Aceita somente dçitos
		function checkDigits(e) {
			var tecla = e.keyCode
			if (!(tecla == 46 ||tecla == 8 ||tecla == 9 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 || tecla >= 35 && tecla <= 39)) {
				return false;
			} else { return true; }
		}

<!-- FIM -->

// Luiz Fernando 30/01/2007
// Controle de DIVs
function Hide(string){
	document.getElementById(string).style.display = "none";
}
function Show(string){
	document.getElementById(string).style.display = "";
}
function seeUnsee(string){
	var string = document.getElementById(string);
	if(string.style.display == "")
		string.style.display = "none";
	else{
		string.style.display = "";
	}
}

var timerDepartamentos;

function mostrarDepartamentos() {
	clearTimeout(timerDepartamentos);
	document.getElementById('todososdepartamentos').style.visibility = 'visible';
	document.forms.search.ctg.style.visibility = 'hidden';
}

function esconderDepartamentos() {
	timerDepartamentos = setTimeout('esconderDepartamentosMESMO()', 200)
}

function esconderDepartamentosMESMO() {
	clearTimeout(timerDepartamentos);
	document.getElementById('todososdepartamentos').style.visibility = 'hidden';
	document.forms.search.ctg.style.visibility = 'visible';
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// Mostra Compra Rapida
var timerBotaoCompraRapida = new Array();

function mostrarBotaoCompraRapida (idproduto) {
    clearTimeout(timerBotaoCompraRapida[idproduto]);
    var o = document.getElementById('botaocomprarapida_' + idproduto);
    if (o) {
        o.style.display = 'block';
    }
}

function esconderBotaoCompraRapida (idproduto) {
    esconderBotaoCompraRapidaMesmo(idproduto);
}

function esconderBotaoCompraRapidaMesmo (idproduto) {
    clearTimeout(timerBotaoCompraRapida[idproduto]);
    var o = document.getElementById('botaocomprarapida_' + idproduto);
    if (o) {
        o.style.display = 'none';
    }
}


var timerCompraRapida = new Array();

function mostrarCompraRapida (idproduto) {
	clearTimeout(timerCompraRapida[idproduto]);
	var o = document.getElementById('comprarapida_' + idproduto);
	if (o.style.display == 'none' || o.style.display == '') {
		o.style.left = Math.round(document.body.parentNode.scrollLeft + ((window.innerWidth || document.documentElement.offsetWidth || 0) - 650) / 2) + 'px';
		o.style.display = 'block';
		//
		var imgs = o.getElementsByTagName('IMG');
		var tmp;
		for (var i = 0; i < imgs.length; i ++) {
			tmp = imgs[i].getAttribute('altsrc');
			if ((tmp != '') && (tmp != undefined)) {
				imgs[i].src = imgs[i].getAttribute('altsrc');
			}
		}
	}
}

function escondeCompraRapida (idproduto) {
	clearTimeout(timerCompraRapida[idproduto]);
	timerCompraRapida[idproduto] = setTimeout('escondeCompraRapidaMesmo(' + idproduto + ')', 200);
}

function escondeCompraRapidaMesmo (idproduto) {
	var o = document.getElementById('comprarapida_' + idproduto);
	if (o) {
		o.style.display = 'none';
	}
}

function imprimirFlash(arquivo,w,h,transparente,params,id) {
	document.write('<object'+(((typeof id != 'undefined') && (navigator.appVersion.indexOf('MSIE') > -1))?' id="'+id+'"':'')+' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"' + ((typeof w == 'undefined')?'':' width="'+w+'"') + ((typeof h == 'undefined')?'':' height="'+h+'"') + '>');
	document.write('<param name="movie" value="'+arquivo+'">');
	document.write('<param name=quality value=high>');
	document.write('<param name="menu" value="false">');
	if (typeof params != 'undefined') {
		var p = '';

		for (var i in params) {
			p += i + '="' + params[i] + '" ';
			document.write('<param name="'+i+'" value="'+params[i]+'">');
		}
	}
	if (transparente) {
		document.write('<param name="wmode" value="transparent">');
	}
	document.write('<embed'+(((typeof id != 'undefined') && (navigator.appVersion.indexOf('MSIE') < 0))?' id="'+id+'"':'')+' src="'+arquivo+'" quality="high" pluginspage="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"' + ((typeof w == 'undefined')?'':' width="'+w+'"') + ((typeof h == 'undefined')?'':' height="'+h+'"') + ' ');
	if (transparente) {
		document.write('wmode="transparent" ');
	}
	document.write(p);
	document.write(' menu="false"></embed>');
	document.write('</object>');
}

function escreverOpiniao (produto) {
	window.divopen('/index?page=product/product_review_form&prd=' + produto + '&light=1&only_page=1&rvw=',495,598);
	return false;
}

