function EnviarBusca(){
		//$('#form_busca').ready(function() {
		$('#form_busca').submit();
//	});
}

function validaForm2(){
			//validar nome
		doc = document.enviarPost;
		if (doc.nomeOrigem.value == ""){
			alert("O campo Nome deve ser preenchido!");
			doc.nomeOrigem.focus();
			return false;
		}
		
		//validar email
		if (doc.emailOrigem.value == ""){
			alert("O campo E-mail deve ser preenchido!");
			doc.emailOrigem.focus();
			return false;
		}

return true;
}

function validaForm(){
		//validar nome
		d = document.cadastro;
		if (d.NOME.value == ""){
			alert("O campo " + d.NOME.name + " deve ser preenchido!");
			d.NOME.focus();
			return false;
		}
		
		//validar email
		if (d.EMAIL.value == ""){
			alert("O campo " + d.EMAIL.name + " deve ser preenchido!");
			d.EMAIL.focus();
			return false;
		}

		var email = d.EMAIL;
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(email.value)) {
			alert('Informe um E-mail válido');
			d.EMAIL.focus();
			return false;
		}
		
		//validar email(verificao de endereco eletronico)
		//parte1 = d.EMAIL.value.indexOf("@");
//		parte2 = d.EMAIL.value.indexOf(".");
//		parte3 = d.EMAIL.value.length;
//		if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
//			alert("O campo " + d.EMAIL.name + " deve ser conter um endereco eletronico!");
//			d.EMAIL.focus();
//			return false;
//		}

		//validar telefone
		if (d.TELEFONE.value == ""){
			alert("O campo " + d.TELEFONE.name + " deve ser preenchido!");
			d.TELEFONE.focus();
			return false;
		}

		if (d.TELEFONE.value.length != 14){
			alert("Preencha o campo " + d.TELEFONE.name + " corretamente!");
			d.TELEFONE.focus();
			return false;
		}
		

		//validar senha
		if (d.comentario.value == ""){
			alert("O campo " + d.comentario.name + " deve ser preenchido!");
			d.comentario.focus();
			return false;
		}
		
		if(d.ClienteClaro1.checked){
		    if(d.TipoClienteClaro.value == "0"){
		        alert("Selecione seu tipo de plano.");
		        d.TipoClienteClaro.focus();
		        return false;
		    }
		}

		//código de verificação
		if (d.cpts.value == ""){
			alert("Informe o Código de verificação!");
			d.cpts.focus();
			return false;
		}
		

		return true;
	}


//FUNÇÕES AJAX
function GetXMLHttp() {  
    if (navigator.appName == "Microsoft Internet Explorer") {  
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  
    } else {  
        xmlHttp = new XMLHttpRequest();  
    }  
    return xmlHttp;  
}  

var mod = GetXMLHttp();  

function abrirPost(POST_ID, DIV) {
	$("h1").html("&nbsp;");
	$('h6').removeClass('h6Ativo');
	$('a').removeClass('vermelho');
	$('a').removeClass('linkVermelho');
	
	$("#"+POST_ID).addClass('h6Ativo');
	
	mod.open("GET", "asp/Carrega.asp?POST_ID="+POST_ID+"", true); 
	mod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
	mod.onreadystatechange = function() {  
	if (mod.readyState == 4) {

		$("#"+"a"+POST_ID).addClass('vermelho');
		document.getElementById('blocoCentro').innerHTML = mod.responseText;  
		$("html, body").animate({
			scrollTop: $("#container").offset().top
		}, 800);
		$("h1").html("&nbsp;");
	}  
};  
 mod.send(null);  
} 

function PostAvaliar(rating)
{
	
	var postid = document.getElementById('hddpostid').value;

	mod.open("GET", "asp/proc_rating.asp?postid="+postid+"&rating="+rating, false); 
	mod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
	mod.onreadystatechange = function() {  
	if (mod.readyState == 4) {
		if(mod.responseText != '')
			//alert(mod.responseText);  
			document.getElementById('avisoPostAvaliar').innerHTML = mod.responseText;
	}  
};  
 mod.send(null);  
}

