/*
------------------------------------------------------------------------------------------
© Digital Industry - 2007
Autor: Rafael Cronemberger de Assis

Aslan Armarinhos
------------------------------------------------------------------------------------------
*/

window.defaultStatus 	= "ASLAN - Armarinhos e Aviamentos";
strMsgErro				= "Atenção para o seguinte erro:\n\n";

var isNS4 				= (navigator.appName=="Netscape")?1:0;
var isNN 				= (navigator.appName.indexOf("Netscape")!=-1);

var nome_dia = new Array ('Domingo','Segunda-feira','Terça-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sábado');
var nome_mes = new Array ('janeiro','fevereiro','março','abril','maio','junho','julho','agosto','setembro','outubro','novembro','dezembro');

var isIE = document.all;
var mouseX = 0;
var mouseY = 0;

function getMouseXY(e){ 
	if (!e) e = window.event;
	if (e){ 
	mouseX = isIE ? (e.clientX + document.body.scrollLeft) : e.pageX;
	mouseY = isIE ? (e.clientY + document.body.scrollTop) : e.pageY;
	}
}

/*
if (!popupTransacaoCartao){
	var popupTransacaoCartao="";
}else{

}
*/

function displayMenuDireita(){
	var nmLargura 	= screen.Width;
	var nmAltura 	= screen.Height;

	if(nmLargura >= 1024){
		displayLayer("destaque");
	}else{
		hideLayer("destaque");
	}
}

function hideLayer(stNomeLayer){
	if(document.getElementById(stNomeLayer)){
		document.getElementById(stNomeLayer).style.display = "none";
	}
}

function disabledEntrega(){
	document.frmFormaEntrega.fgFormaEntrega[0].disabled=true;
	document.frmFormaEntrega.fgFormaEntrega[1].disabled=true;
}

function confirmDelCar(idCarrinho){
	if(confirm("Deseja retirar esse item do carrinho de compras?")){
		document.location.href=("../carrinho/carrinho.asp?stAction=delCarrinho&idCarrinho="+idCarrinho+"");
	}
}

 
function deleteEndereco(idEndereco) {
		if(confirm("Deseja realmente apagar este endereco ?")){
		document.location.href=("../pagamento/EnderecosEntrega.asp?cAction=1&idEndereco="+idEndereco+"");
	}
}



function displayLayer(stNomeLayer){
	if(document.getElementById(stNomeLayer)){	
		document.getElementById(stNomeLayer).style.display = "";
	}
}

function validLogin(objForm){
	if(objForm.stLoginCadastro2.value=="" ||  objForm.stLoginCadastro2.value=="(Cpf/Cnpj)"){
		alert(strMsgErro + "O campo login não pode estar em branco.");
		objForm.stLoginCadastro2.value="";
		objForm.stLoginCadastro2.focus();
		return false;
	}else if(objForm.stSenhaCadastro2.value==""){
		alert(strMsgErro + "O campo senha não pode estar em branco.");
		objForm.stSenhaCadastro2.value="";
		objForm.stSenhaCadastro2.focus();
		return false;
	}else{
		return true;
	}
}

function hideLayerDelay(stNomeLayer){
	window.setTimeout("hideLayer('"+stNomeLayer+"');", 6000);
}

function displayFlash(largura, altura, arquivo){
	//document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+largura+'" height="'+altura+'" id="teste" align="middle">');
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'+largura+'" height="'+altura+'" id="teste" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" /><param name="wmode" value="transparent" />');
	//document.write('<param name="movie" value="'+arquivo+'" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><embed src="'+arquivo+'" wmode="transparent" quality="best" width="'+largura+'" height="'+altura+'" name="teste" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('<param name="movie" value="'+arquivo+'" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><embed src="'+arquivo+'" wmode="transparent" quality="best" width="'+largura+'" height="'+altura+'" name="teste" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"/>');
	document.write('</object>');
}

function displayCad(stTipoCadastro){
	if(stTipoCadastro == "F"){
		displayLayer("div_pFisica");
		hideLayer("div_pJuridica");
		document.frmCadFisica.stNome.focus();
	}else if(stTipoCadastro == "J"){
		displayLayer("div_pJuridica");
		hideLayer("div_pFisica");
		document.frmCadJuridica.stRazaoSocialCadastro.focus();
	}else{
		displayLayer("div_pFisica");
		hideLayer("div_pJuridica");
	}
}

function blockChars(e){
	if (!e) var e = window.event;
	if (e){
	   if(e.keyCode) 
		{ _TXT = e.keyCode; } 
	   else if(e.which) 
		{ _TXT = e.which; }
	   if(_TXT > 47 && _TXT < 58) { 
			return true; 
		} 
		else {
			if (_TXT == 13)			// enter
				{ return true; }
			else if (_TXT == 9)		// tab
			    { return true; }
			else if (_TXT == 37)	// left arrow
			    { return true; }
			else if (_TXT == 39)	// right arrow
			    { return true; }				
			else if (_TXT != 8) 	// backspace
				{ return false; } 
			else 
				{ return true; }
		}
	}
}

function pasteTextNumbers(ctrl,e){
	var PastedText;
	if (!e) var e = window.event;
	if (e){
	   if(e.keyCode) 
		{ _TXT = e.keyCode; } 
	   else if(e.which) 
		{ _TXT = e.which; }
	   if((_TXT == 80) && (isIE) && (ctrl.value == '0')) { 
   			PastedText = ctrl.createTextRange();
  			PastedText.execCommand("Paste");
			if (isNaN(ctrl.value)){
				ctrl.value = ""
			}
			return false;
		} 
		else {
			return blockChars(e);
		}
	}	
}

function pasteText(ctrl,e){
	var PastedText;
	if (!e) var e = window.event;
	if (e){
	   if(e.keyCode) 
		{ _TXT = e.keyCode; } 
	   else if(e.which) 
		{ _TXT = e.which; }
	   if((_TXT == 80) && (isIE) && (ctrl.value == '0')) { 
   			PastedText = ctrl.createTextRange();
  			PastedText.execCommand("Paste");
			return false;
		} 
	}	
}

function blockSpecialChars(e){
	if (!e) var e = window.event;
	if (e){		
		if(e.keyCode){
			if ((e.keyCode > 32 && e.keyCode < 48) || (e.keyCode > 57 && e.keyCode < 65) || (e.keyCode > 90 && e.keyCode < 97)) return false;
		}else if (e.which){
			if((e.which > 32 && e.which < 48) || (e.which > 57 && e.which < 65) || (e.which > 90 && e.which < 97)) return false;
		}
	}
}

function blockCharsEnter(e) {
	if (!e) var e = window.event;
	if (e){
	   if(e.keyCode) 
		{ _TXT = e.keyCode; } 
	   else if(e.which) 
		{ _TXT = e.which; }
	   if(_TXT > 47 && _TXT < 58) { 
			return true; 
		} 
		else {
			if (_TXT == 13)			// enter
				{ return false; }
			else if (_TXT == 9)		// tab
			    { return true; }
			else if (_TXT == 37)	// left arrow
			    { return true; }
			else if (_TXT == 39)	// right arrow
			    { return true; }				
			else if (_TXT != 8) 	// backspace
				{ return false; } 
			else 
				{ return true; }
		}
	}
}

function onlyNumbers(){
	if ((event.keyCode > 94 && event.keyCode < 106) || (event.keyCode == 37 || event.keyCode == 39) && !(event.keyCode == 188 || event.keyCode == 190 || event.keyCode == 16)){ 
		return true
	}else if ((event.keyCode  < 48 || event.keyCode > 57) && !(event.keyCode == 8 || event.keyCode == 46 || event.keyCode == 9 || event.keyCode == 22)){
		return false
	}
}

function validaCnpj(nmCnpj){
	var i;
	var c 	= nmCnpj.substr(0,12);
	var dv 	= nmCnpj.substr(12,2);
	var d1 	= 0;
	for (i = 0; i < 12; i++){
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
	if (d1 == 0){
		alert(strMsgErro + "O CNPJ informado não é válido.");
		return false;
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1){
		alert(strMsgErro + "O CNPJ informado não é válido.");
		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){
		alert(strMsgErro + "O CNPJ informado não é válido.");
		return false;
	}
	return true;
}

function validaCpf(nmCpf){
	valor = true;
	erro 	= new String;

	if(nmCpf.length < 11) erro += "São necessários 11 dígitos para verificação do CPF.\n";
	var nonNumbers = /\D/;
	if (nonNumbers.test(nmCpf)) erro += "A verificação de CPF suporta apenas números.\n";
	if (nmCpf == "00000000000" || nmCpf == "11111111111" || nmCpf == "22222222222" || nmCpf == "33333333333" || nmCpf == "44444444444" || nmCpf == "55555555555" || nmCpf == "66666666666" || nmCpf == "77777777777" || nmCpf == "88888888888" || nmCpf == "99999999999"){
		erro += "Número de CPF invalido."
	}

	var a = [];
	var b = new Number;
	var c = 11;
	for (i=0; i<11; i++){
		a[i] = nmCpf.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 ((nmCpf.charAt(9) != a[9]) || (nmCpf.charAt(10) != a[10])){
		erro +="O número do CPF é inválido.";
	}
	if (erro.length > 0){
		alert(strMsgErro + erro);
		return false;
	}
	return true;
}

function getInicialFocus(){
	document.frmContato.stNome.focus();
}

function clearField(objField){
	if(objField.value =="Qtd." || objField.value =="0" || objField.value ==0){
		objField.value="";
	}else{
		return false;
	}
}

function validFormCommerce(objForm){
	var boChecked 		= ""
	var nmTotalCores	= 0
	var count = 0

	try{
		nmTotalCores = objForm.nmIdCor.length;
	}
	
	catch(exc){
		nmTotalCores = 0
	}

	if(nmTotalCores == 0){
		alert("Esse produto não está disponível no momento.");
		return false;
	}		
	
	if(!nmTotalCores){
		nmTotalCores = 1

		if(objForm.nmIdCor.checked==true){
			count = count + parseInt(objForm.nmQtdCor.value);			
			boChecked = true;
		}
	}else{
		for (i=0; i < nmTotalCores; i++){
			if(objForm.nmIdCor[i].checked==true){
				count = count + parseInt(objForm.nmQtdCor[i].value);
				boChecked = true;
			}
		}
	}

	// Agulhas Tulip Sortidas
	if((objForm.stCodigoProduto.value == "02604") && (parseInt(count) < 12)){
		alert("Você selecionou " + count + " estojo(s).\nO mínimo para este produto é de 12 estojos.");
		return false;
	}
/*
	if(nmTotalCores == 0){
		alert(strMsgErro + "Esse produto não está disponível para seu carrinho de compras.");
		return false;
	}
*/

	if(boChecked == ""){
		alert("Selecione uma opção de côr, modelo ou tamanho para esse produto\nmesmo quando única e, em seguida, digite a quantidade desejada.");
		return false;
	}else{
		return true;
	}
	return false;
}

function checkField(objCheck, nmIdField){
	if(objCheck.checked == true){
		document.getElementById(nmIdField).disabled=false;
		document.getElementById(nmIdField).value="";
		document.getElementById(nmIdField).focus();
	}else{
		document.getElementById(nmIdField).disabled=true;
		document.getElementById(nmIdField).value="Qtd.";
	}
}

function verifyFieldCommerce(objField, nmIdField, nmValorEstoque){
	if(objField.value =="" || objField.value=="0" || objField.value==0){
		document.getElementById(nmIdField).checked=false;
		objField.value="QTD.";
		objField.disabled=true;		
	}
	
	if(objField.value != ""){
		if(objField.value > nmValorEstoque){
			alert(strMsgErro + "Quantidade ultrapassou disponibilidade no estoque.\nNo momento existe(m) "+nmValorEstoque+" unidade(s) no estoque.");
			document.getElementById(nmIdField).checked=false;
			objField.value="QTD.";
			objField.disabled=true;
		}
	}
}

function displayEndereco(stTipoEndereco){
	if(stTipoEndereco == ""){
		alert(strMsgErro + "Favor selecionar uma Categoria.");
		return false;
	}else	if(stTipoEndereco == "loja"){
		document.getElementById("stRotulo").style.display = "none";
		document.getElementById("stRotulo").value = "";		
		document.getElementById("stEstado").style.display = "none";
		document.getElementById("stCidade").style.display = "none";	
		document.getElementById("stGrupoEndereco").style.display = "none";		
		document.frmEnderecos.action = "?stAction=loja";
		
		document.frmEnderecos.submit();
		
	}else if(stTipoEndereco == "revendedor"){
		document.getElementById("stRotulo").style.display = "";	
		document.getElementById("stRotulo").value = "Revendedores:";			
		document.getElementById("stEstado").style.display = "";
		document.getElementById("stEstado").value = "selecione";		
		document.getElementById("stEstado").focus();
		document.getElementById("stCidade").style.display = "none";
		document.getElementById("stGrupoEndereco").style.display = "none";			
		document.frmEnderecos.action = "?stAction=revendedor";
		
	}else if(stTipoEndereco == "representante"){
		document.getElementById("stRotulo").style.display = "";	
		document.getElementById("stRotulo").value = "Representantes:";			
		document.getElementById("stEstado").style.display = "";
		document.getElementById("stEstado").value = "selecione";		
		document.getElementById("stEstado").focus();		
		document.getElementById("stCidade").style.display = "none";
		document.getElementById("stGrupoEndereco").style.display = "none";			
		document.frmEnderecos.action = "?stAction=representante";
	}
}

function hideMenuProdutos(){
	hideLayer("destaque");
}

function displayCidade(nmIdCidade){
	if(nmIdCidade == "" || nmIdCidade == 0){
		alert(strMsgErro + "Favor selecionar alguma Cidade.");
		return false;
	}else{

		if(document.frmEnderecos.stCategoria.value != "representante"){
			document.getElementById("stGrupoEndereco").style.display = "";
		}else{
			document.frmEnderecos.submit();
		}
			

		if(document.getElementById("stEstado").value == ""){
			alert(strMsgErro + "Favor selecionar o Estado.");
			document.getElementById("stEstado").focus();
			return false;
		}
		//document.frmEnderecos.submit();
	}
}

function displayGrupo(){
	if(document.getElementById("stCategoria").value == ""){
		alert(strMsgErro + "Favor selecionar a Categoria.");
		document.getElementById("stCategoria").focus();
		return false;
	}else if(document.getElementById("stEstado").value == ""){
		alert(strMsgErro + "Favor selecionar o Estado.");
		document.getElementById("stEstado").focus();
		return false;
	}else if(document.getElementById("stCidade").value == ""){
		alert(strMsgErro + "Favor selecionar a Cidade.");
		document.getElementById("stCidade").focus();
		return false;
	}else if(document.getElementById("stGrupoEndereco").value == ""){
		alert(strMsgErro + "Favor selecionar o Grupo.");
		document.getElementById("stGrupoEndereco").focus();
		return false;
	}else{
		document.frmEnderecos.action = "?stAction=revendedor";
		document.frmEnderecos.submit();
	}
}

function Dados(valor){
	if (valor == ""){
		alert(strMsgErro + "Favor selecionar algum Estado.");
		return false;
	}

	if(document.getElementById("stCategoria").value == "revendedor"){
		document.getElementById("stCidade").style.display = "";
		document.getElementById("stCidade").focus();
	}else{
		document.getElementById("stGrupoEndereco").style.display = "none";
		document.getElementById("stCidade").style.display = "";
		document.frmEnderecos.action = "?stAction=representante";
		document.getElementById("stEstado").style.display = "";
		document.getElementById("stEstado").focus();
	}

	try{
		ajax = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	
	catch(e){
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		}
		
		catch(ex){
			try{
				ajax = new XMLHttpRequest();
			}

			catch(exc){
				ajax = null;
			}
		}
	}

	if(ajax){
		document.frmEnderecos.stCidade.options.length = 1;
		idOpcao  = document.getElementById("opcoes");
		
		ajax.onreadystatechange = function(){
			if(ajax.readyState == 1){
				idOpcao.innerHTML = "Carregando...";
			}

			if(ajax.readyState == 4 ){
				if(ajax.responseXML){
					processXML(ajax.responseXML);
				}else{
					idOpcao.innerHTML = "Favor selecionar o Estado.";
				}
			}
		}

		var params = "stEstado="+valor;
		
		if(document.frmEnderecos.action == "?stAction=representante"){
			ajax.open("POST", "xmlRepresentante.asp", true);
		}else{
			ajax.open("POST", "xmlEndereco.asp", true);
		}

		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		
		ajax.send(params);
	}
}

function processXML(obj){
	var dataArray   = obj.getElementsByTagName("cidade");

	if(dataArray.length > 0){
		for(var i = 0 ; i < dataArray.length ; i++) {
			var item = dataArray[i];

			var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
			var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;

			idOpcao.innerHTML = "Selecione a cidade";

			var novo = document.createElement("option");
			novo.setAttribute("id", "opcoes");
			novo.value = codigo;
			novo.text  = descricao;
			document.frmEnderecos.stCidade.options.add(novo);
		}
	}else{
		idOpcao.innerHTML = "";
		alert("Sua busca não retornou resultados.")
	}	  
}

function validateFormContatoCorporativo(obj_form){
	if(obj_form.stNome.value==""){
		alert(strMsgErro+"O campo Nome não pode estar em branco.");
		obj_form.stNome.focus();
		return false;
	}else if(obj_form.stEmail.value==""){
		alert(strMsgErro+"O campo E-mail não pode estar em branco.");
		obj_form.stEmail.focus();
		return false;
	}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj_form.stEmail.value)){
		alert(strMsgErro+"O campo E-mail não foi preenchido corretamente.");
		obj_form.stEmail.focus();
		return false;
	}else if(obj_form.stConfirmaEmail.value==""){
		alert(strMsgErro+"O campo confirmação de e-mail não pode estar em branco.");
		obj_form.stConfirmaEmail.focus();
		return false;
	}else if(obj_form.stConfirmaEmail.value != obj_form.stEmail.value){
		alert(strMsgErro+"O campo confirmação de e-mail não é idêntico ao campo e-mail.");
		obj_form.stConfirmaEmail.focus();
		return false;		
/*	}else if(obj_form.nmDdd.value==""){
		alert(strMsgErro+"O campo DDD não pode estar em branco.");
		obj_form.nmDdd.focus();
		return false;
	}else if(obj_form.nmTel.value==""){
		alert(strMsgErro+"O campo Telefone não pode estar em branco.");
		obj_form.nmTel.focus();
		return false;	*/  
	}else if(obj_form.fgAssunto.value==""){
		alert(strMsgErro+"O campo Assunto não pode estar em branco.");
		obj_form.fgAssunto.focus();
		return false;
	}else if(obj_form.stMensagem.value==""){
		alert(strMsgErro+"O campo Mensagem não pode estar em branco.");
		obj_form.stMensagem.focus();
		return false;
	}else{
		return true;
	}
	return false;	
}

function validateFormDeposito(obj_form){

	if(obj_form.banco[0].checked==false&&obj_form.banco[1].checked==false&&obj_form.banco[2].checked==false){
		alert(strMsgErro+"Indique o banco no qual foi realizado o depósito.");
		return false;
	}else if(obj_form.nmValorDeposito.value==""||obj_form.nmValorDeposito.value=='0,00'){
		alert(strMsgErro+"Informe o valor depositado.");
		obj_form.nmValorDeposito.focus();
		return false;
	}else if(obj_form.nmDiaDeposito.value==""){
		alert(strMsgErro+"Informe o dia do depósito.");
		obj_form.nmDiaDeposito.focus();
		return false;
	}else if(obj_form.nmMesDeposito.value==""){
		alert(strMsgErro+"Informe o mês do depósito.");
		obj_form.nmMesDeposito.focus();
		return false;
	}else if(obj_form.nmAnoDeposito.value==""){
		alert(strMsgErro+"Informe o ano do depósito.");
		obj_form.nmAnoDeposito.focus();
		return false;
	}else{
		return true;
	}
	return false;
		
}

function validateFormContato(obj_form){
	if(obj_form.stNome.value==""){
		alert(strMsgErro+"O campo Nome não pode estar em branco.");
		obj_form.stNome.focus();
		return false;
	}else if(obj_form.stEmail.value==""){
		alert(strMsgErro+"O campo E-mail não pode estar em branco.");
		obj_form.stEmail.focus();
		return false;
	}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj_form.stEmail.value)){
		alert(strMsgErro+"O campo E-mail não foi preenchido corretamente.");
		obj_form.stEmail.focus();
		return false;
	}else if(obj_form.stConfirmaEmail.value==""){
		alert(strMsgErro+"O campo confirmação de e-mail não pode estar em branco.");
		obj_form.stConfirmaEmail.focus();
		return false;
	}else if(obj_form.stConfirmaEmail.value != obj_form.stEmail.value){
		alert(strMsgErro+"O campo confirmação de e-mail não é idêntico ao campo e-mail.");
		obj_form.stConfirmaEmail.focus();
		return false;		
/*	}else if(obj_form.nmDdd.value==""){
		alert(strMsgErro+"O campo DDD não pode estar em branco.");
		obj_form.nmDdd.focus();
		return false;
	}else if(obj_form.nmTel.value==""){
		alert(strMsgErro+"O campo Telefone não pode estar em branco.");
		obj_form.nmTel.focus();
		return false;	 
	}else if (obj_form.tipocli[0].checked == false && obj_form.tipocli[1].checked == false && obj_form.tipocli[2].checked == false && obj_form.tipocli[3].checked == false && obj_form.tipocli[4].checked == false && obj_form.tipocli[5].checked == false) {
	    alert(strMsgErro+"Escolha entre pessoa física, empresa ou outra identificação.");
		return false;	
	}else if(obj_form.tipocli[1].checked == true && obj_form.subtipcli[0].checked == false && obj_form.subtipcli[1].checked == false && obj_form.subtipcli[2].checked == false && obj_form.subtipcli[3].checked == false) {
        alert(strMsgErro+"Escolha o tipo de sua empresa.");
		return false;		
	}else if(obj_form.tipocli[1].checked == true && obj_form.subtipcli[1].checked == true && obj_form.outrocomercio.value=="") {
        alert(strMsgErro+"Defina seu outro tipo de Comercio.");
		return false;		
	}else if(obj_form.tipocli[1].checked == true && obj_form.subtipcli[3].checked == true && obj_form.outrasindustrias.value=="") {
        alert(strMsgErro+"Defina seu outro tipo de Industria.");
		return false;		
	}else if(obj_form.tipocli[5].checked == true && obj_form.outrotipo.value == "" ) {
        alert(strMsgErro+"Defina seu (outro tipo).");	
		return false; */ 
	}else if(obj_form.fgAssunto.value==""){
		alert(strMsgErro+"O campo Assunto não pode estar em branco.");
		obj_form.fgAssunto.focus();
		return false;
	}else if(obj_form.stMensagem.value==""){
		alert(strMsgErro+"O campo Mensagem não pode estar em branco.");
		obj_form.stMensagem.focus();
		return false;
	}else{
		return true;
	}
	return false;
}

function validateFormContatoErro(obj_form){		
	if(obj_form.stNome.value.replace(/^\s+|\s+$/g,"")==""){
		alert(strMsgErro+"O campo Nome não pode estar em branco.");
		obj_form.stNome.focus();
		return false;
	}else if(obj_form.stEmail.value==""){
		alert(strMsgErro+"O campo E-mail não pode estar em branco.");
		obj_form.stEmail.focus();
		return false;
	}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj_form.stEmail.value)){
		alert(strMsgErro+"O campo E-mail não foi preenchido corretamente.");
		obj_form.stEmail.focus();
		return false;
	}else if(obj_form.stConfirmaEmail.value==""){
		alert(strMsgErro+"O campo confirmação de e-mail não pode estar em branco.");
		obj_form.stConfirmaEmail.focus();
		return false;
	}else if(obj_form.stConfirmaEmail.value != obj_form.stEmail.value){
		alert(strMsgErro+"O campo confirmação de e-mail não é idêntico ao campo e-mail.");
		obj_form.stConfirmaEmail.focus();
		return false;		
/*	}else if(obj_form.nmDdd.value==""){
		alert(strMsgErro+"O campo DDD não pode estar em branco.");
		obj_form.nmDdd.focus();
		return false;
	}else if(obj_form.nmTel.value==""){
		alert(strMsgErro+"O campo Telefone não pode estar em branco.");
		obj_form.nmTel.focus();
		return false;	*/
	}else if(obj_form.stMensagem.value==""){
		alert(strMsgErro+"O campo Mensagem não pode estar em branco.");
		obj_form.stMensagem.focus();
		return false; 			
	}else{
		return true;
	}
	return false;
}

function validateFormContatoRepresentante(obj_form){
	if(obj_form.stRazaoSocial.value.replace(/^\s+|\s+$/g,"")==""){
		alert(strMsgErro+"O campo Razão Social não pode estar em branco.");
		obj_form.stRazaoSocial.focus();
		return false;
	}else if(obj_form.stCnpj.value==""){
		alert(strMsgErro+"O campo CNPJ não pode estar em branco !!");
		obj_form.stCnpj.focus();
		return false;
	}else if(obj_form.stCnpj.value.length != 14){
		alert(strMsgErro+"O CNPJ deve ter 14 caracteres numéricos !!");		
		obj_form.stCnpj.focus();
		return false;		
	}else if(!validaCnpj(obj_form.stCnpj.value)){
		obj_form.stCnpj.focus();
		return false;		
	}else if(obj_form.stEstado.value==""){
		alert(strMsgErro+"Favor selecionar um estado.");
		obj_form.stEstado.focus();
		return false;
	}else if(obj_form.stCidade.value.replace(/^\s+|\s+$/g,"")==""){
		alert(strMsgErro+"O campo Cidade não pode estar em branco.");
		obj_form.stCidade.focus();
		return false;		
	}else if(obj_form.stNome.value.replace(/^\s+|\s+$/g,"")==""){
		alert(strMsgErro+"O campo Nome não pode estar em branco.");
		obj_form.stNome.focus();
		return false;
	}else if(obj_form.stEmail.value==""){
		alert(strMsgErro+"O campo E-mail não pode estar em branco.");
		obj_form.stEmail.focus();
		return false;
	}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj_form.stEmail.value)){
		alert(strMsgErro+"O campo E-mail não foi preenchido corretamente.");
		obj_form.stEmail.focus();
		return false;
	}else if(obj_form.stConfirmaEmail.value==""){
		alert(strMsgErro+"O campo confirmação de e-mail não pode estar em branco.");
		obj_form.stConfirmaEmail.focus();
		return false;
	}else if(obj_form.stConfirmaEmail.value != obj_form.stEmail.value){
		alert(strMsgErro+"O campo confirmação de e-mail não é idêntico ao campo e-mail.");
		obj_form.stConfirmaEmail.focus();
		return false;		
/*	}else if(obj_form.nmDdd.value==""){
		alert(strMsgErro+"O campo DDD não pode estar em branco.");
		obj_form.nmDdd.focus();
		return false;
	}else if(obj_form.nmTel.value==""){
		alert(strMsgErro+"O campo Telefone não pode estar em branco.");
		obj_form.nmTel.focus();
		return false;	
	}else if(obj_form.stMensagem.value==""){
		alert(strMsgErro+"O campo Mensagem não pode estar em branco.");
		obj_form.stMensagem.focus();
		return false;  */ 			
	}else{
		return true;
	}
	return false;
}

function validateFormNewsLetter(obj_form){
	if(obj_form.stNome.value==""){
		alert(strMsgErro+"O campo Nome não pode estar em branco.");
		obj_form.stNome.focus();
		return false;
	}else if(obj_form.stEmail.value==""){
		alert(strMsgErro+"O campo E-mail não pode estar em branco.");
		obj_form.stEmail.focus();
		return false;
	}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj_form.stEmail.value)){
		alert(strMsgErro+"O campo E-mail não foi preenchido corretamente.");
		obj_form.stEmail.focus();
		return false;
	}else if(obj_form.stConfirmaEmail.value==""){
		alert(strMsgErro+"O campo confirmação de e-mail não pode estar em branco.");
		obj_form.stConfirmaEmail.focus();
		return false;
	}else if(obj_form.stConfirmaEmail.value != obj_form.stEmail.value){
		alert(strMsgErro+"O campo confirmação de e-mail não é idêntico ao campo e-mail.");
		obj_form.stConfirmaEmail.focus();
		return false;		
/*	}else if(obj_form.nmDdd.value==""){
		alert(strMsgErro+"O campo DDD não pode estar em branco.");
		obj_form.nmDdd.focus();
		return false;
	}else if(obj_form.nmTel.value==""){
		alert(strMsgErro+"O campo Telefone não pode estar em branco.");
		obj_form.nmTel.focus();
		return false;	  */
	}else if (obj_form.tipocli[0].checked == false && obj_form.tipocli[1].checked == false && obj_form.tipocli[2].checked == false) {
	    alert(strMsgErro+"Escolha entre pessoa física, empresa ou outra identificação.");
		return false;	
	}else if(obj_form.tipocli[1].checked == true && obj_form.subtipcli[0].checked == false && obj_form.subtipcli[1].checked == false && obj_form.subtipcli[2].checked == false && obj_form.subtipcli[3].checked == false) {
        alert(strMsgErro+"Escolha o tipo de sua empresa.");
		return false;		
	}else if(obj_form.tipocli[1].checked == true && obj_form.subtipcli[1].checked == true && obj_form.outrocomercio.value=="") {
        alert(strMsgErro+"Defina seu outro tipo de comércio.");
		return false;		
	}else if(obj_form.tipocli[1].checked == true && obj_form.subtipcli[3].checked == true && obj_form.outrasindustrias.value=="") {
        alert(strMsgErro+"Defina seu outro tipo de indústria.");
		return false;		
	}else if(obj_form.tipocli[2].checked == true && obj_form.outrotipo.value == "" ) {
        alert(strMsgErro+"Defina seu (outro tipo).");	
		return false;
	}else{
		return true;
	}
	return false;
}

function validateFormLembrete(obj_form){
	if(obj_form.stEmailCadastro.value==""){
		alert(strMsgErro+"O campo E-mail não pode estar em branco.");
		obj_form.stEmailCadastro.focus();
		return false;
	}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj_form.stEmailCadastro.value)){
		alert(strMsgErro+"O campo E-mail não foi preenchido corretamente.");
		obj_form.stEmailCadastro.focus();
		return false;
	}
}

function validateCadastroFisicaNumero(obj_form){
	if (!obj_form.chkNumero){
		return true;
	}
	if (obj_form.chkNumero.checked==true){ 
		obj_form.stNumero.value="sem nº";		
		obj_form.stNumero.disabled=true;
	}
	else{ 
		obj_form.stNumero.value="";
		obj_form.stNumero.disabled=false; 
		obj_form.stNumero.focus();
	}	
}

function validateCadastroFisicaComplemento(obj_form){
	if (!obj_form.chkComplemento){
		return true;
	}	
	if (obj_form.chkComplemento.checked==true){ 
		obj_form.stComplemento.value="";		
		obj_form.stComplemento.disabled=true; 
	}
	else{ 
		obj_form.stComplemento.disabled=false; 
	}	
}

