/*FAQ*/
function applySelectedTo(link, abrir) {
	var ul = document.getElementById("sanfona"); // get the first ul tag on the page
	var allLinks = ul.getElementsByTagName("h3"); // get all the links within that ul
	
	for (var i=0; i<allLinks.length; i++) { // iterate through all those links
		allLinks[i].className = ""; // and assign their class names to nothing
		document.getElementById(allLinks[i].lang).style.display='none';
	}
	link.className = "ativo";  // finally, assign class="selected" to our chosen link
	document.getElementById(abrir).style.display='';
}
/*FAQ - Fim*/

/*Favoritos*/
function bookmarksite(title,url){
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}else if(document.all)// ie
		window.external.AddFavorite(url, title);
	else
		alert('Por favor, para adicionar este site ao favoritos, pressione as teclas CTRL+D em seu teclado. Obrigado.');
}
/*Favoritos - Fim*/

/*Voltar ao Topo*/
function scrollTop() {
	window.scroll(0,0); 
}
/*Voltar ao Topo - Fim*/

/*Voltar*/
function voltaBack() {
	history.back();
}
/*Voltar - Fim*/

/*Modulo Indique*/
ModuloIndique = function (pagina) {
	if (typeof pagina == 'undefined') pagina = '';
	novoBox('modulos/indique/cadIndique.php?pagina='+escape(pagina), '', 400, 320);	
}
/*Modulo Indique - Fim*/

/*Botão Ativo*/
function botaoAtivo(ativo) {
	
	// CONTROLE DOS BOTÕES
	
	var num_botoes = document.getElementsByName("menu_top").length;
	for (i = 0; i < num_botoes; i++){
		if (ativo == document.getElementsByName("menu_top")[i].id)
			document.getElementsByName("menu_top")[i].className = 'ativo';
		else
			document.getElementsByName("menu_top")[i].className = '';
	}
	
	// CONTROLE DOS BANNERS
	
//	var banner_index	= document.getElementById('banner_home');
	//var banner_home		= document.getElementById('banner_internas');
	
	
//	banner_index.style.display = (ativo == "btn_0")?'block':'none';
//	banner_home.style.display  = (ativo != "btn_0")?'block':'none';
}
/*Botão Ativo - Fim*/

/*Aumentar Fonte*/
// Para usar coloque o comando: "javascript:mudaTamanho('tag_ou_id_alvo', -1);" para diminuir
// e o comando "javascript:mudaTamanho('tag_ou_id_alvo', +1);" para aumentar
 
// Especificando os possíveis tamanhos de fontes, poderia ser: x-small, small...
var tamanhos = new Array( '100%','110%','120%','130%','140%','150%' );
var tamanhoInicial = 0;
 
function mudaTamanho( idAlvo,acao ){
  if (!document.getElementById) return
  var selecionados = null,tamanho = tamanhoInicial,i,j,tagsAlvo;
  tamanho += acao;
  if ( tamanho < 0 ) tamanho = 0;
  if ( tamanho > 4 ) tamanho = 4;
  tamanhoInicial = tamanho;
  if ( !( selecionados = document.getElementById( idAlvo ) ) ) selecionados = document.getElementsByTagName( idAlvo )[ 0 ];
  
	dives	= document.getElementsByTagName('div');
	for (i=0;i<dives.length;i++)  {
		if (dives[i].id==idAlvo)  {
			dives[i].style.fontSize = tamanhos[ tamanho ];
		}
	}
}
/*Aumentar Fonte - Fim*/

function barraLateral(ativo){
	if(ativo == 'S'){
		document.getElementById('conteudo_lateral').style.display = '';
	} else {
		document.getElementById('conteudo_lateral').style.display = 'none';
	}
}

/* CAD_CURRICULO */
var GTR_CAD_CURRICULO_ABA_ATIVA = 1;
function ativaAbaCuriculo(tab_id, valida) {
	if (typeof valida == 'undefined') valida = true;
	
	if (valida && !ativaAbaCuriculo(GTR_CAD_CURRICULO_ABA_ATIVA)) {
		return false;
	}
	
	GTR_CAD_CURRICULO_ABA_ATIVA = parseInt(tab_id.replace('tab_step', ''));
	
	var tabs = document.getElementById('abas').getElementsByTagName("a");
	var tab_conteudo_id;
	for(var i = 0; i < tabs.length; i++) {
		var tab = tabs[i];
		if (HasClassName(tab, "ativo")) {
			RemoveClassName(tab, "ativo");
			tab_conteudo_id = tab.id.substr(4,5);
			document.getElementById(tab_conteudo_id).style.display = "none";
		}
	}
	
	var tab_ativa = document.getElementById(tab_id);
	AddClassName(tab_ativa, "ativo");
	tab_conteudo_id = tab_ativa.id.substr(4,5);
	document.getElementById(tab_conteudo_id).style.display = "block";
	parent.scrollTop();
	
	return false;
}

function validaAbaCurriculo(tab_id){
	if (tab_id == 1){
		return validaAbaNum1Curriculo();
	}
	if (tab_id == 2){
		return validaAbaNum2Curriculo();
	}
	
	if (tab_id == 3){
		return validaAbaNum3Curriculo();
	}
	
	if (tab_id == 4){
		return validaAbaNum4Curriculo();
	}

	return true;
}

function ValidaCadCurriculo(){
	ativaAbaCuriculo('tab_step1', false);
	if (validaAbaNum1Curriculo() == false){
		ativaAbaCuriculo('tab_step1', false);
		return false;
	}
	
	ativaAbaCuriculo('tab_step2', false);
	if (validaAbaNum2Curriculo() == false){
		ativaAbaCuriculo('tab_step2', false);
		return false;
	}
	
	ativaAbaCuriculo('tab_step3', false);
	if (validaAbaNum3Curriculo() == false){
		ativaAbaCuriculo('tab_step3', false);
		return false;
	}
	
	ativaAbaCuriculo('tab_step4', false);
	if (validaAbaNum4Curriculo() == false){
		ativaAbaCuriculo('tab_step4', false);
		return false;
	}
	
	parent.document.forms['CadCurriculoMan'].submit();
}

function validaAbaNum1Curriculo(){
	var form						= document.getElementById('CadCurriculoMan');
	var nn_desnome					= form.nn_desnome.value;
	var nn_datnascimento_Dia		= form.nn_datnascimento_Dia.value;
	var nn_datnascimento_Mes		= form.nn_datnascimento_Mes.value;
	var nn_datnascimento_Ano		= form.nn_datnascimento_Ano.value;
	var nn_fontelefone				= form.nn_fontelefone.value;
	var nn_desendereco				= form.nn_desendereco.value;
	var nn_codpais					= form.nn_codpais.value;
	var nn_codestado				= form.nn_codestado.value;
	var nn_codcidade				= form.nn_codcidade.value;
	var nu_desestado_out			= form.nu_desestado_out.value;
	var nu_descidade_out			= form.nu_descidade_out.value;
	var nn_sonmudarcidade			= form.nn_sonmudarcidade.value;
	var nn_emlemail					= form.nn_emlemail.value;
	var nn_dessenha					= form.nn_dessenha.value;
	var nn_dessenha_conf			= form.nn_dessenha_conf.value;
	
	if (nn_desnome == ''){
		alert('Preencha o Nome Completo!');
		return false;
	}
	
	if(nn_datnascimento_Dia == '' && nn_datnascimento_Mes == '' && nn_datnascimento_Ano == ''){
		alert('Preencha o campo Data de Nascimento');
		return false;
	} else {	
		if (TestaDataDividida_Ext(form.nn_datnascimento_Dia, form.nn_datnascimento_Mes, form.nn_datnascimento_Ano, "Data de Nascimento") == false){
			return false;	
		}
	}
	
	if (nn_fontelefone == ''){
		alert('Preencha o Telefone Fixo!');
		return false;
	} else {
		if (nn_fontelefone.length != 13){
			alert('O campo Telefone Fixo não foi preechido corretamente.');
			return false;
		}
	}
	if (nn_desendereco == ''){
		alert('Preencha Endereço!');
		return false;
	}	
	if (nn_codpais == ''){
		alert('Preencha País!');
		return false;
	}else{
		if (nn_codpais == 1){
			if (nn_codestado == ''){
				alert('Preencha Estado!');
				return false;
			}			
			
			if (nn_codcidade == ''){
				alert('Preencha Cidade!');
				return false;
			}			
		}else if (nn_codpais == 2){
			if (nu_desestado_out == ''){
				alert('Preencha Estado!');
				return false;
			}			
			
			if (nu_descidade_out == ''){
				alert('Preencha Cidade!');
				return false;
			}	
		}
	}
	
	if (nn_sonmudarcidade == ''){
		alert('Preencha Disponibilidade para mudar de Cidade!');
		return false;
	}
	
	if (nn_emlemail == ''){
		alert('Preencha o Email');
		return false;
	} else {
		if (ChecaEmail(nn_emlemail, 'Email') == false){
			return false;
		}
	}
	
	if (nn_dessenha == ''){
		alert('Preencha sua senha!');
		return false;
	}else{
		if (nn_dessenha != nn_dessenha_conf){
			alert('Preencha sua Confirmação senha corretamente!');
			return false;
		}
	}

	return true;
}

function validaAbaNum2Curriculo(){
	// Mínimo de 1 obrigatório
	var linhas = document.getElementById('tblEscola').rows.length;
	if (linhas <= 0){
		alert('Escolaridade deve ter no mínimo uma informação!');
		return false;
	}
	
	return true;
}

function validaAbaNum3Curriculo(){
	// Não é obrigatório nenhuma empresa
	var form					= document.getElementById('CadCurriculoMan');
	var nn_sonprimeiro_emprego	= form.nn_sonprimeiro_emprego.value;
	var linhas					= document.getElementById('tblEmprego').rows.length;
	
	if (nn_sonprimeiro_emprego == 'NAO'){
		if (linhas <= 0){
			alert('Informe sua experiência profissional!');
			return false;
		}
	}
	
	return true;
}

function validaAbaNum4Curriculo(){
	var form = document.getElementById('CadCurriculoMan');
	var codcurriculo_cargo = form.nn_codcurriculo_cargo.value;
	
	if (codcurriculo_cargo == ''){
		alert('Preencha o campo Cargo Pretendido!');
		return false;
	}
	
	return true;
}



GTR_CurriculoAddEmprego = function (){
	var form		= document.getElementById("CadCurriculoMan");
	var empresa		= form.nu_desempresa.value;
	var estado		= form.nu_codestadoempresa.value;
	var cidade		= form.nu_codcidadeempresa.value;
	var telefone	= form.nu_telefone.value;
	var cargo		= form.nu_cargo.value;
	var datai_d		= form.nu_datperiodode_Dia.value;
	var datai_m		= form.nu_datperiodode_Mes.value;
	var datai_a		= form.nu_datperiodode_Ano.value;
	var dataf_d		= form.nu_datperiodoate_Dia.value;
	var dataf_m		= form.nu_datperiodoate_Mes.value;
	var dataf_a		= form.nu_datperiodoate_Ano.value;
	var motivosaida	= form.nu_motivosaida.value;
	var descricao	= form.nu_texdescricao.value;
	
	if(empresa.length <= 0){
		alert("Informe o nome da Empresa");	
		form.nu_desempresa.focus();
		return false;
	}
	
	if(estado == "") {
		alert("Informe o Estado");
		form.nu_codestadoempresa.focus();
		return false;
	}
	
	if(cidade == "") {
		alert("Informe a Cidade");
		form.nu_codcidadeempresa.focus();
		return false;
	}
	
	if(telefone.length != 13){
		alert("Informe o Telefone");	
		form.nu_telefone.focus();
		return false;
	}
	
	if(cargo == "") {
		alert("Informe o cargo");
		form.nu_cargo.focus();
		return false;
	}
	
	if (TestaDataDividida_Ext(form.nu_datperiodode_Dia, form.nu_datperiodode_Mes, form.nu_datperiodode_Ano, "Data Entrada") == false){
		return false;	
	}
	
	datai = new Date(datai_a, parseInt(datai_m) - 1, datai_d, 0, 0, 1);
	dataa = new Date();
	
	if (datai > dataa) {
		alert("A data de entrada é maior que a data atual");
		form.nu_datperiodode_Dia.focus();
		return false;
	}
	
	if (dataf_d != '' || dataf_m != '' || dataf_a != ''){
		if (TestaDataDividida_Ext(form.nu_datperiodoate_Dia, form.nu_datperiodoate_Mes, form.nu_datperiodoate_Ano, "Data Saída") == false){
			return false;	
		}
		
		dataf = new Date(dataf_a, parseInt(dataf_m) - 1, dataf_d, 0, 0, 1);
		if (datai > dataf) {
			alert("A data de entrada é maior que a data de saida");
			form.nu_datperiodode_Dia.focus();
			return false;
		}
		
		if(motivosaida == "") {
			alert("Informe o Motivo da saída");
			form.nu_motivosaida.focus();
			return false;
		}
	}

	
	if(descricao.length <= 0){
		alert("Informe a descrição das suas atividades nessa Empresa");
		form.nu_texdescricao.focus();
		return false;
	}
	

	
	var tabela = "tblEmprego";
	var linha = document.getElementById(tabela).insertRow(document.getElementById(tabela).rows.length);
	
	// limpa caracteres
	empresa.replace("'", "");
	cargo.replace("'", "");
	motivosaida.replace("'", "");
	descricao.replace("'", "");
	
	
	
	var cmpEmpresa		= "<input type='hidden' name='nu_emprego_empresa[]' value='"+empresa+"'>";
	var cmpEstado		= "<input type='hidden' name='nu_emprego_estado[]' value='"+estado+"'>";
	var cmpCidade		= "<input type='hidden' name='nu_emprego_cidade[]' value='"+cidade+"'>";
	var cmpTelefone		= "<input type='hidden' name='nu_emprego_telefone[]' value='"+telefone+"'>";
	var cmpCargo		= "<input type='hidden' name='nu_emprego_cargo[]' value='"+cargo+"'>";
	var cmpDataI_Dia	= "<input type='hidden' name='nu_emprego_datai_Dia[]' value='"+datai_d+"'>";
	var cmpDataI_Mes	= "<input type='hidden' name='nu_emprego_datai_Mes[]' value='"+datai_m+"'>";
	var cmpDataI_Ano	= "<input type='hidden' name='nu_emprego_datai_Ano[]' value='"+datai_a+"'>";
	var cmpDataF_Dia	= "<input type='hidden' name='nu_emprego_dataf_Dia[]' value='"+dataf_d+"'>";
	var cmpDataF_Mes	= "<input type='hidden' name='nu_emprego_dataf_Mes[]' value='"+dataf_m+"'>";
	var cmpDataF_Ano	= "<input type='hidden' name='nu_emprego_dataf_Ano[]' value='"+dataf_a+"'>";
	var cmpMotivo		= "<input type='hidden' name='nu_emprego_motivo[]' value='"+motivosaida+"'>";
	var cmpDescricao	= "<input type='hidden' name='nu_emprego_descricao[]' value='"+descricao+"'>";
	
	var camposOcultos	=  cmpEmpresa + cmpEstado + cmpCidade + cmpTelefone + cmpCargo;
	camposOcultos		+= cmpDataI_Dia + cmpDataI_Mes + cmpDataI_Ano;
	camposOcultos		+= cmpDataF_Dia + cmpDataF_Mes + cmpDataF_Ano;
	camposOcultos		+= cmpMotivo + cmpDescricao;
	
	var HTML = "<p>Empresa: " + empresa + "<a href='javascript: void(0);' onClick='GTR_CurriculoDel(this.parentNode.parentNode.parentNode.rowIndex);'><img align='absmiddle' src='img/btn/	' width='14' height='15' alt='Excluir' border='0' style='margin-right:10px;' /></a></p>";
	HTML += "<ul>";
	HTML += "<li>&raquo; Estado: " + form.nu_codestadoempresa.options[form.nu_codestadoempresa.selectedIndex].text + "</li>";
	HTML += "<li>&raquo; Cidade: " + form.nu_codcidadeempresa.options[form.nu_codcidadeempresa.selectedIndex].text + "</li>";
	HTML += "<li>&raquo; Telefone: " + telefone + "</li>";
	HTML += "<li>&raquo; Cargo: " + cargo + "</li>";
	HTML += "<li>&raquo; Data de entrada: " + datai_d + "/" + datai_m + "/" + datai_a + "</li>";
	
	var dataSaida = ""
	if (dataf_d != ''){
		dataSaida = dataf_d + "/" + dataf_m + "/" + dataf_a;
	}
	
	HTML += "<li>&raquo; Data de saída: " + dataSaida + "</li>";
	HTML += "<li>&raquo; Motivo da saída: " + motivosaida + "</li>";
	HTML += "<li>&raquo; Descrição das atividades: " + descricao + "</li>";
	HTML += "</ul>";
	
	var col = linha.insertCell(0);
	col.innerHTML	= HTML;
	
	col = linha.insertCell(1);
	col.innerHTML = camposOcultos;
	col.valing = "top";
	
	form.nu_desempresa.value		= "";
	form.nu_cargo.value				= "";
	form.nu_datperiodode_Dia.value	= "";
	form.nu_datperiodode_Mes.value	= "";
	form.nu_datperiodode_Ano.value	= "";
	form.nu_datperiodoate_Dia.value	= "";
	form.nu_datperiodoate_Mes.value	= "";
	form.nu_datperiodoate_Ano.value	= "";
	form.nu_texdescricao.value		= "";
	form.nu_codestadoempresa.selectedIndex = 0;
	form.nu_codcidadeempresa.selectedIndex = 0;
	form.nu_telefone.value = "";
	form.nu_motivosaida.value = "";
}

GTR_CurriculoDel = function (i){
	document.getElementById('tblEmprego').deleteRow(i)
}

GTR_CurriculoAddFilhoIdade = function (){
	var form		= document.getElementById("CadCurriculoMan");
	var idade		= form.nu_desidade.value;
	
	if(idade.length <= 0){
		alert("Informe a Idade do Filho");	
		form.nu_desidade.focus();
		return false;
	}
		
	form.nu_desidade.value	= "";
	form.nu_desidade.focus();
	
	
	var tabela = "tblFilhoIdade";
	var linha = document.getElementById(tabela).insertRow(document.getElementById(tabela).rows.length);
	var indice_linha_nova = parseInt(document.getElementById(tabela).rows.length,10);
	// limpa caracteres
	idade.replace("'", "");
	
	var cmpIdade		= "<input type='hidden' name='nu_filho_idade[]' value='"+idade+"'>";
	var camposOcultos	= cmpIdade;
	
	var col = linha.insertCell(0);
	var complemento = '';
	if(IsNumeric(idade)){
		complemento = ' anos';
	}
	
	var HTML = "<p><a href='javascript: void(0);' onClick='GTR_CurriculoDelFilhoIdade(this.parentNode.parentNode.parentNode.rowIndex);'><img align='absmiddle' src='img/btn/btn_janela_close.png' width='14' height='15' alt='Excluir' border='0' style='margin-right:10px;' /></a>&nbsp;&nbsp;&nbsp;Filho <span style='display:inline;' id='filho_"+indice_linha_nova+"'>"+indice_linha_nova+"</span>:&nbsp;" + idade+complemento + "</p>";
	//HTML += "<ul>";
	//HTML += "<li>&raquo; Idade: " + idade+complemento + "</li>";
	//HTML += "</ul>";
	
	col.innerHTML	= HTML;
	
	col = linha.insertCell(1);
	col.innerHTML = camposOcultos;
	col.valign = "top";
}
GTR_CurriculoDelFilhoIdade = function (i){
	var tam = parseInt(document.getElementById("tblFilhoIdade").rows.length,10);
	var limite = i+1;
	var nova_posicao = '';
	for(var idx=tam;idx>limite;idx--){
		nova_posicao = parseInt(document.getElementById("filho_"+idx).innerHTML,10) - 1;
		document.getElementById("filho_"+idx).innerHTML = nova_posicao;
		document.getElementById("filho_"+idx).id 		= "filho_" + nova_posicao;
	}
	
	document.getElementById('tblFilhoIdade').deleteRow(i);
}


GTR_CurriculoAddEscola = function (){
	var form		= document.getElementById("CadCurriculoMan");
	var entidade	= form.nu_desentidade.value;
	var curso		= form.nu_descurso.value;
	var graduacao	= form.nu_graduacao.value;
	var ano			= form.nu_intano.value;
	
	if(entidade.length <= 0){
		alert("Informe o nome da Entidade");	
		form.nu_desentidade.focus();
		return false;
	}
	
	if(curso == "") {
		alert("Informe o curso");
		form.nu_descurso.focus();
		return false;
	}
	
	
	if(graduacao.length <= 0){
		alert("Informe a graduação");
		form.nu_graduacao.focus();
		return false;
	}
	
	if(ano.length <= 0){
		alert("Informe a o ano da conclusão");
		form.nu_intano.focus();
		return false;
	}
	
	if(ano.length < 4){
		alert("O ano da conclusão deve conter 4 digitos");
		form.nu_intano.focus();
		return false;
	}
	
	form.nu_desentidade.value	= "";
	form.nu_descurso.value		= "";
	form.nu_graduacao.value		= "";
	form.nu_intano.value		= "";
	
	var tabela = "tblEscola";
	var linha = document.getElementById(tabela).insertRow(document.getElementById(tabela).rows.length);
	
	// limpa caracteres
	entidade.replace("'", "");
	curso.replace("'", "");
	graduacao.replace("'", "");
	ano.replace("'", "");
	
	var cmpEntidade		= "<input type='hidden' name='nu_escola_entidade[]' value='"+entidade+"'>";
	var cmpCurso		= "<input type='hidden' name='nu_escola_curso[]' value='"+curso+"'>";
	var cmpGraduacao	= "<input type='hidden' name='nu_escola_graduacao[]' value='"+graduacao+"'>";
	var cmpAno			= "<input type='hidden' name='nu_escola_ano[]' value='"+ano+"'>";
	var camposOcultos	= cmpEntidade + cmpCurso + cmpGraduacao + cmpAno;
	
	var col = linha.insertCell(0);
	var HTML = "<p><a href='javascript: void(0);' onClick='GTR_CurriculoDelEscola(this.parentNode.parentNode.parentNode.rowIndex);'><img style='background: #9E3737;' align='absmiddle' src='img/btn/btn_janela_close.png' width='16' height='16' alt='Excluir' border='0' /></a> &nbsp; &nbsp; &nbsp; Entidade: " + entidade + "</p>";
	HTML += "<ul style='margin-left:45px; '>";
	HTML += "<li>&raquo; Curso: " + curso + "</li>";
	HTML += "<li>&raquo; Graduação: " + graduacao + "</li>";
	HTML += "<li>&raquo; Ano de Conclusão: " + ano + "</li>";
	HTML += "</ul>";
	
	col.innerHTML	= HTML;
	
	col = linha.insertCell(1);
	col.innerHTML = camposOcultos;
	col.valign = "top";
}

GTR_CurriculoDelEscola = function (i){
	document.getElementById('tblEscola').deleteRow(i)
}

function ativaAba(tab_id, valida) {
	if (typeof valida == 'undefined') valida = true;
	
	if (valida && !validaAba(GTR_CAD_CLIENTE_ABA_ATIVA)) {
		return false;
	}
	
	GTR_CAD_CLIENTE_ABA_ATIVA = parseInt(tab_id.replace('tab_step', ''));
	
	var tabs = document.getElementById('abas').getElementsByTagName("a");
	for(var i = 0; i < tabs.length; i++) {
		var tab = tabs[i];
		if (HasClassName(tab, "ativo")) {
			RemoveClassName(tab, "ativo");
			tab_conteudo_id = tab.id.substr(4,5);
			document.getElementById(tab_conteudo_id).style.display = "none";
		}
	}
	
	tab_ativa = document.getElementById(tab_id);
	AddClassName(tab_ativa, "ativo");
	tab_conteudo_id = tab_ativa.id.substr(4,5);
	document.getElementById(tab_conteudo_id).style.display = "block";
	parent.scrollTop();
	
	return false;
}
/* FIM CAD_CURRICULO */

// ----------------------------------------------------------------------------
// HasClassName
//
// Description : returns boolean indicating whether the object has the class name
//    built with the understanding that there may be multiple classes
//
// Arguments:
//    objElement              - element to manipulate
//    strClass                - class name to add
//
function HasClassName(objElement, strClass) {

	// if there is a class
	if ( objElement.className ) {
	
		// the classes are just a space separated list, so first get the list
		var arrList = objElement.className.split(' ');
		
		// get uppercase class for comparison purposes
		var strClassUpper = strClass.toUpperCase();
		
		// find all instances and remove them
		for ( var i = 0; i < arrList.length; i++ ) {		
			// if class found
			if ( arrList[i].toUpperCase() == strClassUpper ) {
				// we found it
				return true;		
			}		
		}
	
	}
	
	// if we got here then the class name is not there
	return false;

}
// 
// HasClassName
// ----------------------------------------------------------------------------