function setarRating(rating)
{
	for(i=1;i<=5;i++)
	{
		if(i<= rating)
			document.getElementById('star'+i).src = 'imagem/starFull2.gif';
		else
			document.getElementById('star'+i).src = 'imagem/starEmpty2.gif';
	}
}


function FiltraCategoria(menu_id,tag_id) {
	
	checkLinkAtivoTopo('linkHomeTopo')
	ativaSecao('linkCategoria');

	$('a').removeClass('linkVermelho');
	$('a').removeClass('vermelho');
	$('a').removeClass('tagVermelho');
	$('p').removeClass('linkVermelho');
	
	mod.open("GET", "asp/Carrega.asp?menu_id="+menu_id+"&tag_id="+tag_id+"&ACAO=FiltraCategoria", false); 
	mod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
	mod.onreadystatechange = function() {  
	if (mod.readyState == 4) {
		document.getElementById("blocoCentro").innerHTML = mod.responseText;  
		
		if(tag_id == 0) {
		$("#"+"l"+menu_id).addClass('linkVermelho');
		}
		$("#"+"T"+tag_id).addClass('tagVermelho');
		
		teste();
	}  
};  
 mod.send(null);  
} 

function Buscar(palavra,ano,mes,ordem) {

	document.getElementById('linkHomeTopo').className = 'mHomeAtivo';
	document.getElementById('linkRSS').className = 'mRss';
	document.getElementById('linkConduta').className = 'mCodigoconduta';
	document.getElementById('linkPodCast').className = 'mPodcast';
	document.getElementById('linkVideos').className = 'mVideo';
	document.getElementById('linkBlogueiro').className = 'mNossoBlogueiro';
	
	document.getElementById('secaoMaisAcessados').src = 'imagem/titMaisAcessado.png';
	document.getElementById('secaoComentariosRecente').src = 'imagem/titComentariosRecente.gif';
	document.getElementById('linkCategoria').src = 'imagem/titCategoria.png';
	document.getElementById('linkCategoria').src = 'imagem/titCategoria.png';

	$('a').removeClass('linkVermelho');
	$('a').removeClass('vermelho');
	$('a').removeClass('tagVermelho');
	$('p').removeClass('linkVermelho');

//	var str="Visit Microsoft!";
//	document.write(str.replace("Microsoft", "W3Schools"));
	
//	alert(palavra.replace("+","++"));
	
	palavra = (palavra.replace("+","xmaisx"));

	mod.open("GET", "asp/Carrega.asp?palavra="+palavra+"&ano="+ano+"&mes="+mes+"&ordem="+ordem+"&ACAO=Buscar", true); 
	mod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
	mod.onreadystatechange = function() {  
	if (mod.readyState == 4) {
		document.getElementById("blocoCentro").innerHTML = mod.responseText; 

			if(ano > 0) {
				
				//alertar
				$('#removeBusca1').hide()
				$('#removeBusca2').hide()
				//fim do alterar
				
				if(mes == 1){
					mesTitulo = "Janeiro"
					}
				if(mes == 2){
					mesTitulo = "Fevereiro"
					}
				if(mes == 3){
					mesTitulo = "Março"
					}
				if(mes == 4){
					mesTitulo = "Abril"
					}
				if(mes == 5){
					mesTitulo = "Maio"
					}
				if(mes == 6){
					mesTitulo = "Junho"
					}
				if(mes == 7){
					mesTitulo = "Julho"
					}
				if(mes == 8){
					mesTitulo = "Agosto"
					}
				if(mes == 9){
					mesTitulo = "Setembro"
					}
				if(mes == 10){
					mesTitulo = "Outubro"
					}
				if(mes == 11){
					mesTitulo = "Novembro"
					}
				if(mes == 12){
					mesTitulo = "Dezembro"
					}					
				
					$('h1').html("Arquivo / "+mesTitulo+" / "+ano+"");
			}
			
			$("html, body").animate({
				scrollTop: $("#container").offset().top
			}, 800);

			$("#slider").easySlider();
			$("#slider2").easySlider({
				prevId: 'prevBtn2',
				nextId: 'nextBtn2'			
			});			
	
	}  
};  
 mod.send(null);  
} 

