function Mascara(e,src,mask) {
    if(window.event) { _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 != 8) { return false; } 
 else { return true; }
    }
}

	function filtroCategoria(string,id) { //v2.0
		location='/busca.php?categoria='+id+string;
		//window.open(theURL);
	}

	function filtroSubCategoria(string,id) { //v2.0
		location='/busca.php?subcategoria='+id+string;
		//window.open(theURL);
	}

	function filtroRegiao1(string,id) { //v2.0
		location='/busca.php?regiao1='+id+string;
		//window.open(theURL);
	}

	function filtroRegiao2(string,id) { //v2.0
		location='/busca.php?regiao2='+id+string;
		//window.open(theURL);
	}

	function filtroRegiao3(string,id) { //v2.0
		location='/busca.php?regiao3='+id+string;
		//window.open(theURL);
	}
	
/* pg indique*/
	function ChecaformIndique() {
		with (document.formIndique)
		{
			if (!ind_nome.value) {
			alert ('Por favor, preencha o campo Nome!');
			ind_nome.focus();
			return (false);
			}
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test (ind_email.value))){
				alert ('Por favor, informe o Email corretamente!');
				ind_email.focus();
				return (false);
			}
			if (!ind_msg.value) {
			alert ('Por favor, preencha o campo Mensagem!');
			ind_msg.focus();
			return (false);
			}
			if (!ind_nome_dest.value) {
			alert ('Por favor, preencha o campo Nome do Destinatário!');
			ind_nome_dest.focus();
			return (false);
			}
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test (ind_email_dest.value))){
				alert ('Por favor, informe o Email corretamente do Destinatário!');
				ind_email_dest.focus();
				return (false);
			}
			if (!imagem.value) {
			alert ('Por favor, preencha o valor da imagem!');
			imagem.focus();
			return (false);
			}
		//return true;
		Modalbox.show('indique.php', {title: '<?=utf8_decode(htmlentities("Indicação Enviada"))?>', width: 760, params: Form.serialize('formIndique'), method:'post' }); return false;
		}
	}
/**/

	function ChecaformContato() {
		with (document.formContato)
		{
			
			if (document.formContato.con_motivo.value=='') {
			alert ('Por favor, selecione o motivo do Contato!');
			con_motivo.focus();
			return (false);
			}
			
			if (!con_nome.value) {
			alert ('Por favor, preencha o campo Nome!');
			con_nome.focus();
			return (false);
			}
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test (con_email.value))){
				alert ('Por favor, informe o Email corretamente!');
				con_email.focus();
				return (false);
			}
			if (!con_telefone_res.value) {
			alert ('Por favor, preencha o campo Telefone Residencial!');
			con_telefone_res.focus();
			return (false);
			}
			if (!con_endereco.value) {
			alert ('Por favor, preencha o campo Endereço!');
			con_endereco.focus();
			return (false);
			}
			if (!con_endereco_num.value) {
			alert ('Por favor, preencha o campo Número!');
			con_endereco_num.focus();
			return (false);
			}		
			if (!con_bairro.value) {
			alert ('Por favor, preencha o campo Bairro!');
			con_bairro.focus();
			return (false);
			}	
			if (!con_cidade.value) {
			alert ('Por favor, preencha o campo Cidade!');
			con_cidade.focus();
			return (false);
			}
			if (!con_comentarios.value) {
			alert ('Por favor, preencha o campo Comentário!');
			con_comentarios.focus();
			return (false);
			}										
			if (!imagem.value) {
			alert ('Por favor, preencha o valor da imagem!');
			imagem.focus();
			return (false);
			}
		return true;
		}
	}
	


/*FUNCAO PARA CONTAGEM DE TEXTAREA*/	
function textarea_forms(maximo,campo,camporestante) {
      var comp = document.getElementById(campo).value.length
      var restam = maximo - comp
      document.getElementById(camporestante).innerHTML = restam + " caracteres restantes"
      if(comp > maximo) {
            document.getElementById(campo).value = document.getElementById(campo).value.substring(0, maximo);
      }

}