// ----------------------------------------------------------------------------
// AddClassName
//
// Description : adds a class to the class attribute of a DOM element
//    built with the understanding that there may be multiple classes
//
// Arguments:
//    objElement              - element to manipulate
//    strClass                - class name to add
//
function AddClassName(objElement, strClass, blnMayAlreadyExist) {

	// if there is a class
	if ( objElement.className ) {
	
		// the classes are just a space separated list, so first get the list
		var arrList = objElement.className.split(' ');
		
		// if the new class name may already exist in list
		if ( blnMayAlreadyExist ) {
		
			// get uppercase class for comparison purposes
			var strClassUpper = strClass.toUpperCase();
			
			// find all instances and remove them
			for ( var i = 0; i < arrList.length; i++ ) {			
				// if class found
				if ( arrList[i].toUpperCase() == strClassUpper) {				
					// remove array item
					arrList.splice(i, 1);					
					// decrement loop counter as we have adjusted the array's contents
					i--;				
				}			
			}		
		}
		
		// add the new class to end of list
		arrList[arrList.length] = strClass;
		
		// add the new class to beginning of list
		//arrList.splice(0, 0, strClass);
		
		// assign modified class name attribute
		objElement.className = arrList.join(' ');
	
	} else {
		// if there was no class
		
		// assign modified class name attribute      
		objElement.className = strClass;	
	}
}
// 
// AddClassName
// ----------------------------------------------------------------------------


// ----------------------------------------------------------------------------
// RemoveClassName
//
// Description : removes a class from the class attribute of a DOM element
//    built with the understanding that there may be multiple classes
//
// Arguments:
//    objElement              - element to manipulate
//    strClass                - class name to remove
//
function RemoveClassName(objElement, strClass) {

	// if there is a class
	if ( objElement.className ) {
	
		// the classes are just a space separated list, so first get the list
		var arrList = objElement.className.split(' ');
		
		// get uppercase class for comparison purposes
		var strClassUpper = strClass.toUpperCase();
		
		// find all instances and remove them
		for ( var i = 0; i < arrList.length; i++ ) {		
			// if class found
			if ( arrList[i].toUpperCase() == strClassUpper ) {		
				// remove array item
				arrList.splice(i, 1);		
				// decrement loop counter as we have adjusted the array's contents
				i--;		
			}		
		}
		
		// assign modified class name attribute
		objElement.className = arrList.join(' ');
	
	}
	// if there was no class
	// there is nothing to remove
}
// 
// RemoveClassName
// ----------------------------------------------------------------------------

function abre_filial(estado){
	var pai = document.getElementById(estado);
	var filho = document.getElementById('fil_'+estado);
	if(filho.style.display == 'none'){
		filho.style.display = '';
		pai.setAttribute("class","ativo");
	} else {
		filho.style.display = 'none';
		pai.setAttribute("class","");
	}
}

function boxAtivo(arr_box){
	//var boxes = document.getElementsByName("box_lateral_prog");
	var divboxes = document.getElementById('boxes_prog');
	var boxes = divboxes.getElementsByTagName('div');
	for(var idx=0;idx<boxes.length;idx++){
		if(boxes[idx].id.search("box_conteudo") != -1){
			boxes[idx].style.display = 'none';
		}
	}
	
	var box_ativo = arr_box.split(',');
	for(var i=0;i<box_ativo.length;i++){
		document.getElementById('box_conteudo_'+box_ativo[i]).style.display = '';
	}	
}

function muda_infofilhos(status){
	if(status == "SIM"){
		document.getElementById('tr_infofilho').style.display = '';
		document.getElementById('nu_intqtdefilho').focus();
	} else {
		document.getElementById('tr_infofilho').style.display = 'none';
		document.getElementById('nu_desidade').value = '';
		document.getElementById('nu_intqtdefilho').value = '';
		var linhas_infofilho = parseInt(document.getElementById('tblFilhoIdade').rows.length,10);
		for(var i=linhas_infofilho-1;i>-1;i--){
			document.getElementById('tblFilhoIdade').deleteRow(i);
		}
	}
}

function IsNumeric(value){	
	var er = /^[0-9,\.]+$/;
	return (er.test(value)) ? true : false;
}

// Inicio da função TestaDataDividida
function TestaDataDividida_Ext(dia1, mes1, ano1, desData){
    dia = dia1.value;
    mes = mes1.value;
    ano = ano1.value;
    msgErro = '';
    if ( (isNaN(dia)) || (isNaN(mes)) || (isNaN(ano)) || (ano==0) ) 
    {
		errData	= GTR_TXT_DATAINVALIDA.replace("%", desData);
        alert(errData);
        dia1.value = '';
        return false;
     }
  
    if ( (dia=="") && (mes=="") && (ano=="") ) 
    {
        errData	= GTR_TXT_DATCORRETAMENTE.replace("%", desData);
        alert(errData);
        dia1.value = '';
        return false;
    }  
    else
    {           
        if ( (dia=="") || (mes=="") || (ano=="") ) 
        {
			errData	= GTR_TXT_DATAINVALIDA.replace("%", desData);
			alert(errData);
            dia1.value = '';
            return false;
        } 
        else
        {
            if ((dia>31)||(dia<1))
            {
				errData	= GTR_TXT_DIAINVALIDO.replace("%", desData);
				alert(errData);
                dia1.value = '';
                return false;
            }
            if ((mes>12)||(mes<1))
            {
				errData	= GTR_TXT_MESINVALIDO.replace("%", desData);
				alert(errData);
                mes1.value = '';
                return false;
            }
            if (ano.length < 4) 
            {
				errData	= GTR_TXT_ANOINVALIDO.replace("%", desData);
				alert(errData);
                ano1.value = '';
                return false;
            }   
            if (mes==2)
            {
                if (((dia)>29)||(dia=='29' && (ano)%4!=0)) 
                {

					errData	= GTR_TXT_DIAINVALIDO.replace("%", desData);
					alert(errData);
                    dia1.value = '';
                    return false;
                }
            }
            else
            {
                if ( ( (mes==4) || (mes==6) || (mes==9) || mes=='11') && (dia>30) ) 
                {
					errData	= GTR_TXT_DIAINVALIDO.replace("%", desData);
					alert(errData);
                    dia1.value = '';
                    return false;
                }    
                else
                { 
                    if (dia>31)
                    {
						errData	= GTR_TXT_DIAINVALIDO.replace("%", desData);
						alert(errData);
                        dia1.value = '';
                        return false;
                    }  
                }    
            } 
        }
    }
    return true;

}
// Final da função TestaDataDividida



function detCliente(codcliente){
	novoBox('modulos/cliente/detCliente.php?codcliente=' + codcliente, '', 350, 400);
}

var objGalCliente = {
	  itens: []
	, pagina: 1
};

function galCliente(pos){
	var proxPagina = (pos == '-') ? objGalCliente.pagina - 1 : objGalCliente.pagina + 1;
	
	if (proxPagina < 1) proxPagina = 1;
	if (proxPagina > objGalCliente.itens.length) proxPagina = 1;
	
	if (proxPagina > 1) $j('#cliNagAnterior').show();
	if (proxPagina < 2) $j('#cliNagAnterior').hide();
	
	if (proxPagina < objGalCliente.itens.length) $j('#cliNagProxima').show();
	if (proxPagina == objGalCliente.itens.length) $j('#cliNagProxima').hide();
	
	objGalCliente.pagina = proxPagina;
	
	var idx = proxPagina - 1;
	
	$j('#cliLegenda')[0].innerHTML = objGalCliente.itens[idx].legenda;
	$j('#cliPortfolio')[0].innerHTML = '<img src="../../lib/upload/preview.php?codsisupload=' + objGalCliente.itens[idx].codsisupload + '" border="0" />';
}

function configHome(){
	$j(".logo_unidade").bind("mouseenter mouseleave", function(e){
		var cmpImg		= $j(this).find('img');
		var imgColorida	= '../../lib/upload/preview.php?codsisupload=' + cmpImg.attr('colorida');
		var imgCinza	= '../../lib/upload/preview.php?codsisupload=' + cmpImg.attr('cinza');
		var img			= (cmpImg.attr('src') == imgColorida) ? imgCinza : imgColorida;
		
		cmpImg.attr('src', img);
    });
	
	JSliderNews();
}

function JSliderNews(){
	$j('#banner_flash_home').lofJSidernews({ 
		interval:4000,
		easing:'easeInOutQuad',
		duration:1200,
		auto:true,
		maxItemDisplay: 3
	});
}

function Orcamento(codproduto){
	novoBox('modulos/produto/cadOrcamento.php?codproduto=' + codproduto, '', 500, 600);
}

function manOrcamento(){
	if (gtr_submit('cadOrcamento', 'false')){
		$j.post('modulos/produto/manOrcamento.php', $j('#cadOrcamento').serializeArray(), function (retorno){
			$j('#cadOrcamentoBox').hide();
			$j('#cadOrcamentoRespostaBox').html(retorno).show();
		});
	}
	
	return false;
}

function trocaFonesEmail(fone, email){
	$j('#sp_tel_unidade').html(fone);
	$j('#sp_email_unidade').html(email);
}

var objFoneEmailMatriz = {fone: '', email: ''};
function trocaFonesEmailMatriz(){
	trocaFonesEmail(objFoneEmailMatriz.fone, objFoneEmailMatriz.email);
}

function VerMapa(codunidade){
	novoBox('modulos/unidade/detMapa.php?codunidade=' + codunidade, '', 600, 600);
}

function ValidaCNPJ(cnpj) {

  var i = 0;
  var l = 0;
  var strNum = "";
  var strMul = "6543298765432";
  var character = "";
  var iValido = 1;
  var iSoma = 0;
  var strNum_base = "";
  var iLenNum_base = 0;
  var iLenMul = 0;
  var iSoma = 0;
  var strNum_base = 0;
  var iLenNum_base = 0;

  //if (cnpj == "")
        //return ("Preencha o campo CNPJ.");
				
		

  l = cnpj.length;
  for (i = 0; i < l; i++) {
        caracter = cnpj.substring(i,i+1)
        if ((caracter >= '0') && (caracter <= '9'))
           strNum = strNum + caracter;
  };

  if(strNum.length != 14)
        return ("CNPJ deve conter 14 caracteres.");

  strNum_base = strNum.substring(0,12);
  iLenNum_base = strNum_base.length - 1;
  iLenMul = strMul.length - 1;
  for(i = 0;i < 12; i++)
        iSoma = iSoma +
                        parseInt(strNum_base.substring((iLenNum_base-i),(iLenNum_base-i)+1),10) *
                        parseInt(strMul.substring((iLenMul-i),(iLenMul-i)+1),10);

  iSoma = 11 - (iSoma - Math.floor(iSoma/11) * 11);
  if(iSoma == 11 || iSoma == 10)
        iSoma = 0;

  strNum_base = strNum_base + iSoma;
  iSoma = 0;
  iLenNum_base = strNum_base.length - 1
  for(i = 0; i < 13; i++)
        iSoma = iSoma +
                        parseInt(strNum_base.substring((iLenNum_base-i),(iLenNum_base-i)+1),10) *
                        parseInt(strMul.substring((iLenMul-i),(iLenMul-i)+1),10)

  iSoma = 11 - (iSoma - Math.floor(iSoma/11) * 11);
  if(iSoma == 11 || iSoma == 10)
        iSoma = 0;
  strNum_base = strNum_base + iSoma;
  if(strNum != strNum_base)
        return ("CNPJ inválido.");

  return (true);

}






function str_pad (input, pad_length, pad_string, pad_type) {
    // Returns input string padded on the left or right to specified length with pad_string 
    //
    // version: 909.322
    // discuss at: http://phpjs.org/functions/str_pad
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // + namespaced by: Michael White (http://getsprink.com)
    // +      input by: Marco van Oort
    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: str_pad('Kevin van Zonneveld', 30, '-=', 'STR_PAD_LEFT');
    // *     returns 1: '-=-=-=-=-=-Kevin van Zonneveld'
    // *     example 2: str_pad('Kevin van Zonneveld', 30, '-', 'STR_PAD_BOTH');
    // *     returns 2: '------Kevin van Zonneveld-----'
    var half = '', pad_to_go;
 
    var str_pad_repeater = function (s, len) {
        var collect = '', i;
 
        while (collect.length < len) {collect += s;}
        collect = collect.substr(0,len);
 
        return collect;
    };
 
    input += '';
    pad_string = pad_string !== undefined ? pad_string : ' ';
     
    if (pad_type != 'STR_PAD_LEFT' && pad_type != 'STR_PAD_RIGHT' && pad_type != 'STR_PAD_BOTH') { pad_type = 'STR_PAD_RIGHT'; }
    if ((pad_to_go = pad_length - input.length) > 0) {
        if (pad_type == 'STR_PAD_LEFT') { input = str_pad_repeater(pad_string, pad_to_go) + input; }
        else if (pad_type == 'STR_PAD_RIGHT') { input = input + str_pad_repeater(pad_string, pad_to_go); }
        else if (pad_type == 'STR_PAD_BOTH') {
            half = str_pad_repeater(pad_string, Math.ceil(pad_to_go/2));
            input = half + input + half;
            input = input.substr(0, pad_length);
        }
    }
 
    return input;
}
function cnpjValido(cnpj) {
		
	regExp = /[^0-9]/gi;
	
	if(cnpj[0] == 0) {
		cnpj = cnpj.substring(1, cnpj.length);
	}
	
	cnpj = str_pad(cnpj.replace(regExp, ''), 14, '0', 'STR_PAD_LEFT');
	
	if(cnpj == '00000000000000' || cnpj == '11111111111111' || cnpj == '22222222222222' || cnpj == '33333333333333' || cnpj == '44444444444444' || cnpj == '55555555555555' || cnpj == '66666666666666' || cnpj == '77777777777777' || cnpj == '88888888888888' || cnpj == '99999999999999') {
		return false;
	} else if(cnpj.length != 14) {
		return false;
	} else {
		for (t = 12; t < 14; t++) {
			for (d = 0, p = t - 7, c = 0; c < t; c++) {
				d += cnpj[c] * p;
				p   = (p < 3) ? 9 : --p;
			}
			
			d = ((10 * d) % 11) % 10;
			
			if (cnpj[c] != d) {
				return false;
			}
		}
		
		return true;
	}
}
function teste_paralelo_orcamento() {
	try {
		var cnpj = document.forms['cadOrcamento'].nn_descnpj;
		if(cnpj.value){
			if(!cnpjValido(cnpj.value)){
				alert("O CNPJ informado é inválido. Por favor, verifique.");
				document.forms['cadOrcamento'].nn_descnpj.select();
				return false;
			}
		}
		
		var telefone = document.forms['cadOrcamento'].nn_fontelefone;
		var tel_naopermitido = Array("(00)0000-0000", "(11)1111-1111", "(22)2222-2222", "(33)3333-3333", "(44)4444-4444", "(55)5555-5555", "(66)6666-6666", "(77)7777-7777", "(88)8888-8888", "(99)9999-9999");
		
		if(telefone.value){
			if(in_array(telefone.value, tel_naopermitido)){
				alert("O Telefone informado é inválido. Por favor, verifique.");
				return false;
			}
		}
		
		var arquivo = document.forms['cadOrcamento'].nu_uplarquivo;
		var permitido = Array("pdf", "png", "jpg", "bmp", "pcx", "tif", "ps", "eps", "txt", "psd", "pcl", "raw", "cdr", "doc", "docx", "xls", "xlsx", "ptt", "pttx", "rar", "zip", "ai", "indd");
		
		if(arquivo.value){
			var tipo_arquivo = arquivo.value.toLowerCase().split('.');
			var ext = tipo_arquivo[tipo_arquivo.length-1];
			if(in_array(ext, permitido) == false){
				alert("Por favor, anexe um arquivo dos tipos:\n"+permitido.toString());
				document.forms['cadOrcamento'].nu_uplarquivo.select();
				return false;
			}
		}
		return true;
	}
	catch(e)  {
		return false;
	}
}