function validateCadFisica(obj_form, fgAjaxAtualiza, idUsuario){
	if(obj_form.stNome.value==""){
		alert(strMsgErro+"O campo Nome não pode estar em branco.");
		obj_form.stNome.focus();
		return false;
	}else if(obj_form.stCpf.value==""){
		alert(strMsgErro+"O campo CPF não pode estar em branco.");
		obj_form.stCpf.focus();
		return false;
	}else if(!validaCpf(obj_form.stCpf.value)){
		obj_form.stCpf.focus();
		return false;
	}else if(obj_form.stRg.value==""){
		alert(strMsgErro+"O campo RG não pode estar em branco.");
		obj_form.stRg.focus();
		return false;
	}else if(obj_form.dtDiaNascimento.value==""){
		alert(strMsgErro+"O campo dia de nascimento não pode estar em branco.");
		obj_form.dtDiaNascimento.focus();
		return false;
	}else if(obj_form.dtMesNascimento.value==""){
		alert(strMsgErro+"O campo mês de nascimento não pode estar em branco.");
		obj_form.dtMesNascimento.focus();
		return false;
	}else if(obj_form.dtAnoNascimento.value.length < 4){
		alert(strMsgErro+"Preencha o campo ano de nascimento com 4 algarismos (Ex: 1972).");
		obj_form.dtAnoNascimento.focus();
		return false;
	}else if(obj_form.stEmail.value==""){
		alert(strMsgErro+"O campo e-mail não pode estar em branco.");
		obj_form.stEmail.focus();
		return false;
	}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj_form.stEmail.value)){
		alert(strMsgErro+"O campo E-mail não foi preenchido corretamente.");
		obj_form.stEmail.focus();
		return false;
	}else if(obj_form.stConfirmaEmail.value==""){
		alert(strMsgErro+"O campo confirmação de e-mail não pode estar em branco.");
		obj_form.stConfirmaEmail.focus();
		return false;
	}else if(obj_form.stConfirmaEmail.value != obj_form.stEmail.value){
		alert(strMsgErro+"O campo confirmação de e-mail não é idêntico ao campo e-mail.");
		obj_form.stConfirmaEmail.focus();
		return false;
	}else if(obj_form.nmDdd.value==""){
		alert(strMsgErro+"O campo ddd não pode estar em branco.");
		obj_form.nmDdd.focus();
		return false;
	}else if(obj_form.nmTel.value==""){
		alert(strMsgErro+"O campo Telefone não pode estar em branco.");
		obj_form.nmTel.focus();
		return false;
	}else if(obj_form.stSenha.value==""){
		alert(strMsgErro+"O campo Senha não pode estar em branco.");
		obj_form.stSenha.focus();
		return false;
	}else if(obj_form.stConfirmaSenha.value==""){
		alert(strMsgErro+"O campo Confirmação de Senha não pode estar em branco.");
		obj_form.stConfirmaSenha.focus();
		return false;
	}else if(obj_form.stConfirmaSenha.value != obj_form.stSenha.value){
		alert(strMsgErro+"O campo confirmação de senha não é idêntico ao campo senha.");
		obj_form.stConfirmaSenha.focus();
		return false;
	}else if(obj_form.stCep.value==""){
		alert(strMsgErro+"O campo CEP não pode estar em branco.");
		obj_form.stCep.focus();
		return false;
	}else if(ValidateCep(obj_form.stCep)==false){
		return false;	
	}else if(obj_form.stEndereco.value==""){
		alert(strMsgErro+"O campo Endereço não pode estar em branco.");
		obj_form.stEndereco.focus();
		return false;
	}else if((obj_form.stNumero) && (obj_form.stNumero.value=="") && (obj_form.chkNumero.checked==false)){
		alert(strMsgErro+"O campo Número não pode estar em branco. \nSe não houver número, clique na caixa de seleção Sem Número.");
		obj_form.stNumero.focus();
		return false;		
	}else if(obj_form.stBairro.value==""){
		alert(strMsgErro+"O campo Bairro não pode estar em branco.");
		obj_form.stBairro.focus();
		return false;
	}else if(obj_form.stCidade.value==""){
		alert(strMsgErro+"O campo Cidade não pode estar em branco.");
		obj_form.stCidade.focus();
		return false;
	}else if(obj_form.stEstado.value==""){
		alert(strMsgErro+"O campo Estado não pode estar em branco.");
		obj_form.stEstado.focus();
		return false;
	}else if(fgAjaxAtualiza == 1){
		executeAjax('editF', obj_form, idUsuario);
		return false;
	}else{
		return true;
	}
}

function validateAtEndereco(obj_form){
	if(obj_form.stCepEntrega.value==""){
		alert(strMsgErro+"O campo cep para entrega não pode estar em branco.");
		obj_form.stCepEntrega.focus();
		return false;
	}else if(obj_form.stEnderecoEntrega.value==""){
		alert(strMsgErro+"O campo endereço para cobrança não pode estar em branco.");
		obj_form.stEnderecoEntrega.focus();
		return false;
	}else if(obj_form.stBairroEntrega.value==""){
		alert(strMsgErro+"O campo Bairro para Entrega não pode estar em branco.");
		obj_form.stBairroEntrega.focus();
		return false;
	}else if(obj_form.stCidadeEntrega.value==""){
		alert(strMsgErro+"O campo Cidade para Entrega não pode estar em branco.");
		obj_form.stCidadeEntrega.focus();
		return false;
	}else if(obj_form.stEstadoEntrega.value==""){
		alert(strMsgErro+"O campo Estado para Entrega não pode estar em branco.");
		obj_form.stEstadoEntrega.focus();
		return false;
	}else{
		return true;
	}
}

function validateCadJuridico(obj_form, fgAjaxAtualiza, idUsuario){
	if(obj_form.stRazaoSocialCadastro.value==""){
		alert(strMsgErro+"O campo Razão Social não pode estar em branco !");
		obj_form.stRazaoSocialCadastro.focus();
		return false;
	}else if(obj_form.stCnpjCadastro.value==""){
		alert(strMsgErro+"O campo CNPJ não pode estar em branco !!");
		obj_form.stCnpjCadastro.focus();
		return false;
	}else if(obj_form.stCnpjCadastro.value.length != 14){
		alert(strMsgErro+"O CNPJ deve ter 14 caracteres numéricos !!");		
		obj_form.stCnpjCadastro.focus();
		return false;		
	}else if(!validaCnpj(obj_form.stCnpjCadastro.value)){
		obj_form.stCnpjCadastro.focus();
		return false;		
	}else if(obj_form.stDddCadastro.value==""){
		alert(strMsgErro+"O campo DDD não pode estar em branco.");
		obj_form.stDddCadastro.focus();
		return false;
	}else if(obj_form.stTelCadastro.value==""){
		alert(strMsgErro+"O campo Telefone não pode estar em branco.");
		obj_form.stTelCadastro.focus();
		return false;
	}else if(obj_form.stEmailCadastro.value==""){
		alert(strMsgErro+"O campo E-mail não pode estar em branco.");
		obj_form.stEmailCadastro.focus();
		return false;
	}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj_form.stEmailCadastro.value)){
		alert(strMsgErro+"O campo E-mail não foi preenchido corretamente.");
		obj_form.stEmailCadastro.focus();
		return false;
	}else if(obj_form.stConfirmaEmailCadastro.value==""){
		alert(strMsgErro+"O campo Confirmação de E-mail não pode estar em branco.");
		obj_form.stConfirmaEmailCadastro.focus();
		return false;
	}else if(obj_form.stEmailCadastro.value != obj_form.stConfirmaEmailCadastro.value){
		alert(strMsgErro+"O campo confirmação de E-mail não é idêntico ao campo E-mail.");
		obj_form.stConfirmaEmailCadastro.focus();
		return false;
	}else if(obj_form.stSenhaCadastro.value==""){
		alert(strMsgErro+"O campo Senha não pode estar em branco.");
		obj_form.stSenhaCadastro.focus();
		return false;
	}else if(obj_form.stConfirmaSenha.value==""){
		alert(strMsgErro+"O campo Confirmação da Senha não pode estar em branco.");
		obj_form.stConfirmaSenha.focus();
		return false;
	}else if(obj_form.stConfirmaSenha.value != obj_form.stSenhaCadastro.value){
		alert(strMsgErro+"O campo confirmação de Senha não é idêntico ao campo senha.");
		obj_form.stConfirmaSenha.focus();
		return false;
	}else if(obj_form.stNomeContatoEmpresa.value==""){
		alert(strMsgErro+"O campo nome do contato não pode estar em branco.");
		obj_form.stNomeContatoEmpresa.focus();
		return false;
	}else if(obj_form.stCepFaturaCadastro.value==""){
		alert(strMsgErro+"O campo CEP não pode estar em branco.");
		obj_form.stCepFaturaCadastro.focus();
		return false;
	}else if(ValidateCep(obj_form.stCepFaturaCadastro)==false){
		return false;		
	}else if(obj_form.stEnderecoFaturaCadastro.value==""){
		alert(strMsgErro+"O campo endereço para fatura não pode estar em branco.");
		obj_form.stEnderecoFaturaCadastro.focus();
		return false;
	}else if((obj_form.stNumeroFaturaCadastro) && (obj_form.stNumeroFaturaCadastro.value=="")){
		alert(strMsgErro+"O campo número para fatura não pode estar em branco.");
		obj_form.stNumeroFaturaCadastro.focus();
		return false;		
	}else if(obj_form.stBairroFaturaCadastro.value==""){
		alert(strMsgErro+"O campo bairro para fatura não pode estar em branco.");
		obj_form.stBairroFaturaCadastro.focus();
		return false;
	}else if(obj_form.stCidadeFaturaCadastro.value==""){
		alert(strMsgErro+"O campo cidade para fatura não pode estar em branco.");
		obj_form.stCidadeFaturaCadastro.focus();
		return false;
	}else if(obj_form.stEstadoFaturaCadastro.value==""){
		alert(strMsgErro+"O campo estado para fatura não pode estar em branco.");
		obj_form.stEstadoFaturaCadastro.focus();
		return false;
	}else if(obj_form.stCepCobranca.value==""){
		alert(strMsgErro+"O campo CEP não pode estar em branco.");
		obj_form.stCepCobranca.focus();
		return false;
	}else if(ValidateCep(obj_form.stCepCobranca)==false){
		return false;		
	}else if(obj_form.stEnderecoCobranca.value==""){
		alert(strMsgErro+"O campo endereço para cobrança não pode estar em branco.");
		obj_form.stEnderecoCobranca.focus();
		return false;
	}else if((obj_form.stNumeroCobranca) && (obj_form.stNumeroCobranca.value=="")){
		alert(strMsgErro+"O campo número para cobrança não pode estar em branco.");
		obj_form.stNumeroCobranca.focus();
		return false;		
	}else if(obj_form.stBairroCobranca.value==""){
		alert(strMsgErro+"O campo bairro para cobrança não pode estar em branco.");
		obj_form.stBairroCobranca.focus();
		return false;
	}else if(obj_form.stCidadeCobranca.value==""){
		alert(strMsgErro+"O campo cidade para cobrança não pode estar em branco.");
		obj_form.stCidadeCobranca.focus();
		return false;
	}else if(obj_form.stEstadoCobranca.value==""){
		alert(strMsgErro+"O campo estado para cobrança não pode estar em branco.");
		obj_form.stEstadoCobranca.focus();
		return false;
	}else if(obj_form.stCepEntrega.value==""){
		alert(strMsgErro+"O campo CEP não pode estar em branco.");
		obj_form.stCepEntrega.focus();
		return false;
	}else if(ValidateCep(obj_form.stCepEntrega)==false){
		return false;		
	}else if(obj_form.stEnderecoEntrega.value==""){
		alert(strMsgErro+"O campo endereço para entrega não pode estar em branco.");
		obj_form.stEnderecoEntrega.focus();
		return false;
	}else if((obj_form.stNumeroEntrega) && (obj_form.stNumeroEntrega.value=="")){
		alert(strMsgErro+"O campo número para entrega não pode estar em branco.");
		obj_form.stNumeroEntrega.focus();
		return false;		
	}else if(obj_form.stBairroEntrega.value==""){
		alert(strMsgErro+"O campo bairro para Entrega não pode estar em branco.");
		obj_form.stBairroEntrega.focus();
		return false;
	}else if(obj_form.stCidadeEntrega.value==""){
		alert(strMsgErro+"O campo cidade para Entrega não pode estar em branco.");
		obj_form.stCidadeEntrega.focus();
		return false;
	}else if(obj_form.stEstadoEntrega.value==""){
		alert(strMsgErro+"O campo estado para Entrega não pode estar em branco.");
		obj_form.stEstadoEntrega.focus();
		return false;
	}else if(obj_form.stEstadoFaturaCadastro.value != obj_form.stEstadoEntrega.value){
		alert(strMsgErro+"O campo estado para entrega não pode ser diferenre do estado para fatura.");
		obj_form.stEstadoFaturaCadastro.focus();
		return false;
	}else if(fgAjaxAtualiza == 1){
		executeAjax('editJ', obj_form, idUsuario);
		return false;
	}else{
		return true;
	}
}

function selecionaEntrega(){
	document.frmCarrinho.stActionFrete.value = "1";
	document.frmCarrinho.action="?stActionFrete=1";
	document.frmCarrinho.submit();
}

function selFormaEntrega(){
	document.frmCarrinho.action="?stAction=abreFormaEntrega";
	document.frmCarrinho.submit();
}

function validFormaEntrega(objForm){
	if(objForm.fgFormaEntrega[0].checked == false && objForm.fgFormaEntrega[1].checked == false){
		alert(strMsgErro+"Favor selecionar alguma forma de entrega.");
		objForm.fgFormaEntrega[0].focus();
		return false;	  
	}else if(objForm.fgFormaEntrega[1].checked == true && objForm.stCepEntrega.value == "00000-000"){		
		alert(strMsgErro+"Digite o cep corretamente!");
		objForm.stCepEntrega.focus();
		return false;
	}else if(objForm.fgFormaEntrega[0].checked == true){
		if(objForm.stTransportadora.value == "Próprio"){
			if(objForm.stNomeRetirada.value == ""){
				alert(strMsgErro+"O campo Nome não pode estar em branco!");
				objForm.stNomeRetirada.focus();
				return false;
			}else if(objForm.stTelRetirada.value == ""){
				alert(strMsgErro+"O campo Telefone não pode estar em branco.");
				objForm.stTelRetirada.focus();
				return false;
			}
		}else{
			if(objForm.stTelRetirada.value == ""){
				alert(strMsgErro+"O campo Telefone não pode estar em branco.");
				objForm.stTelRetirada.focus();
				return false;
			}
		}
	}
}	


function validEndEnt(obj_form){
	if(obj_form.stNumero.value==""){
		alert(strMsgErro+"O campo Numero não pode estar em branco !");
		obj_form.stNumero.focus();
		return false;
	}else if(stEndEntrega == ""){
		alert(strMsgErro+"O campo Endereço não pode estar em branco !");
		obj_form.stEndEntrega.focus();
		return false;
	}else{
		return true;
	}
}

          
	  
function validFormaEntrega1(objForm){
	if(objForm.fgFormaEntrega[0].checked == false && objForm.fgFormaEntrega[1].checked == false){
		alert(strMsgErro+"Favor selecionar alguma forma de entrega.");
		objForm.fgFormaEntrega[0].focus();
		return false;	  
	}else if(objForm.fgFormaEntrega[1].checked == true && objForm.stCepEntrega.value == "00000-000" ){		
		alert(strMsgErro+"Digite o cep corretamente!");
		objForm.stCepEntrega.focus();
		return false;								  
    }else if(objForm.fgFormaEntrega[1].checked == true && objForm.stCepEntrega.value.length < 9 ) {
		alert(strMsgErro+"O Tamanho do CEP inválido "  );
		objForm.stCepEntrega.focus();
		return false;								  
			
	}else if(objForm.fgFormaEntrega[0].checked == true){
		if(objForm.stTransportadora.value == "Próprio"){
			if(objForm.stNomeRetirada.value == ""){
				alert(strMsgErro+"O campo Nome não pode estar em branco!");
				objForm.stNomeRetirada.focus();
				return false;
			}else if(objForm.stTelRetirada.value == ""){
				alert(strMsgErro+"O campo Telefone não pode estar em branco.");
				objForm.stTelRetirada.focus();
				return false;
			}
		}else{
			if(objForm.stTelRetirada.value == ""){
				alert(strMsgErro+"O campo Telefone não pode estar em branco.");
				objForm.stTelRetirada.focus();
				return false;
			}
		}
	}
}


function MascaraMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e){
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 13) return true;
	key = String.fromCharCode(whichCode);
	if(strCheck.indexOf(key) == -1) return false;
	len = objTextBox.value.length;
	for(i = 0; i < len; i++)
		if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) break;
	aux = '';
	for(; i < len; i++)
		if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1) aux += objTextBox.value.charAt(i);
	aux += key;
	len = aux.length;
	if (len == 0) objTextBox.value = '';
	if (len == 1) objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;
	if (len == 2) objTextBox.value = '0'+ SeparadorDecimal + aux;
	if (len > 2){
		aux2 = '';
		for (j = 0, i = len - 3; i >= 0; i--){
			if (j == 3){
				aux2 += SeparadorMilesimo;
				j = 0;
			}
		aux2 += aux.charAt(i);
		j++;
	}
	objTextBox.value='';
	len2 = aux2.length;
	for (i = len2 - 1; i >= 0; i--)
		objTextBox.value += aux2.charAt(i);
		objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
	}
	return false;
}

function dataExtenso(hoje){
	var dia 			= nome_dia[hoje.getDay()];
	var dia_do_mes	= hoje.getDate();
	var mes 			= nome_mes[hoje.getMonth()];
	var ano 			= hoje.getYear();
	var minuto 		= hoje.getMinutes();
	var hora 		= hoje.getHours();

	if (minuto=="0") minuto = "01";
	if (minuto=="1") minuto = "02";
	if (minuto=="2") minuto = "03";
	if (minuto=="3") minuto = "04";
	if (minuto=="4") minuto = "05";
	if (minuto=="5") minuto = "06";
	if (minuto=="6") minuto = "07";
	if (minuto=="7") minuto = "08";
	if (minuto=="8") minuto = "09";
	if (minuto=="9") minuto = "10";

	if (ano < 100){
		var ano = '19' + ano
	}

	var xyz = dia + ', ' + dia_do_mes + ' de ' + mes + ' de ' + ano + ' .:. ' + hora + ':' + minuto; 
	return xyz;
}

function reloadPage(init){
	if (init==true) with (navigator){
		if((appName=="Netscape")&&(parseInt(appVersion)==4)){
			document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage;
		}
	}else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload()
}

var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e){
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	try {
		if(input.value.length >= len && !containsElement(filter,keyCode)){
			input.value = input.value.slice(0, len);
			input.form[(getIndex(input)+1) % input.form.length].focus();
		}
	} 
	catch (exc) {
	// Nothing	
	}


function containsElement(arr, ele){
	var found = false, index = 0;
	while(!found && index < arr.length)
		if(arr[index] == ele)
			found = true;
		else
			index++;
	return found;
}

function getIndex(input) {
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
		if (input.form[i] == input)index = i;
		else i++;
		return index;
	}
	return true;
}

function openPopup(vURL, vNomeJanela, vParametros){
	v_pop = window.open(vURL, vNomeJanela, vParametros)
}

function validaBusca(objForm){
	if(objForm.stBusca.value.length < 3){
		alert(strMsgErro + "Favor preencher o campo busca com mais de 3 caracteres.");
		objForm.stBusca.focus();
		return false;
	}else{
		objForm.submit();
	}
}

function validaCupom(objForm){
	if(objForm.ccupom.value.length = 0){
		alert(strMsgErro + "Favor preencher o numero do cupom recebido");
		objForm.ccupom.focus();
		return false;
	
	}else{
		objForm.submit();
	}
}

function geraTransacaoBoleto(form, features, windowName){
	if(!windowName)windowName = 'formTarget' + (new Date().getTime());
	form.target = windowName;
	open('', windowName, features);
	
	document.location.href = "../finalizacao/finalizacao.asp";
}

function geraSegViaBoleto(form, features, windowName){
	if(!windowName)windowName = 'formTarget' + (new Date().getTime());
	form.target = windowName;
	open('', windowName, features);
}

function VerificaFaturamento(){
	if(document.frmPagamento.stParcelasPagamento[4].value == ""){
		alert("Favor selecionar o tipo de parcelamento.");
		document.frmPagamento.stParcelasPagamento[4].focus();
		return false;
	}
	return true;
}

function geraTransacaoCartao(form, features, windowName){
	if(!windowName)windowName = 'vpos';
	form.target = windowName;

	vpos = window.open('', windowName, features);
	
	tmt_Move_WindowX = (screen.width - 780) / 2; 
	tmt_Move_WindowY = (screen.height - 460) / 2; 

	vpos.moveTo(tmt_Move_WindowX,tmt_Move_WindowY); 
}

function geraTransacaoCartaoAmex(form, features, windowName){
	form.target = windowName;
	popupTransacaoCartao = window.open('', windowName, features);
}

function geraTransacaoVisa(){

	if(document.frmpagamento.stNumeroCartao.value.length < 6){
		alert(strMsgErro + "Por favor, informe os 6 primeiros dígitos do seu cartão de crédito.");
		document.frmpagamento.stNumeroCartao.focus();
		return false;
	}else{
		var retorno;
		var mpg_popup;
		window.name="loja";
		
		if(navigator.appName.indexOf("Netscape") != -1){
		   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=440");
		}else{
		   mpg_popup = window.open("", "mpg_popup","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,screenX=0,screenY=0,left=0,top=0,width=765,height=440");
		}

		window.location.href="../visa/redirecionaCBP.asp";
		return true;

		tmt_Move_WindowX = (screen.width - 765) / 2; 
		tmt_Move_WindowY = (screen.height - 440) / 2; 

		mpg_popup.moveTo(tmt_Move_WindowX,tmt_Move_WindowY); 
	}
}

function geraTransacaoVisaElectron(){
	window.name="loja";
	var retorno;
	var mpg_popup;
	window.name="loja";
	
	if(navigator.appName.indexOf("Netscape") != -1){
	   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=440");
	}else{
	   mpg_popup = window.open("", "mpg_popup","toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,screenX=0,screenY=0,left=0,top=0,width=765,height=440");

		tmt_Move_WindowX = (screen.width - 765) / 2; 
		tmt_Move_WindowY = (screen.height - 440) / 2; 

		mpg_popup.moveTo(tmt_Move_WindowX,tmt_Move_WindowY); 
	}
}

function geraTransacaoRedecard(features, windowName){
	if(!windowName)windowName = 'vpos';

	vpos = window.open('', windowName, features);
	
	tmt_Move_WindowX = (screen.width - 780) / 2; 
	tmt_Move_WindowY = (screen.height - 500) / 2; 

	vpos.moveTo(tmt_Move_WindowX,tmt_Move_WindowY); 
}

function fechaTransacao(){
	popupTransacaoCartao = window.open('', 'popCartao', 'width=0,height=0');
	popupTransacaoCartao.close();	
}

function geraComprovanteVenda(form, features, windowName){
	if(!windowName)windowName = 'popCartao';
	form.target = windowName;

	popupTransacaoCartao = window.open('', windowName, features);
	
	nmMoveX = (screen.width - 295) / 2; 
	nmMoveY = (screen.height - 460) / 2; 

	popupTransacaoCartao.moveTo(nmMoveX, nmMoveY); 
}

function redirectAndClose(stRedirecionamento){
	this.window.close();
	window.opener.location = stRedirecionamento;
}

function verificaTransportadora(stTransportadora, fgFocus){
	if(stTransportadora == "Próprio"){
		document.getElementById("spNome").style.display 			= "";
		document.getElementById("spTelefone").style.display 		= "";

		if(fgFocus == 1){
			document.getElementById("idStNomeRetirada").focus();
		}
	}else{
		document.getElementById("spNome").style.display 			= "none";
		document.getElementById("spTelefone").style.display 		= "";

		if(fgFocus == 1){
			document.getElementById("idStTelRetirada").focus();
		}
	}
}

function executeAjax(stAction, objForm, idUsuario){
	stParameters = "../ajax/actions_ajax.asp?stAction="+stAction+"&idUsuario="+idUsuario;
	stParameters += "&stEmailAntigo="+objForm.stEmailAntigo.value;
	
	if(stAction == "editF"){
		stParameters += "&stNome="+escape(objForm.stNome.value);
		stParameters += "&stCpf="+objForm.stCpf.value;
		stParameters += "&stRg="+objForm.stRg.value;
		stParameters += "&dtDiaNascimento="+objForm.dtDiaNascimento.value;
		stParameters += "&dtMesNascimento="+objForm.dtMesNascimento.value;
		stParameters += "&dtAnoNascimento="+objForm.dtAnoNascimento.value;
	
		if(objForm.fSexo[0].checked == true){
			stParameters += "&fSexo="+objForm.fSexo[0].value;
		}else if(objForm.fSexo[1].checked == true){
			stParameters += "&fSexo="+objForm.fSexo[1].value;
		}	
		stParameters += "&stEmail="+objForm.stEmail.value;
		stParameters += "&nmDdd="+objForm.nmDdd.value;
		stParameters += "&nmTel="+objForm.nmTel.value;
		stParameters += "&nmDddFax="+objForm.nmDddFax.value;
		stParameters += "&nmTelFax="+objForm.nmTelFax.value;
		stParameters += "&stSenha="+objForm.stSenha.value;
		stParameters += "&stEndereco="+escape(objForm.stEndereco.value);
		stParameters += "&stBairro="+escape(objForm.stBairro.value);
		stParameters += "&stCep="+objForm.stCep.value.replace(/-/,'');
		stParameters += "&stCidade="+escape(objForm.stCidade.value);
		stParameters += "&stEstado="+escape(objForm.stEstado.value);
		stParameters += "&stReferencia="+escape(objForm.stReferencia.value);
	
		if(objForm.fNewsletter.checked == true){
			stParameters += "&fNewsletter="+objForm.fNewsletter.value;
		}else{
			stParameters += "&fNewsletter=0";
		}
	}else{	
		stParameters += "&stRazaoSocialCadastro="+escape(objForm.stRazaoSocialCadastro.value);
		stParameters += "&stCnpjCadastro="+objForm.stCnpjCadastro.value;
		stParameters += "&stInscricaoEstadualCadastro="+objForm.stInscricaoEstadualCadastro.value;
		stParameters += "&stDddCadastro="+objForm.stDddCadastro.value;
		stParameters += "&stTelCadastro="+objForm.stTelCadastro.value;
		stParameters += "&stDddFaxCadastro="+objForm.stDddFaxCadastro.value;
		stParameters += "&stTelFaxCadastro="+objForm.stTelFaxCadastro.value;
		stParameters += "&stEmailCadastro="+objForm.stEmailCadastro.value;
		stParameters += "&stSenhaCadastro="+objForm.stSenhaCadastro.value;
		stParameters += "&stNomeContatoEmpresa="+escape(objForm.stNomeContatoEmpresa.value);
		stParameters += "&stNomeVendedorEmpresa="+escape(objForm.stNomeVendedorEmpresa.value);

		if(objForm.fgNewsletterCadastro.checked == true){
			stParameters += "&fgNewsletterCadastro="+objForm.fgNewsletterCadastro.value;
		}else{
			stParameters += "&fgNewsletterCadastro=0";
		}		
		stParameters += "&stCepFaturaCadastro="+objForm.stCepFaturaCadastro.value.replace(/-/,'');
		stParameters += "&stEnderecoFaturaCadastro="+escape(objForm.stEnderecoFaturaCadastro.value);
		stParameters += "&stBairroFaturaCadastro="+escape(objForm.stBairroFaturaCadastro.value);
		stParameters += "&stCidadeFaturaCadastro="+escape(objForm.stCidadeFaturaCadastro.value);
		stParameters += "&stEstadoFaturaCadastro="+escape(objForm.stEstadoFaturaCadastro.value);
		stParameters += "&stCepCobranca="+objForm.stCepCobranca.value.replace(/-/,'');		
		stParameters += "&stEnderecoCobranca="+escape(objForm.stEnderecoCobranca.value);
		stParameters += "&stBairroCobranca="+escape(objForm.stBairroCobranca.value);
		stParameters += "&stCidadeCobranca="+escape(objForm.stCidadeCobranca.value);
		stParameters += "&stEstadoCobranca="+escape(objForm.stEstadoCobranca.value);
		stParameters += "&stCepEntrega="+objForm.stCepEntrega.value.replace(/-/,'');		
		stParameters += "&stEnderecoEntrega="+escape(objForm.stEnderecoEntrega.value);
		stParameters += "&stBairroEntrega="+escape(objForm.stBairroEntrega.value);
		stParameters += "&stCidadeEntrega="+escape(objForm.stCidadeEntrega.value);
		stParameters += "&stEstadoEntrega="+escape(objForm.stEstadoEntrega.value);
		stParameters += "&stReferencia="+escape(objForm.stReferencia.value);
		if(objForm.tipoemp[0].checked == true){
			stParameters += "&tipoemp="+objForm.tipoemp[0].value;
			stParameters += "&stobsempresa="+("");			
		}else if(objForm.tipoemp[1].checked == true){
			stParameters += "&tipoemp="+objForm.tipoemp[1].value;
			stParameters += "&stobsempresa="+escape(objForm.stobsempresa2.value);			
		}else if(objForm.tipoemp[2].checked == true){
			stParameters += "&tipoemp="+objForm.tipoemp[2].value;
			stParameters += "&stobsempresa="+("");			
		}else if(objForm.tipoemp[3].checked == true){
			stParameters += "&tipoemp="+objForm.tipoemp[3].value;
			stParameters += "&stobsempresa="+escape(objForm.stobsempresa4.value);			
		}				
	}

	// Microsoft.
	try{
		objAjax = new ActiveXObject("Microsoft.XMLHTTP");
	} 

	catch(e){
		// Mozilla.
		try{
			objAjax = new ActiveXObject("Msxml2.XMLHTTP");
		}

		catch(ex){
			try{
				objAjax = new XMLHttpRequest();
			}

			catch(exc){
				objAjax = null;
			}
		}
	}

	if(objAjax){
		objAjax.onreadystatechange = function(){
			if(objAjax.readyState == 1){
				var objDivLoaderStyle = document.getElementById("divLoader").style;
				if (objDivLoaderStyle.filter != null) {
					objDivLoaderStyle.filter = 'Alpha(opacity=50)';	 /* Internet Explorer */
				}
				else if (objDivLoaderStyle.opacity != null) {
					objDivLoaderStyle.opacity = 0.5;                 /* Firefox */
				}
				document.getElementById("divLoader").style.top = mouseY - 100;
				document.getElementById("divLoader").style.left = mouseX - 75;				
				document.getElementById("divMsgLoader").style.top = mouseY - 92;
				document.getElementById("divMsgLoader").style.left = mouseX - 75;				
				document.getElementById("divLoader").style.display = "";
				document.getElementById("divMsgLoader").style.display = "";	
				
				window.onClose = function(){
					alert('Aguarde enquanto o seu cadastro é atualizado.');
				}
			}
			
			if(objAjax.readyState == 4 ){				
				window.setTimeout("document.getElementById('divLoader').style.display = 'none';", 2000);
				window.setTimeout("document.getElementById('divMsgLoader').style.display = 'none';", 2000);
				if(objAjax.responseText == "cadastro_erro"){
					window.setTimeout("alert('Atenção. O E-mail informado já existe na base de dados. As informações não foram atualizadas.');", 2000);
				}else if(objAjax.responseText == "cadastro_ok"){
					window.setTimeout("alert('Informações atualizadas com sucesso.');", 2000);
				}
			}
		}
		objAjax.open("POST", stParameters, true);
		objAjax.setRequestHeader("Content-Type", "text/html;charset=iso-8859-1");		
		objAjax.send(stParameters);
	}
}

function abreItemPedido(idPedido){
	var fgCondicao 		= document.getElementById("fgCondicao_"+idPedido).value;
	var nmQtdItemPedido	= document.getElementById("nmQtdItemPedido_"+idPedido).value;
	nmQtdItemPedido ++
	
	if(fgCondicao == 0){
		document.getElementById("fgCondicao_"+idPedido).value = 1;

		for(i=1; i < nmQtdItemPedido; i++){
			document.getElementById("tr_det_pedido_"+idPedido+"_"+i).style.display = "";
					
			document.getElementById("img_0_"+idPedido).style.display = "none";			
			document.getElementById("img_1_"+idPedido).style.display = "";
		}
		
	}else{
		document.getElementById("fgCondicao_"+idPedido).value = 0;

		for(i=1; i < nmQtdItemPedido; i++){
			document.getElementById("tr_det_pedido_"+idPedido+"_"+i).style.display = "none";
			
			document.getElementById("img_0_"+idPedido).style.display = "";			
			document.getElementById("img_1_"+idPedido).style.display = "none";
			

		}
	}
}

function abreTopico(stNomeTr, idTr){
	var nmResults;
	nmResults = document.getElementById("nmTotalItens").value;

	if(document.getElementById(stNomeTr+idTr).style.display == ""){
		document.getElementById(stNomeTr+idTr).style.display = "none"
	}else{
		for(i = 0; i < nmResults; i++){
			if(idTr != i){
				document.getElementById(stNomeTr+i).style.display = "none";
			}else{
				document.getElementById(stNomeTr+i).style.display = "";
			}
		}
	}
	i 			= 0
	nmResults	= 0
}

function FormatCep(e,src,mask) {
	if (!e) var e = window.event;
	if (e){
	   if(e.keyCode) 
		{ _TXT = e.keyCode; } 
	   else if(e.which) 
		{ _TXT = e.which; }
	   if(_TXT > 47 && _TXT < 58) { 
		var i = src.value.length; 
		var saida = mask.substring(0,1); 
		var texto = mask.substring(i)
		if (texto.substring(0,1) != saida) 
			{ src.value += texto.substring(0,1); } 
			return true; 
		} 
		else {
			if ((_TXT == 13) && (src.value.length == 9))
				{ return true; }
			else if (_TXT == 9)
			    { return true; }
			else if (_TXT == 37)
			    { return true; }
			else if (_TXT == 39)
			    { return true; }			
			else if (_TXT != 8) 
				{ return false; } 
			else 
				{ return true; }
		}
	}
}

function ShowHideCEP(action,lblCEP,imgCep){
	var ctrlCEP = document.getElementById(lblCEP);
	var logoCEP = document.getElementById(imgCep);	
	if (action == 'hide'){
		ctrlCEP.style.display = 'none';	
		logoCEP.style.display = 'none';			
	}
	else
	{
		ctrlCEP.style.display = '';	
		logoCEP.style.display = '';			
	}												
}

function VerificaCep(txt,radioCEP){ 
	if (radioCEP.checked == false){
		return true;
	}
	else
	{
		return ValidateCep(txt)
	}
}

function ValidateCep(txt){ 
	if (txt.value.length < 9){
		alert('Preencha o campo "CEP de Entrega" com 8 algarismos.');
		txt.focus();
		return false;
	}
	else if (txt.value.indexOf('-') != 5){
		alert('Erro no preenchimento do campo "CEP de Entrega".');
		txt.focus();											
		return false;
	}
	else
	{
		return true;
	}
}

function repetirEnderecoFatura(obj) {
	if (obj.checked) {
		if (obj.name == 'stRepetirFaturaCobranca'){
			obj.form.stCepCobranca.value = obj.form.stCepFaturaCadastro.value;
			obj.form.stEnderecoCobranca.value = obj.form.stEnderecoFaturaCadastro.value;
			if (obj.form.stNumeroCobranca){
				obj.form.stNumeroCobranca.value = obj.form.stNumeroFaturaCadastro.value;
			}
			if (obj.form.stComplementoCobranca){
				obj.form.stComplementoCobranca.value = obj.form.stComplementoFaturaCadastro.value;
			}
			obj.form.stBairroCobranca.value = obj.form.stBairroFaturaCadastro.value;			
			obj.form.stCidadeCobranca.value = obj.form.stCidadeFaturaCadastro.value;			
			obj.form.stEstadoCobranca.value = obj.form.stEstadoFaturaCadastro.value;
		}else if (obj.name =='stRepetirFaturaEntrega') {
			obj.form.stCepEntrega.value = obj.form.stCepFaturaCadastro.value;
			obj.form.stEnderecoEntrega.value = obj.form.stEnderecoFaturaCadastro.value;
			if (obj.form.stNumeroEntrega){
				obj.form.stNumeroEntrega.value = obj.form.stNumeroFaturaCadastro.value;
			}
			if (obj.form.stComplementoEntrega){
				obj.form.stComplementoEntrega.value = obj.form.stComplementoFaturaCadastro.value;
			}
			obj.form.stBairroEntrega.value = obj.form.stBairroFaturaCadastro.value;			
			obj.form.stCidadeEntrega.value = obj.form.stCidadeFaturaCadastro.value;
			obj.form.stEstadoEntrega.value = obj.form.stEstadoFaturaCadastro.value;			
		}
	}
}

function formatCurrency(num) {
	num = num.toString().replace(',','.');
	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;
	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));
	return (((sign)?'':'-') + 'R$ ' + num + ',' + cents);
}

function confirmarCopiaPedido(nmTotalProdutos){
	if (parseInt(nmTotalProdutos) == 0)
		if (confirm("Deseja adicionar os itens deste pedido ao seu carrinho de compras?"))
			{ return true }
		else
			{ return false }
	else {
		if (confirm("Você possui itens no seu carrinho de compras.\nDeseja adicionar os itens deste pedido aos já existentes?"))
			{ return true }
		else
			{ return false }
	}
}

function ShowHidePanelCredito(objForm,hideFormaPagamento,corp){
	if (objForm.chkCredito.checked == true) {
		if (corp == "true" && (document.frmPagamento.stBandeiraPagamento.value=="BOLETO" || document.frmPagamento.stBandeiraPagamento.value=="DEPOSITO_BANCARIO" || document.frmPagamento.stBandeiraPagamento.value=="VISA_ELECTRON" || document.frmPagamento.stBandeiraPagamento.value=="TEF_ITAU")){
			hideLayer('panel_credito');
			hideLayer('panel_total_com_credito');			
			displayLayer("panel_credito_desconto");
			displayLayer("panel_total_com_desconto_com_credito");
		} else {
			hideLayer("panel_credito_desconto");
			hideLayer("panel_total_com_desconto_com_credito");
			displayLayer('panel_credito');
			displayLayer('panel_total_com_credito');
		}		

		if (hideFormaPagamento == true){
			document.getElementById("table_forma_pagamento").style.display = "none";
			document.getElementById("table_pagar_com_credito").style.display = "";
			document.frmPagamento.stBandeiraPagamento.value = "CREDITO";
		}
	}else{
		document.getElementById("panel_credito").style.display = "none";
		document.getElementById("panel_total_com_credito").style.display = "none";
		document.getElementById("panel_credito_desconto").style.display = "none";
		document.getElementById("panel_total_com_desconto_com_credito").style.display = "none";		
		document.getElementById("table_forma_pagamento").style.display = "";
		document.getElementById("table_pagar_com_credito").style.display = "none";		
	}
}

// Indicação a um amigo - Newsletter

function AbrirJanelaVisualizarIndicacaoNewsletter(news){
	openPopup('visualiza_amigo_indica_newsletter.asp?News=' + news + '&visualizar=s&Cliente=' + escape(document.getElementById('stNomeCliente').value) + '&Amigo=' + escape(document.getElementById('stNomeAmigo').value) + '&Mensagem=' + escape(document.getElementById('stMensagem').value), 'VisualizaIndicacaoAmigo','width=760,height=540,scrollbars=yes,status=yes,location=yes,menubar=yes,toolbar=yes,resizable=1,top=200,left=220');	
}

// Indicação a um amigo - Produto

function AbrirJanelaIndicacao(idProduto){
	openPopup('indique_a_um_amigo.asp?idProduto=' + idProduto, 'IndicacaoAmigo','width=500,height=334,scrollbars=no,status=yes,location=no,menubar=no,toolbar=no,top=200,left=220');	
}

function AbrirJanelaVisualizarIndicacao(idProduto){
	openPopup('visualiza_amigo_indica.asp?visualizar=s&Produto=' + idProduto + '&Cliente=' + escape(document.getElementById('stNomeCliente').value) + '&Amigo=' + escape(document.getElementById('stNomeAmigo').value) + '&Mensagem=' + escape(document.getElementById('stMensagem').value), 'VisualizaIndicacaoAmigo','width=760,height=540,scrollbars=yes,status=yes,location=yes,menubar=yes,toolbar=yes,resizable=1,top=200,left=220');	
}

function verificaFormIndicacao(obj_form){
	if(obj_form.stNomeCliente.value==""){
		alert("Favor preencher o campo com o seu nome.");
		obj_form.stNomeCliente.focus();
		return false;
	}else if(obj_form.stEmailCliente.value==""){
		alert("Favor preencher o campo com o seu e-mail.");
		obj_form.stEmailCliente.focus();
		return false;
	}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj_form.stEmailCliente.value)){
		alert("O campo com o seu e-mail não foi preenchido corretamente.");
		obj_form.stEmailCliente.focus();
		return false;
	}else if(obj_form.stNomeAmigo.value==""){
		alert("Favor preencher o campo com o nome do seu amigo.");
		obj_form.stNomeAmigo.focus();
		return false;
	}else if(obj_form.stEmailAmigo.value==""){
		alert("Favor preencher o campo com o e-mail do seu amigo.");
		obj_form.stEmailAmigo.focus();
		return false;
	}else if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj_form.stEmailAmigo.value)){
		alert("O campo com o e-mail do seu amigo não foi preenchido corretamente.");
		obj_form.stEmailAmigo.focus();
		return false;
	}
	
	if(obj_form.stNomeAmigo1!=null) {
		if(obj_form.stNomeAmigo1.value=="" && obj_form.stEmailAmigo1.value!=""){
			alert("Favor preencher o campo com o nome do seu amigo.");
			obj_form.stNomeAmigo1.focus();
			return false;	
		}
		if(obj_form.stEmailAmigo1.value!=""){
			if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj_form.stEmailAmigo1.value)){
				alert("O campo com o e-mail do seu amigo não foi preenchido corretamente.");
				obj_form.stEmailAmigo1.focus();
				return false;
			}
		}
	}
	
	if(obj_form.stNomeAmigo2!=null) {
		if(obj_form.stNomeAmigo2.value=="" && obj_form.stEmailAmigo2.value!=""){
			alert("Favor preencher o campo com o nome do seu amigo.");
			obj_form.stNomeAmigo2.focus();
			return false;	
		}
		if(obj_form.stEmailAmigo2.value!=""){
			if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj_form.stEmailAmigo2.value)){
				alert("O campo com o e-mail do seu amigo não foi preenchido corretamente.");
				obj_form.stEmailAmigo2.focus();
				return false;
			}
		}
	}	

	return true;
}


// Correios - Início

    function CriticaCampos()
    {
    if (document.Geral.Localidade.value == "")
    {
    alert("Informe o nome completo da Cidade/Município/Distrito/Povoado. Para o DF poderá ser informado o nome da Região Administrativa (Lago Sul, Lago Norte, Cruzeiro, Taguatinga, etc) !!");
    document.Geral.Localidade.focus();
    return (false);
    } 
    else
    { 
    var Branco = " ";
    var Posic, Carac;
    var Temp = document.Geral.Localidade.value.length;    
    var Cont = 0;
    for (var i=0; i < Temp; i++)   
    {  
    Carac =  document.Geral.Localidade.value.charAt (i);
    Posic  = Branco.indexOf (Carac);   
    if (Posic == -1)   
    Cont++;      
    }   
    if (Cont <= 0)
    {
    alert("Informe o nome completo da Cidade/Município/Distrito/Povoado. Para o DF poderá ser informado o nome da Região Administrativa (Lago Sul, Lago Norte, Cruzeiro, Taguatinga, etc) !!");
    document.Geral.Localidade.focus();
    return (false);
    }   
    }
    if (document.Geral.Logradouro.value == "")
    {
    alert("Informe o nome do logradouro");
    document.Geral.Logradouro.focus();
    return (false);
    }  
    else
    { 
    var Branco = " ";
    var Posic, Carac;
    var Temp = document.Geral.Logradouro.value.length;    
    var Cont = 0;
    for (var i=0; i < Temp; i++)   
    {  
    Carac =  document.Geral.Logradouro.value.charAt (i);
    Posic  = Branco.indexOf (Carac);   
    if (Posic == -1)   
    Cont++;      
    }   
    if (Cont <= 0)
    {
    alert("Informe o nome do logradouro");
    document.Geral.Logradouro.focus();
    return (false);
    }
    }
    } 
    function AjudaLogradouro()
    {   
       DocRemote = window.open ('http://www.correios.com.br/servicos/cep/ajuda/ajuda_cep_loc_log.htm','Logradouro','scrollbars,resizable,width=300,height=400');
    }  
	
function logradouroCorreios(e){
	if (!e) var e = window.event;
	if (e){
	   if(e.keyCode) 
		{ _TXT = e.keyCode; } 
	   else if(e.which) 
		{ _TXT = e.which; }
	if ((_TXT > 32 && _TXT < 40) || (_TXT > 41 && _TXT < 48) || (_TXT > 57 && _TXT < 65) || (_TXT > 90 && _TXT < 97)) 
		{ 
			return false; 
		}
	}
}
	
// Correios - Fim

// Efeito Blink

function doBlink(){
		obj = document.getElementsByTagName('blink');
		for(i=0;i<obj.length;i++){
			tag=obj[i];
			tag.style.visibility=(tag.style.visibility=='hidden')?'visible':'hidden';
		}
}

function doBlinkColor(firstColor,secondColor){
	obj = document.getElementById('blink_text');
	if(obj){
		if(obj.style.color.replace(/ /g,'')==firstColor.replace(/ /g,'')){
			obj.style.color=secondColor;
		}else{
			obj.style.color=firstColor;			
		}
	}
}

// Obter Contagem de Usuários Ativos

function getUsersOnline() {

	if (document.getElementById("users_online")){

		// Microsoft.
		try{
			objAjax = new ActiveXObject("Microsoft.XMLHTTP");
		} 
	
		catch(e){
			// Mozilla.
			try{
				objAjax = new ActiveXObject("Msxml2.XMLHTTP");
			}
	
			catch(ex){
				try{
					objAjax = new XMLHttpRequest();
				}
	
				catch(exc){
					objAjax = null;
				}
			}
		}
	
		if(objAjax){		
			objAjax.onreadystatechange = function(){
				if(objAjax.readyState == 1){		
					// document.getElementById("users_online").innerHTML = "";
				}
				
				if(objAjax.readyState == 4 ){
					if (objAjax.status == 200) { 
						document.getElementById("users_online").innerHTML = objAjax.responseText;
					} else {
						// document.getElementById("users_online").innerHTML = "";
					}				
				}
			}
			
			var url = "../../inc/UsersOnline.asp";
			
			objAjax.open("GET", url, true);
			objAjax.setRequestHeader("Content-Type", "text/html;charset=iso-8859-1");
			objAjax.send(url);
		}
	}
}

// Renovar Sessão
function refreshSession() {

	var objAjax;
	if (window.XMLHttpRequest) {
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  objAjax = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
	  // code for IE6, IE5
	  objAjax = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {
	  // browser does not support XMLHTTP
	  // document.getElementById("id_browser").innerHTML = "SESSION_RENEW_OBJECT_AJAX_ERROR#";
	}
	
	if(objAjax) {
		var urlSessionRenew = "../ajax/session_renew.asp";
		objAjax.onreadystatechange = function() {
			if(objAjax.readyState == 1){
				 // document.getElementById("id_browser").innerHTML = " ";
			}
	
			if(objAjax.readyState == 4 ) {
				if (objAjax.status == 200) { 
					 // document.getElementById("id_browser").innerHTML = objAjax.responseText;
				} else {
					 // document.getElementById("id_browser").innerHTML = "SESSION_RENEW_AJAX_ERROR#";
				}
			}
		}
		objAjax.open("POST", urlSessionRenew, true);
		objAjax.setRequestHeader("Content-Type", "text/html;charset=iso-8859-1");
		objAjax.send(urlSessionRenew);
	}

}


// GoogleMaps
function googleMaps(idEndereco) {
	
	var elementMaps = document.getElementById("div_map_" + idEndereco);
	var btnComoChegar = document.getElementById("btn_Como_Chegar_" + idEndereco);
	
	if (elementMaps.style.display == "block") {
		btnComoChegar.src = "../../imagens/btn_como_chegar_mais.gif";
		elementMaps.style.display = "none";
		return true;
	}
	else {
		btnComoChegar.src = "../../imagens/btn_como_chegar_menos.gif";
	}

	var objAjax;
	if (window.XMLHttpRequest) {
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  objAjax = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
	  // code for IE6, IE5
	  objAjax = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {
	  // browser does not support XMLHTTP
	  // document.getElementById("id_browser").innerHTML = "GOOGLE_MAPS_AJAX_ERROR#";
	}
	
	if(objAjax) {
		var urlGoogleMaps = "../ajax/google_maps.asp?idEndereco=" + idEndereco;
		objAjax.onreadystatechange = function() {
			if(objAjax.readyState == 1){
				elementMaps.innerHTML = "<div style='position:absolute;top:50%;margin-top:-25px;left:50%;margin-left:-45px;'><img src='../../imagens/aero_light.gif' border='0' width='32' height='32'><br />&nbsp;Carregando ...</div>";
				elementMaps.style.height = "80px";
				elementMaps.style.display = "block";
			}
	
			if(objAjax.readyState == 4 ) {
				if (objAjax.status == 200) {
					if (objAjax.responseText == "GOOGLE_MAPS_ERROR#") {
						btnComoChegar.src = "../../imagens/btn_como_chegar_mais.gif";
						elementMaps.style.display = "none";						
					}
					else {
						elementMaps.style.height = "570px";
						elementMaps.innerHTML = objAjax.responseText;
					}
				} else {
					btnComoChegar.src = "../../imagens/btn_como_chegar_mais.gif";
					elementMaps.style.display = "none";
				}
			}
		}
		objAjax.open("POST", urlGoogleMaps, true);
		objAjax.setRequestHeader("Content-Type", "text/html;charset=iso-8859-1");
		objAjax.send(urlGoogleMaps);
	}

}

function formatCnpj(element, e){
  if (e.keyCode != 8){
    length = element.value.length;
    if (length == 2)
      element.value += ".";
    if (length == 6)
      element.value += ".";
    if (length == 10)
      element.value += "/";
    if (length == 15)
      element.value += "-";
  }
}


function validateEntregaJuridica(obj_form, fgAjaxAtualiza, idUsuario){
	if(obj_form.cNome.value==""){
		alert(strMsgErro+"O campo Nome não pode estar em branco.");
		obj_form.cNome.focus();
		return false;
	}else if(obj_form.cEndereco.value==""){
		alert(strMsgErro+"O campo Endereco não pode estar em branco.");
		obj_form.cEndereco.focus();
		return false;
	}else if(obj_form.cNumero.value==""){
		alert(strMsgErro+"O campo Numero não pode estar em branco.");
		obj_form.cNumero.focus();
		return false;
	}else if(obj_form.cBairro.value==""){
		alert(strMsgErro+"O campo Bairro não pode estar em branco.");
		obj_form.cBairro.focus();
		return false;
	}else if(obj_form.cMunicipio.value==""){
		alert(strMsgErro+"O campo Municipio não pode estar em branco.");
		obj_form.cMunicipio.focus();
		return false;
	}else if(obj_form.cEstado.value==""){
		alert(strMsgErro+"O campo Estado não pode estar em branco.");
		obj_form.cEstado.focus();
		return false;
	}else if(obj_form.cCep.value==""){
		alert(strMsgErro+"O campo CEP não pode estar em branco.");
		obj_form.cCep.focus();
		return false;
	}else if(obj_form.cCNPJ.value==""){
		alert(strMsgErro+"O campo CNPJ não pode estar em branco.");
		obj_form.cCNPJ.focus();
		return false;
	}else if(obj_form.cIE.value==""){
		alert(strMsgErro+"O campo Inscricao Estadual não pode estar em branco.");
		obj_form.cIE.focus();
		return false;
		
	}else{
		return true;
	}
}


function validateEntregaFisica(obj_form, fgAjaxAtualiza, idUsuario){
	if(obj_form.cNome.value==""){
		alert(strMsgErro+"O campo Nome não pode estar em branco.");
		obj_form.cNome.focus();
		return false;
	}else if(obj_form.cEndereco.value==""){
		alert(strMsgErro+"O campo Endereco não pode estar em branco.");
		obj_form.cEndereco.focus();
		return false;
	}else if(obj_form.cNumero.value==""){
		alert(strMsgErro+"O campo Numero não pode estar em branco.");
		obj_form.cNumero.focus();
		return false;
	}else if(obj_form.cBairro.value==""){
		alert(strMsgErro+"O campo Bairro não pode estar em branco.");
		obj_form.cBairro.focus();
		return false;
	}else if(obj_form.cMunicipio.value==""){
		alert(strMsgErro+"O campo Municipio não pode estar em branco.");
		obj_form.cMunicipio.focus();
		return false;
	}else if(obj_form.cEstado.value==""){
		alert(strMsgErro+"O campo Estado não pode estar em branco.");
		obj_form.cEstado.focus();
		return false;
	}else if(obj_form.cCep.value==""){
		alert(strMsgErro+"O campo CEP não pode estar em branco.");
		obj_form.cCep.focus();
		return false;
		
	}else{
		return true;
	}
}