/* pg newsletter*/
	function ChecaformNewsletter() {
		with (document.newsletter)
		{
			if (!txtNome.value) {
			alert ('Por favor, preencha com seu Nome!');
			txtNome.focus();
			return (false);
			}
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test (txtEmail.value))){
				alert ('Por favor, informe o Email corretamente!');
				txtEmail.focus();
				return (false);
			}
		//return true;
		Modalbox.show('newsletter.php', {title: 'Newsletter: Confirme seus dados', width: 760, params: Form.serialize('newsletter'), method:'post' }); return false;
		}
	}
	
	function ChecaformNewsletter2() {
		with (document.formNews)
		{
			if (!txtNome.value) {
			alert ('Por favor, preencha o campo Nome!');
			txtNome.focus();
			return (false);
			}
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test (txtEmail.value))){
				alert ('Por favor, informe o Email corretamente!');
				txtEmail.focus();
				return (false);
			}
			if (!imagem.value) {
			alert ('Por favor, preencha o valor da imagem!');
			imagem.focus();
			return (false);
			}			
		//return true;
		Modalbox.show('newsletter.php', {title: 'Newsletter: Confirme a imagem', width: 720, params: Form.serialize('formNews'), method:'post' }); return false;
		}
	}	

	function ChecaformNewsletterRemove() {
		with (document.formNews)
		{
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test (txtEmail.value))){
				alert ('Por favor, informe o Email corretamente!');
				txtEmail.focus();
				return (false);
			}
			if (!imagem.value) {
			alert ('Por favor, preencha o valor da imagem!');
			imagem.focus();
			return (false);
			}			
		//return true;
		Modalbox.show('newsletter_remove.php', {title: 'Newsletter: Confirme a imagem', width: 720, params: Form.serialize('formNews'), method:'post' }); return false;
		}
	}		
/*FIM*/

/* CURRICULOS */
	function ChecaformVagas() {
		with (document.formVagas)
		{
			if (!cv_nome.value) {
			alert ('Por favor, preencha o campo Nome!');
			cv_nome.focus();
			return (false);
			}
			if (!cv_rg.value){
				alert ('Por favor, preencha o campo RG!');
				cv_rg.focus();
				return (false);
			}
			if (!cv_cpf.value){
				alert ('Por favor, preencha o campo CPF!');
				cv_cpf.focus();
				return (false);
			}
			if (!cv_nascimento.value){
				alert ('Por favor, preencha o campo Data de Nascimento!');
				cv_nascimento.focus();
				return (false);
			}
			if (!cv_endereco.value){
				alert ('Por favor, preencha o campo Endereço!');
				cv_endereco.focus();
				return (false);
			}
			if (!cv_endereco_num.value){
				alert ('Por favor, preencha o campo Número!');
				cv_endereco_num.focus();
				return (false);
			}			
			if (!cv_bairro.value){
				alert ('Por favor, preencha o campo Bairro!');
				cv_bairro.focus();
				return (false);
			}	
			if (!cv_cidade.value){
				alert ('Por favor, preencha o campo Cidade!');
				cv_cidade.focus();
				return (false);
			}
			if (!cv_cep.value){
				alert ('Por favor, preencha o campo CEP!');
				cv_cep.focus();
				return (false);
			}																						
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test (cv_email.value))){
				alert ('Favor informar um Email válido!');
				cv_email.focus();
				return (false);
			}
			if (!cv_telefone_res.value) {
			alert ('Por favor, preencha o campo Telefone Residencial!');
			cv_telefone_res.focus();
			return (false);
			}
			if (!imagem.value) {
			alert ('Por favor, preencha o valor da imagem!');
			imagem.focus();
			return (false);
			}
		return true;
		}
	}
/* FIM CURRICULOS */	

/* pg indique*/
	function ChecaformBuscaEmail() {
		with (document.formIndique)
		{
			if (!ind_nome.value) {
			alert ('Por favor, preencha o campo Nome!');
			ind_nome.focus();
			return (false);
			}
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test (ind_email.value))){
				alert ('Por favor, informe o Email corretamente!');
				ind_email.focus();
				return (false);
			}
			if (!ind_telefone_res.value) {
			alert ('Por favor, preencha o campo Telefone!');
			ind_telefone_res.focus();
			return (false);
			}
			if (!ind_assunto.value) {
			alert ('Por favor, preencha o campo Assunto!');
			ind_assunto.focus();
			return (false);
			}
			if (!ind_msg.value) {
			alert ('Por favor, preencha o campo Mensagem!');
			ind_msg.focus();
			return (false);
			}
			if (!imagem.value) {
			alert ('Por favor, preencha o valor da imagem!');
			imagem.focus();
			return (false);
			}
		//return true;
		Modalbox.show('email_busca.php', {title: 'E-mail Enviado', width: 760, params: Form.serialize('formIndique'), method:'post' }); return false;
		}
	}