function abrirPodCast(POST_ID) {
	mod.open("GET", "asp/Carrega.asp?POST_ID="+POST_ID+"&ACAO=abrirPodCast", true); 
	mod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
	mod.onreadystatechange = function() {  
	if (mod.readyState == 4) {
		document.getElementById('boxPostRecente').innerHTML = mod.responseText;  
		
		$("html, body").animate({
			scrollTop: $("#container").offset().top
		}, 800);
	}  
};  
 mod.send(null);  
} 

function enviarPost(POST_ID) {
	
	mod.open("GET", "asp/Carrega.asp?POST_ID="+POST_ID+"&ACAO=enviarPost", true); 
	mod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
	mod.onreadystatechange = function() {  
	if (mod.readyState == 4) {
		$('#imgenviePost').hide()
		$('#linkenviarPost').hide()
		//document.getElementById('imgenviePost').src = 'imagem/visualizarComentarios.gif';
		$("#linkEnviarPost").html("<a id='linkvisualizarComentarios' onClick='javascript: visualizarComentarios("+POST_ID+");' href='javascript:void(0);'><img id='imgvisualizarComentarios' src='imagem/visualizarComentarios.gif' alt='Visualizar Comentários' /></a>");		
		document.getElementById("idTeste").innerHTML = mod.responseText;  
		teste();
		
	}  
};  
 mod.send(null);  
} 

function visualizarComentarios(POST_ID) {
	
	mod.open("GET", "asp/Carrega.asp?POST_ID="+POST_ID+"&ACAO=visualizarComentarios", true); 
	mod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
	mod.onreadystatechange = function() {  
	if (mod.readyState == 4) {enviarPost
		$('#imgvisualizarComentarios').hide()
		$('#linkvisualizarComentarios').hide()
		$("#linkEnviarPost").html("<a id='linkenviarPost' onClick='javascript: enviarPost("+POST_ID+");' href='javascript:void(0);'><img id='imgenviePost' src='imagem/enviePost.gif' alt='' /></a>");
		document.getElementById("idTeste").innerHTML = mod.responseText;  
	}  
};  
 mod.send(null);  
} 


function linkVermelho(id)
{	
	$('p').removeClass('linkVermelho');
	$("#"+'menu1_'+id).addClass('linkVermelho');
	$("#"+'menu2_'+id).addClass('linkVermelhoComent');
	}


function linkVermelho2(id)
{	
	$('a').removeClass('vermelho');
	$("#"+'n_'+id).addClass('vermelho');
	}


function ativaSecao(id)
{
	checkLinkAtivoTopo('linkHomeTopo')
	$('a').removeClass('linkVermelho');	
	document.getElementById('secaoMaisAcessados').src = 'imagem/titMaisAcessado.png';
	document.getElementById('linkHomeTopo').className = 'mHomeAtivo';
	document.getElementById('linkCategoria').src = 'imagem/titCategoria.png';
	document.getElementById('secaoComentariosRecente').src = 'imagem/titComentariosRecente.gif';
	document.getElementById('secaoTagPalavra').src = 'imagem/titTagsPalavras.gif';

	if(id == 'secaoMaisAcessados'){
		document.getElementById('secaoMaisAcessados').src = 'imagem/titMaisAcessadoVermelho.png';
		//remover os demais
		document.getElementById('linkCategoria').src = 'imagem/titCategoria.png';
		document.getElementById('linkHomeTopo').className = 'mHomeAtivo';
		//checkLinkAtivoTopo('linkHomeTopo');
		$('a').removeClass('linkVermelho');	
		$("h1").html("&nbsp;");
		}
			
	if(id == 'linkCategoria')
		document.getElementById('linkCategoria').src = 'imagem/titCategoriaVermelho.png';
			
	if(id == 'secaoComentariosRecente')
		document.getElementById('secaoComentariosRecente').src = 'imagem/titComentariosRecenteVermelho.gif';
		document.getElementById('linkHomeTopo').className = 'mHomeAtivo';

	if(id == 'secaoTagPalavra')
		document.getElementById('linkCategoria').src = 'imagem/titCategoriaVermelho.png';
		
	if(id == 'ideiaSolta')
		document.getElementById('linkCategoria').src = 'imagem/titCategoriaVermelho.png';
		document.getElementById('linkHomeTopo').className = 'mHomeAtivo';
		document.getElementById('l25').className = 'linkVermelho';
		
	//if(id == 'leioteresTop5')
		//document.getElementById('linkCategoria').src = 'imagem/titLeitoresTopVermelho.png';
		//document.getElementById('linkHomeTopo').className = 'mHomeAtivo';
		//document.getElementById('l25').className = 'linkVermelho';
}


function checkLinkAtivoTopo(ativo)
{
	document.getElementById('linkHomeTopo').className = 'mHome';
	document.getElementById('linkSobreBlog').className = 'mSobreBlog';
	document.getElementById('linkConduta').className = 'mCodigoconduta';
	document.getElementById('linkPodCast').className = 'mPodcast';
	document.getElementById('linkRSS').className = 'mRss';
	document.getElementById('linkVideos').className = 'mVideo';
	document.getElementById('linkBlogueiro').className = 'mNossoBlogueiro';


if(ativo.indexOf('linkHomeTopo')!=-1)		
	document.getElementById('linkHomeTopo').className = 'mHomeAtivo';

if(ativo.indexOf('linkSobreBlog')!=-1)		
	document.getElementById('linkSobreBlog').className = 'mSobreBlogAtivo';

if(ativo.indexOf('linkConduta')!=-1)		
	document.getElementById('linkConduta').className = 'mCodigocondutaAtivo';

if(ativo.indexOf('linkPodCast')!=-1)		
	document.getElementById('linkPodCast').className = 'mPodcastAtivo';

if(ativo.indexOf('linkRSS')!=-1)		
	document.getElementById('linkRSS').className = 'mRssAtivo';

if(ativo.indexOf('linkVideos')!=-1)		
	document.getElementById('linkVideos').className = 'mVideoAtivo';

if(ativo.indexOf('linkBlogueiro')!=-1)		
	document.getElementById('linkBlogueiro').className = 'mNossoBlogueiroAtivo';
}

function maisAcessados() {

	
	checkLinkAtivoTopo('linkHomeTopo')
	ativaSecao('secaoMaisAcessados');
	

	$('a').removeClass('tagVermelho');
	$('a').removeClass('linkVermelho');	
	$('a').removeClass('vermelho');	
	$('p').removeClass('linkVermelho');	
	
	mod.open("GET", "asp/Carrega.asp?ACAO=MaisAcessados", true); 
	mod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
	mod.onreadystatechange = function() {  
	if (mod.readyState == 4) {
		document.getElementById("blocoCentro").innerHTML = mod.responseText;
	}  
};  
	mod.send(null);  
} 

function postRecente() {
    var pagina = parseInt($('#hddPagina').val(), 10) + 2;
    $('#hddPagina').val(pagina);

	mod.open("GET", "asp/Carrega.asp?pagina="+ pagina +"&ACAO=PostRecente", true); 
	mod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
	mod.onreadystatechange = function() {  
	if (mod.readyState == 4) {
		document.getElementById("blocoCentro").innerHTML = mod.responseText;
		
	}  
};  
	mod.send(null);  
} 


function leioteresTop5(EMAIL) {
	$('a').removeClass('tagVermelho');
	$('a').removeClass('linkVermelho');	
	$('a').removeClass('vermelho');	
	$('p').removeClass('linkVermelho');	
	mod.open("GET", "asp/Carrega.asp?comentario_autoremail="+EMAIL+"&ACAO=leioteresTop5", true); 
	mod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
	mod.onreadystatechange = function() {  
	if (mod.readyState == 4) {
		document.getElementById("blocoCentro").innerHTML = mod.responseText;
		$("html, body").animate({
			scrollTop: $("#container").offset().top
		}, 800);
	}  
};  
	mod.send(null);  
} 

function limparAtivos ()
{	
	$('a').removeClass('tagVermelho');
	$('a').removeClass('linkVermelho');
	$('a').removeClass('Vermelho');
	$('a').removeClass('vermelho');
	}

function comentariosRecente(menu_id) {
	//$('a').removeClass('tagVermelho');
//	$('a').removeClass('linkVermelho');
//	$('a').removeClass('Vermelho');
//	$('a').removeClass('vermelho');
//	checkLinkAtivoTopo('linkHomeTopo')
//	ativaSecao('secaoComentariosRecente');
//	$('a').removeClass('tagVermelho');
	
	
	checkLinkAtivoTopo('linkHomeTopo')
	ativaSecao('secaoMaisAcessados');

	$('a').removeClass('tagVermelho');
	$('a').removeClass('linkVermelho');	
	$('a').removeClass('vermelho');	
	$('p').removeClass('linkVermelho');	
	
	document.getElementById('secaoComentariosRecente').src = 'imagem/titComentariosRecenteVermelho.gif';
	document.getElementById('linkCategoria').src='/imagem/titCategoria.png';
    document.getElementById('secaoMaisAcessados').src='/imagem/titMaisAcessado.png';

	mod.open("GET", "asp/Carrega.asp?ACAO=comentariosRecente", true); 
	mod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
	mod.onreadystatechange = function() {  
	if (mod.readyState == 4) {
		document.getElementById("blocoCentro").innerHTML = mod.responseText;
		//$("#linkMaisAcessados").html("<img src='imagem/titMaisAcessadoVermelho.png' alt='Mais Acessados'/></a>");

		for(i=0;i<10;i++) //ativa o menu escolhido
		{
			if (menu_id == 'menu1_'+i){
			alert("x");
				$("#"+'menu1_'+i).addClass('linkVermelho');
			}
			else
				$("#"+'menu1_'+i).removeClass('linkVermelho');
		}
		
		$("html, body").animate({
			scrollTop: $("#container").offset().top
		}, 800);

	}  

};  
	mod.send(null);  
} 	

function votarEnquete(OPCAO_ID, ENQUETE_ID) {
	
	mod.open("GET", "asp/Carrega.asp?ENQUETE_ID="+ENQUETE_ID+"&OPCAO_ID="+OPCAO_ID+"&ACAO=votarEnquete", true); 
	mod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
	mod.onreadystatechange = function() {  
	if (mod.readyState == 4) {
		document.getElementById("enquete_novo").innerHTML = mod.responseText;
	}  
};  
	mod.send(null);
}

function comentarPost(POST_ID) {
	mod.open("GET", "asp/Carrega.asp?POST_ID="+POST_ID+"&ACAO=comentarPost", true); 
	mod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
	mod.onreadystatechange = function() {  
	if (mod.readyState == 4) {
		document.getElementById("idTeste").innerHTML = mod.responseText;
		$("#btnComentar").html("<img src='imagem/botComente.jpg' alt='' /></td>");
	}  
};  
	mod.send(null);
} 

var imgOn = "img/layout/star1.png";
var imgOff = "img/layout/star0.png";
var tm = 0;

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function setBusca(varBusca) {
	$("#q").val(varBusca);
	$("#buscaBlogTrue").val('true');
	$("#form1").submit();
}

function gotoHome() {
	document.location = '/index.asp';
}

$(document).ready(function () {
													
	showArquivoAno(new Date().getFullYear());
	
	//$("#twitter").getTwitter({
//			userName: "claroblog",
//			numTweets: 5,
//			loaderText: "...",
//			slideIn: false,
//			showHeading: false,						
//			showProfileLink: false
//		});
	
	
	$(".rankingStar").mouseover( function() {
		clearTimeout(tm);		
		var thisId = parseInt($(this).attr("name"));
		
		if (!isNaN(thisId))		
			$("#descRanking").html("Clique para dar nota " + thisId);
			
		$(".rankingStar").each(function(index) {			
			if (parseInt($(this).attr("name")) <= thisId) {
				$(this).attr("src", imgOn);
			} else {
				$(this).attr("src", imgOff);
			}
			});
	});
	
	$(".rankingStar").click( function() {
		var postId = parseInt($.query.get('post_id'));
		var nota = parseInt($(this).attr("name"));
		$("#descRanking").html("Aguarde...");
		$.get("/loader/setRanking.asp?post_id=" + postId + "&nota=" + nota, function (data) {
			if (parseInt(data) == 1)
				$("#descRanking").html("Voto registrado, obrigado!");
			else
				$("#descRanking").html("É permitido votar apenas uma vez!");
				
			tm = setTimeout(mostrarRanking,3000);
			});
	});
	
	$(".rankingStar").mouseout(function () {
		tm = setTimeout(mostrarRanking,1000);
	});
	
//mostrarRanking();
		
	});

function showArquivoAno(ano) {
	$(".novo").html("<img src='imagem/seta.gif' alt='' />");	
	$(".arquivoAno:visible").hide(300);
	$("#arquivoAno" + ano).show(300);
	$("#"+ano).html("<span class='novo'><img src='imagem/seta_down.gif' alt='' /></span>"+ano);
}

//function mostrarRanking() {
//	var postId = parseInt($.query.get('post_id'));
//	
//	if (isNaN(postId))
//		return;
//		
//		
//	$.get("/loader/getRanking.asp?post_id=" + postId, function (data) {
//		var r = parseInt(data);
//		
//		$(".rankingStar").each(function(index) {
//		if (parseInt($(this).attr("name")) <= r) {
//			$(this).attr("src", imgOn);
//		} else {
//			$(this).attr("src", imgOff);
//		}
//		});
//		
//		if (r == 0)
//			$("#descRanking").html("Seja o primeiro a avaliar");
//		else
//			$("#descRanking").html("Avalie");
//		
//	});
//}

function Mascara(objeto){
   if(objeto.value.length == 0)
     objeto.value = '(' + objeto.value;

   if(objeto.value.length == 3)
      objeto.value = objeto.value + ')';

 if(objeto.value.length == 8)
     objeto.value = objeto.value + '-';
}

function habilitarDiv () {
	$('#clienteClaro').show();
	$('#clienteClaro2').show();	
	}
	
function desabilitarDiv () {
	$('#clienteClaro').hide();
	$('#clienteClaro2').hide();	
	}
function txtFormat(id)
{
		var str = '1234567890.,!@#$%¨&*()_+<>:?^-}{';
	
		for(i=1;i<32;i++)
		{
			document.getElementById(id).value = document.getElementById(id).value.replace(str.substring(i-1,i),''); 		
		}
		return;
}



function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
 var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;


 if(document.all) { // Internet Explorer
  nTecla = evtKeyPress.keyCode;
 }
 else if(document.layers) { // Nestcape
  nTecla = evtKeyPress.which;
 } else { // Forçar Chrome e Firefox 5+
  nTecla = evtKeyPress.which;
 }

 
 sValue = objForm[strField].value;

 
 // Limpa todos os caracteres de formatação que
 // já estiverem no campo.
 sValue = sValue.toString().replace( "-", "" );
 sValue = sValue.toString().replace( "-", "" );
 sValue = sValue.toString().replace( ".", "" );
 sValue = sValue.toString().replace( ".", "" );
 sValue = sValue.toString().replace( "/", "" );
 sValue = sValue.toString().replace( "/", "" );
 sValue = sValue.toString().replace( "(", "" );
 sValue = sValue.toString().replace( "(", "" );
 sValue = sValue.toString().replace( ")", "" );
 sValue = sValue.toString().replace( ")", "" );
 sValue = sValue.toString().replace( " ", "" );
 sValue = sValue.toString().replace( " ", "" );
 fldLen = sValue.length;
 mskLen = sMask.length;

 
 i = 0;
 nCount = 0;
 sCod = "";
 mskLen = fldLen;

 
 while (i <= mskLen) {
  bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
  bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

 
  if (bolMask) {
  sCod += sMask.charAt(i);
  mskLen++; }
  else {
  sCod += sValue.charAt(nCount);
  nCount++;
  }

 
  i++;
 }

 
 objForm[strField].value = sCod;

 
 if (nTecla != 8) { // backspace
  if (sMask.charAt(i-1) == "9") { // apenas números...
  return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9
  else { // qualquer caracter...
  return true;
  } }
 else {
  return true;
 }
}