/**/

/*ADICIONAR AOS FAVORITOS*/
function add_favoritos() { 
var browsName = navigator.appName; 
	if (browsName == "Microsoft Internet Explorer") { 
		window.external.AddFavorite('http://www.nossobairro.com','Nosso Bairro - Facil de Procurar, facil de achar!' );
	} else { 
		alert ("Para adicionar o portal Nosso Bairro aos favoritos,  aperte CTRL+D"); 
	}
}
/*FIM FAVORITOS*/

/* ADICIONAR PÁGINA INICIAL */
function add_pg_inicial() { 
var browsName = navigator.appName; 
	if (browsName == "Microsoft Internet Explorer") { 
		document.write("<a href=\"#.\" title=\"P&aacute;gina Inicial\" onClick=\"this.style.behavior='url(#default#homepage)'; this.setHomePage('http://www.nossobairro.com');\">P&aacute;gina Inicial</a>");
	} else { 
		document.write("<a href=\"#.\" title=\"P&aacute;gina Inicial\" onClick=\"javascript:Alert_('Para adicionar o portal Nosso Bairro como pagina inicial, clique na barra de ferramentas -> Op&ccedil;&otilde;es e troque para http://www.nossobairro.com')\">P&aacute;gina Inicial</a>");
	}
}
/*FIM FAVORITOS*/

/* ALERT*/
function Alert_(msg) { 
		alert(msg); 
}
/*FIM ALERT*/

/*IMPRIMIR*/
function Imprimir(){
for(var i=0; i < document.getElementsByName('selPrint1').length; i++)
if(document.getElementsByName('selPrint1')[i].type == 'checkbox')
if(document.getElementsByName('selPrint1')[i].checked)
return true;
alert('Por favor, selecione uma empresa para imprimir!');
return false;
}
/*FIM IMPRIMIR*/

/*MARCAR/DESMARCAR CHECKBOX*/
function caixas_checkbox(){
    if (!document.getElementsByName('selPrint1')[0].checked){
        marcar_todos();
    }
    else{
        desmarcar_todos();
    }
}

function marcar_todos(){
var j;
j=0;
	for (i=0;i<document.selectPrints.elements.length;i++){
		//if(document.getElementsByName('selPrint1')[i].checked==false){
		  
		 //alert(i);
		  if( j < 10){
		  	  document.getElementsByName('selPrint1')[i].checked=1;
			  xajax_Imprimir(document.getElementsByName('selPrint1')[i].value);
			  j++;
		  }
		  
		//}
	}	
	//alert(document.selectPrints.elements.length+' '+j);
}

function desmarcar_todos(){
var j;
j=0;
		for (i=0;i<document.selectPrints.elements.length;i++){
			//if(document.getElementsByName('selPrint1')[i].checked==true){
			if( j < 10){			
			  document.getElementsByName('selPrint1')[i].checked=0;
			  xajax_Imprimir(document.getElementsByName('selPrint1')[i].value);
			   j++;
			}
			  
			//}
		}
}
/*FIM MARCAR/DESMARCAR*/

//var menuids=["suckertree1"] //Enter id(s) of SuckerTree UL menus, separated by commas
var menuids=["suckertree1","suckertree12"] //Enter id(s) of SuckerTree UL menus, separated by commas

function buildsubmenus(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
    ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle"
		if (ultags[t].parentNode.parentNode.id==menuids[i]) //if this is a first level submenu
			ultags[t].style.left=ultags[t].parentNode.offsetWidth+"px" //dynamically position first level submenus to be width of main menu item
		else //else if this is a sub level submenu (ul)
		  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.display="block"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.display="none"
    }
    }
		for (var t=ultags.length-1; t>-1; t--){ //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars
		ultags[t].style.visibility="visible"
		ultags[t].style.display="none"
		}
  }
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus)