var templatesArray = new Array();

function vcnpj( c ) {
	var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais, cnpj = c.value.replace(/\D+/g, '');
	digitos_iguais = 1;
	if (cnpj.length != 14) 
            {
                 c.focus();
                 return false;
                 }

     for (i = 0; i < cnpj.length - 1; i++)
           if (cnpj.charAt(i) != cnpj.charAt(i + 1))
                 {
                 digitos_iguais = 0;
                 break;
                 }
     if (!digitos_iguais)
           {
           tamanho = cnpj.length - 2
           numeros = cnpj.substring(0,tamanho);
           digitos = cnpj.substring(tamanho);
           soma = 0;
           pos = tamanho - 7;
           for (i = tamanho; i >= 1; i--)
                 {
                 soma += numeros.charAt(tamanho - i) * pos--;
                 if (pos < 2)
                       pos = 9;
                 }
           resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
           if (resultado != digitos.charAt(0)){
//                 alert('CNPJ inválido');
                 c.focus();
                 return false;
                 }

           tamanho = tamanho + 1;
           numeros = cnpj.substring(0,tamanho);
           soma = 0;
           pos = tamanho - 7;
           for (i = tamanho; i >= 1; i--)
                 {
                 soma += numeros.charAt(tamanho - i) * pos--;
                 if (pos < 2)
                       pos = 9;
                 }
           resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
           if (resultado != digitos.charAt(1)){
//               alert('CNPJ inválido');
                 c.focus();
              alert('ret.03');
                 return false;
                 }
           else {
     // alert('CNPJ  OK !');
            return true;
            }
           }
     else{
//           alert('CNPJ inválido');
           c.focus();
           return false;
    }
} 

// JavaScript Document
var conteudoGMapas = "";
conteudoGMapas += '<div id="modulo_gmaps">';
conteudoGMapas += '<a class="close" href="javascript: fechaBox();"><img src="modulos/google_maps/img/btn_janela_close.png" style="width:auto; height:auto" /></a>';

conteudoGMapas += '<iframe name="detGoogleMaps" id="detGoogleMaps" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="modulos/google_maps/detGoogleMaps.php" width="480" height="410" style="overflow-x: hidden; margin-bottom:10px;"></iframe>';
conteudoGMapas += '</iframe>';

conteudoGMapas += '<strong class="name">Acácia Consultoria</strong> - ';
conteudoGMapas += '<span class="street">Av. Rio Branco, 1132 - térreo - Ed. Rio Negro Center</span><br />';
conteudoGMapas += '<span class="city_state">CEP 17502-000 - Marília/SP</span><br />';
conteudoGMapas += '<span class="phone">Fone: +55 (14)2105-3333<br />E-mail: acacia@acaciaconsultoria.com.br</span>';

conteudoGMapas += '</div>';

ModuloIndique = function(args)  {
	args	= escape(args);
	novoBox('modulos/indique/cadIndique.php?pagina=' + args, '', 480, 300);
}

VideoYoutube = function (vid)
{
	novoBox('detVideo.php?vid=' + vid, '', 540, 430);
}

function fechaBoxVideo()
{
	messageObj.__insertContent('');
	messageObj.close();
}

function applySelectedTo(link, abrir, tag) {
	if (typeof tag == 'undefined') tag = '';
	var ul = document.getElementById("sanfona"+tag); // 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='';
}

function AbreFecha(objSeta, id) {
	$j("#"+id).slideToggle('slow');
	$j(objSeta).toggleClass('ativo');
}

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);
}

// 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%','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 ];
		}
	}
}

function scrollTop()  {
	window.scroll(0,0); 
}

function voltaBack()  {
	history.back();
}

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);
}

function ativaMenus(id_principal, id_secundaria) {
	
	elms = document.getElementById('maintab').getElementsByTagName("li");
	for(var i = 0, maxI = elms.length; i < maxI; ++i) {
		var elm = elms[i];
		RemoveClassName(elm,'selected');
	}
	
	elms = document.getElementById('sub_menu').getElementsByTagName("a");
	for(var i = 0, maxI = elms.length; i < maxI; ++i) {
		var elm = elms[i];
		RemoveClassName(elm,'ativo');
	}
	
	elms = document.getElementById('sub_menu').getElementsByTagName("div");
	for(var i = 0, maxI = elms.length; i < maxI; ++i) {
		var elm = elms[i];
		elm.style.display="none";
	}
	
	elem_principal = document.getElementById(id_principal);
	if (id_principal != '' && elem_principal) 
		AddClassName(elem_principal,'selected');
		
	elem_secundaria = document.getElementById(id_secundaria);
	if (id_secundaria != '' && elem_secundaria) 
		AddClassName(elem_secundaria,'ativo');
		
	initalizetab("maintab");
	
}

// ----------------------------------------------------------------------------
// 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
// ----------------------------------------------------------------------------



/* detProduto */

var timerMenu = null;
function tMenuL()
{
	if (timerMenu) {
		clearInterval(timerMenu);
		timerMenu = null;
	}
	timerMenu = setInterval(function(){SubMenu('E');}, 60);
}

function tMenuD()
{
	if (timerMenu) {
		window.clearInterval(timerMenu);
		timerMenu = null;
	}
	timerMenu = setInterval(function(){SubMenu('D');}, 60);
}

function tMenuOff()
{
	if (timerMenu) {
		window.clearInterval(timerMenu);
		timerMenu = null;
	}
}

function SubMenu(dir)
{
	var obj = document.getElementById('mnuProdutos');
	if (dir == 'E') {
		obj.scrollLeft -= 5;
	}
	else {
		obj.scrollLeft += 5;
	}
}

function GerMenu(ul)
{
	var mnu = ul.getElementsByTagName('ul')[0];
	if (mnu.className == 'ul_close'){
		mnu.className = 'ul_open';
	}else{
		mnu.className = 'ul_close';
	}
}

function IniciaBusca(form)
{
	var ac		= (form.tpBusca[0].checked) ? 'lisBuscaProduto.php' : 'lisBusca.php';
	form.action	= ac;
	
	if (form.q.value == 'Digite o que procura')
		form.q.value = '';
	
	if (form.q.value == '') {
		alert('Pro favor, preencha o campo de pesquisa.');
		form.q.focus();
		return false;
	} else {
		return true;
	}
}

function Galeria(codproduto, largura, altura, imgdst)
{	
	if (typeof imgdst == 'undefined') imgdst = '';
	
	largura += 100;
	altura += 100;
	novoBox('modulos/produto/detProdutoGaleria.php?id_produto='+codproduto+'&src='+ imgdst + '&lgr='+largura, '', largura, altura);
}

function OpenFilter(largura, altura)
{	
	largura += 100;
	altura += 100;
	novoBox('modulos/produto/lisFiltro.php', '', largura, altura);
}

//http://www.nickstakenburg.com/projects/prototip2/
var arrTip = new Array();
function GerarTooltip()
{
	Tips.removeAll();
	GerarTooltipMnu();
	
	var conteudo = "<table>";
	conteudo += '<tr valign="top">';
	conteudo += '<td>$imagem$</td>';
	conteudo += '<td>$conteudo$</td>';
	conteudo += '</tr>';
	conteudo += '</table>';
	
	var txtImg;
	var txtCont;
	var txtConteudoFinal;
	for (var i = 0; i < arrTip.length; i++){
		txtConteudoFinal = conteudo;
		
		if (arrTip[i].imagem){
			txtImg = '<td width="275">';
			txtImg += '<img src="funcao/imagem.php?src='+arrTip[i].imagem+'" alt="'+arrTip[i].titulo+'" title="'+arrTip[i].titulo+'" />';
			txtImg += '</td>';
			
			txtConteudoFinal = txtConteudoFinal.replace('$imagem$', txtImg);
		}else{
			txtConteudoFinal = txtConteudoFinal.replace('$imagem$', '');
		}
	
		if ($(arrTip[i].eltxt) && $(arrTip[i].eltxt).innerHTML){
			txtCont = '<td width="215" style="padding-left:10px;">';
			txtCont += $(arrTip[i].eltxt).innerHTML;
			txtCont += '</td>';
			
			txtConteudoFinal = txtConteudoFinal.replace('$conteudo$', txtCont);
		}else{
			txtConteudoFinal = txtConteudoFinal.replace('$conteudo$', '');
		}
		if (document.getElementById(arrTip[i].el))
			new Tip(arrTip[i].el, txtConteudoFinal, {title: arrTip[i].titulo, style: 'default'});
	}

}

function MudarCarac()
{
	$('frmCarac').submit()
	$('conteudo').innerHTML = htmlAjaxLoader; 
}
	
function checkCombo(combo_id, div_id) {
	if (document.getElementById(combo_id)[document.getElementById(combo_id).selectedIndex].text == "Outros")
		document.getElementById(div_id).style.display = "block";
	else
		document.getElementById(div_id).style.display = "none";
}

function checkMTU(elm, div_id) {
	if (elm.getAttribute("lblDesc") == "Outros" && elm.checked)
		document.getElementById(div_id).style.display = "block";
	
	if (elm.getAttribute("lblDesc") == "Outros" && elm.checked == false)
		document.getElementById(div_id).style.display = "none";
}


function checkMTUOutros(elm, div_id) {
	if (elm.checked)
		document.getElementById(div_id).style.display = "block";
	else
		document.getElementById(div_id).style.display = "none";
}


function clienteRemoveFornecedor(i)
{
	document.getElementById('tblFornecedores').deleteRow(i)
}

function clienteAddFornecedor(){
	var form		= document.cadCliente;
	var empresa		= form.nu_desfornempresa.value;
	var contato		= form.nu_desforncontato.value;
	var telefone	= form.nu_fonforntelefone.value;
	
	if(empresa.length <= 0){
		alert("Informe o nome da Empresa");	
		form.nu_desfornempresa.focus();
		return false;
	}
	
	if(contato == "") {
		alert("Informe o contato");
		form.nu_desforncontato.focus();
		return false;
	}
	
	if(telefone == "") {
		alert("Informe o telefone");
		form.nu_fonforntelefone.focus();
		return false;
	}
	
	form.nu_desfornempresa.value	= "";
	form.nu_desforncontato.value	= "";
	form.nu_fonforntelefone.value	= "";
	
	var tabela = "tblEmprego";
	var linha = document.getElementById(tabela).insertRow(document.getElementById(tabela).rows.length);
	linha.className = "tr_listagem";
	
	// limpa caracteres
	empresa.replace("'", "");
	contato.replace("'", "");
	telefone.replace("'", "");
	
	var cmpEmpresa		= "<input type='hidden' name='nu_emprego_empresa[]' value='"+empresa+"'>";
	var cmpContato		= "<input type='hidden' name='nu_emprego_contato[]' value='"+contato+"'>";
	var cmpTelefone		= "<input type='hidden' name='nu_emprego_telefone[]' value='"+telefone+"'>";
	
	linha.insertCell(0).innerHTML = empresa + cmpEmpresa;
	linha.insertCell(1).innerHTML = contato + cmpContato;
	linha.insertCell(2).innerHTML = telefone + cmpTelefone;
	linha.insertCell(3).innerHTML = "<a href='javascript: void(0);' onClick='clienteRemoveFornecedor(this.parentNode.parentNode.rowIndex);'><img src='img/btn/btn_fechar.gif' alt='Excluir' border='0' /></a>";
}



function produtoRemove(i)
{
	document.getElementById('tblProdComercializado').deleteRow(i)
}

function produtoAdd(){
	var form		= document.cadCliente;
	var produto		= form.nu_prod_clientes_tipo_produto;
	var empresa		= form.nu_prod_desempresa.value;
	var modelo		= form.nu_prod_desmodelo.value;

	if(produto.selectedIndex <= 0){
		alert("Informe o tipo do produto");	
		form.nu_prod_clientes_tipo_produto.focus();
		return false;
	}
	
	if(empresa == "") {
		alert("Informe o nome da Empresa");
		form.nu_prod_desempresa.focus();
		return false;
	}
	
	if(modelo == "") {
		alert("Informe o modelo do produto");
		form.nu_prod_desmodelo.focus();
		return false;
	}
	
	var tabela = "tblProdComercializado";
	var linha = document.getElementById(tabela).insertRow(document.getElementById(tabela).rows.length);
	linha.className = "tr_listagem";
	
	// limpa caracteres
	empresa.replace("'", "");
	modelo.replace("'", "");
	
	var cmpProduto		= "<input type='hidden' name='nu_produto_nome[]' value='"+produto.value+"'>";
	var cmpEmpresa		= "<input type='hidden' name='nu_produto_empresa[]' value='"+empresa+"'>";
	var cmpModelo		= "<input type='hidden' name='nu_produto_modelo[]' value='"+modelo+"'>";
	
	linha.insertCell(0).innerHTML = produto.options[produto.selectedIndex].text + cmpProduto;
	linha.insertCell(1).innerHTML = empresa + cmpEmpresa;
	linha.insertCell(2).innerHTML = modelo + cmpModelo;
	linha.insertCell(3).innerHTML = "<a href='javascript: void(0);' onClick='produtoRemove(this.parentNode.parentNode.rowIndex);'><img src='img/btn/btn_fechar.gif' alt='Excluir' border='0' /></a>";
	
	form.nu_prod_clientes_tipo_produto.selectedIndex= 0;
	form.nu_prod_desempresa.value	= "";
	form.nu_prod_desmodelo.value	= "";
}





function Removertolltips(){
	arrTip = new Array();
	Tips.removeAll();
}

/* CAD_CLIENTE*/
var GTR_CAD_CLIENTE_ABA_ATIVA = 1;
var GTR_TXT_MESINVALIDO = GTR_TXT_ANOINVALIDO = GTR_TXT_DATAINVALIDA;

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;
}

function validaAba(tab_id){
	if (tab_id == 2){
		return validaAbaNum2();
	}
	
	if (tab_id == 3){
		return validaAbaNum3();
	}

	return true;
}

function ValidaCadCliente(){
	if (validaAbaNum2() == false){
		ativaAba('tab_step2', false);
		return false;
	}
	
	if (validaAbaNum3() == false){
		ativaAba('tab_step3', false);
		return false;
	}

	ativaAba('tab_step5', false);

	return true;
}

function validaAbaNum2(){
	var form = document.getElementById('cadCliente');
	var nn_desnomefantasia			= form.nn_desnomefantasia.value;
	var nn_desrazaosocial			= form.nn_desrazaosocial.value;
	var nn_desendereco				= form.nn_desendereco.value;
	var nn_desbairro				= form.nn_desbairro.value;
	var nn_cepcep					= form.nn_cepcep.value;
	var nu_codestado				= form.nu_codestado.value;
	var nu_codcidade				= form.nu_codcidade.value;
	var nn_fontelefone1				= form.nn_fontelefone1.value;
	var nn_descnpj					= form.nn_descnpj.value;
	var nn_desinscricaoestadual		= form.nn_desinscricaoestadual.value;
	var nn_descontato				= form.nn_descontato.value;
	var nn_descargo					= form.nn_descargo.value;
	var nn_emlemail					= form.nn_emlemail.value;
	var nn_datinicioatividades_Dia	= form.nn_datinicioatividades_Dia.value;
	var nn_datinicioatividades_Mes	= form.nn_datinicioatividades_Mes.value;
	var nn_datinicioatividades_Ano	= form.nn_datinicioatividades_Ano.value;
	
	if (nn_desnomefantasia == ''){
		alert('Preencha o campo Nome Fantasia');
		//form.nn_desnomefantasia.focus();
		return false;
	}
	
	if (nn_desrazaosocial == ''){
		alert('Preencha o campo Razão Social');
		//form.nn_desrazaosocial.focus();
		return false;
	}
	
	if (nn_desendereco == ''){
		alert('Preencha o campo Rua/Av.');
		//form.nn_desendereco.focus();
		return false;
	}
	
	if (nn_desbairro == ''){
		alert('Preencha o campo Bairro');
		//form.nn_desbairro.focus();
		return false;
	}
	
	if (nn_cepcep.length != 9){
		alert('Preencha o campo CEP corretamente');
		//form.nn_cepcep.focus();
		return false;
	}
	
	if (nu_codestado == ''){
		alert('Preencha o campo Estado corretamente');
		//form.nn_cepcep.focus();
		return false;
	}
	
	if (nu_codcidade == ''){
		alert('Preencha o campo Cidade corretamente');
		//form.nn_cepcep.focus();
		return false;
	}
	
	
	if (nn_fontelefone1.length != 13){
		alert('Preencha o campo Telefone 1 corretamente');
		//form.nn_fontelefone1.focus();
		return false;
	}
	
	if (validaCNPJ(nn_descnpj) == false){
		return false;
	}	
	
	if (nn_desinscricaoestadual == ''){
		alert('Preencha o campo I.E.');
		//form.nn_desinscricaoestadual.focus();
		return false;
	}
	
	if (nn_descontato == ''){
		alert('Preencha o campo Contato');
		//form.nn_descontato.focus();
		return false;
	}	
	
	if (nn_descargo == ''){
		alert('Preencha o campo Cargo');
		//form.nn_descargo.focus();
		return false;
	}
	
	if (!ChecaEmail(nn_emlemail, 'E-mail')){
		//form.nn_emlemail.focus();
		return false;
	}
	
	if (!TestaDataDividida(form.nn_datinicioatividades_Dia, form.nn_datinicioatividades_Mes, form.nn_datinicioatividades_Ano, "Inicio das atividades")){
		return false;
	}

	return true;
}

function validaAbaNum3(){
	var form = document.getElementById('cadCliente');
	var nn_sonramomoveleiro						= form.nn_sonramomoveleiro.value;
	var nn_codclientes_ramo						= form.nn_codclientes_ramo.value;
	var nn_texdescricaonegocio					= form.nn_texdescricaonegocio.value;
	var nn_mtuclientes_tipo_venda				= '';
	var nn_sontapecariapropria					= form.nn_sontapecariapropria.value;
	var nn_codclientes_tipo_compra				= form.nn_codclientes_tipo_compra.value;
	var nn_destransportadora					= form.nn_destransportadora.value;
	var nn_desfornecedorjuntos					= form.nn_desfornecedorjuntos.value;
	var nn_desfornecedorseparados				= form.nn_desfornecedorseparados.value;
	var nn_mtucomosoube							= '';
	var nn_mtuclientes_tipo_produto_frisokar	= '';
	var nn_texexpectativa						= form.nn_texexpectativa.value;
	
	if (nn_sonramomoveleiro == ''){
		alert('Preencha o campo É do ramo moveleiro');
		//form.nn_sonramomoveleiro.focus();
		return false;
	}
	
	if (nn_codclientes_ramo == ''){
		alert('Preencha o campo Segmento de Atividade');
		//form.nn_codclientes_ramo.focus();
		return false;
	}
	
	if (nn_texdescricaonegocio == ''){
		alert('Preencha o campo Descrição detalhada do negócio');
		//form.nn_texdescricaonegocio.focus();
		return false;
	}
	
	if (!validaMtu('nn_mtuclientes_tipo_venda')){
		alert('Preencha o campo Tipo de Vendas');
		return false;
	}
	
	if (nn_sontapecariapropria == ''){
		alert('Preencha o campo Possui tapeçaria própia');
		//form.nn_sontapecariapropria.focus();
		return false;
	}
	
	if (nn_codclientes_tipo_compra == ''){
		alert('Preencha o campo Compras');
		//form.nn_codclientes_tipo_compra.focus();
		return false;
	}
	
	if (nn_destransportadora == ''){
		alert('Preencha o campo Indique uma transportadora');
		//form.nn_destransportadora.focus();
		return false;
	}
	
	if (nn_desfornecedorjuntos == ''){
		alert('Preencha o campo Como recebe os componentes da cadeira(Espumas de assentos, encosto revestidas, já com braços e base)');
		//form.nn_desfornecedorjuntos.focus();
		return false;
	}
	
	if (nn_desfornecedorseparados == ''){
		alert('Preencha o campo Como recebe os componentes da cadeira(Assento/encosto de um fornecedor, braços e bases de outro)');
		//form.nn_desfornecedorseparados.focus();
		return false;
	}

	if (!validaMtu('nn_mtucomosoube')){
		alert('Preencha o campo Através de que meio soube da existência da Frisokar/Cerantola');
		return false;
	}
	
	if (!validaMtu('nn_mtuclientes_tipo_produto_frisokar')){
		alert('Preencha o campo Quais os produtos Frisokar/Cerantola lhe interessam');
		return false;
	}
	
	if (nn_texexpectativa == ''){
		alert('Preencha o campo Qual a sua expectativa em relação a um fornecedor');
		//form.nn_texexpectativa.focus();
		return false;
	}
	
	return true;
}

function validaMtu(id){
	var formulario	= document.getElementById('cadCliente');
	var numTotalChk	= formulario.elements[id].length;
	var numTotChekd	= 0;
	for (var w=0; w<numTotalChk; w++ )  {
		if ( eval("formulario."+id+"["+w+"].checked") == true )  {
			numTotChekd++;
		}
	}
	
	if (!numTotChekd)  {
		return false;
	}
	
	return true;
}
/* FIM CAD_CLIENTE*/

/* 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(){
	if (validaAbaNum1Curriculo() == false){
		ativaAbaCuriculo('tab_step1', false);
		return false;
	}
	if (validaAbaNum2Curriculo() == false){
		ativaAbaCuriculo('tab_step2', false);
		return false;
	}
	if (validaAbaNum3Curriculo() == false){
		ativaAbaCuriculo('tab_step3', false);
		return false;
	}
	if (validaAbaNum4Curriculo() == false){
		ativaAbaCuriculo('tab_step4', false);
		return false;
	}
	
	return true;
}

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_codcurriculo_estadocivil	= form.nn_codcurriculo_estadocivil.value;
	var nn_desnome_mae				= form.nn_desnome_mae.value;
	var nn_desnome_pai				= form.nn_desnome_pai.value;
	var nn_sonfilho					= form.nn_sonfilho.value;
	var nn_intqtdefilho				= form.nn_intqtdefilho.value;
	var nn_desnaturalidade			= form.nn_desnaturalidade.value;
	var nn_desrg					= form.nn_desrg.value;
	var nn_datrgexpedicao_Dia		= form.nn_datrgexpedicao_Dia.value;
	var nn_datrgexpedicao_Mes		= form.nn_datrgexpedicao_Mes.value;
	var nn_datrgexpedicao_Ano		= form.nn_datrgexpedicao_Ano.value;
	var nn_cpfcpf					= form.nn_cpfcpf.value;
	var nn_codcurriculo_habilitacao	= form.nn_codcurriculo_habilitacao.value;
	var nn_desendereco				= form.nn_desendereco.value;
	var nn_cepcep					= form.nn_cepcep.value;
	var nn_codpais					= form.nn_codpais.value;
	var nu_codestado				= form.nu_codestado.value;
	var nu_codcidade				= form.nu_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 (TestaDataDividida(form.nn_datnascimento_Dia, form.nn_datnascimento_Mes, form.nn_datnascimento_Ano, "Data de Nascimento") == false){
		return false;	
	}
	
	if (nn_codcurriculo_estadocivil == ''){
		alert('Preencha o Estado Civil!');
		return false;
	}
	
	if (nn_desnome_mae == ''){
		alert('Preencha o Nome da Mãe!');
		return false;
	}
	
	if (nn_desnome_pai == ''){
		alert('Preencha o Nome do Pai!');
		return false;
	}
	
	if (nn_sonfilho == ''){
		alert('Preencha se Possui Filhos!');
		return false;
	}else{
		if (nn_sonfilho == 'SIM' && nn_intqtdefilho == ''){
			alert('Preencha a quantidade de filhos!');
			return false;
		}
	}
	
	if (nn_desnaturalidade == ''){
		alert('Preencha Naturalidade/Estado!');
		return false;
	}
	
	if (nn_desrg == ''){
		alert('Preencha RG!');
		return false;
	}

	if (TestaDataDividida(form.nn_datrgexpedicao_Dia, form.nn_datrgexpedicao_Mes, form.nn_datrgexpedicao_Ano, "Data Expedição") == false){
		return false;	
	}
	
	if(nn_cpfcpf == ""){
		alert('Preencha seu CPF!');
		return false;	
	}else{
		if (ValidaCPF(nn_cpfcpf) == false){
			alert('CPF inválido!');
			return false;	
		}
	}
	
	if (nn_codcurriculo_habilitacao == ''){
		alert('Preencha Carteira de Habilitação!');
		return false;
	}
	
	if (nn_desendereco == ''){
		alert('Preencha Endereço!');
		return false;
	}
	
	if (ChecaCep(form.nn_cepcep, 2) == false){
		return false;
	}
	
	if (nn_codpais == ''){
		alert('Preencha País!');
		return false;
	}else{
		if (nn_codpais == 1){
			if (nu_codestado == ''){
				alert('Preencha Estado!');
				return false;
			}			
			
			if (nu_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 (ChecaEmail(nn_emlemail, 'Email') == false){
		return false;
	}
	
	if (nn_dessenha == ''){
		alert('Preencha sua senha!');
		return false;
	}else{
		if (nn_dessenha != nn_dessenha_conf){
			alert('Preenchasua 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(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(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 = "<strong>Empresa: " + empresa + "<a href='javascript: void(0);' onClick='GTR_CurriculoDel(this.parentNode.parentNode.rowIndex);'><img src='img/btn/btn_fechar.gif' alt='Excluir' border='0' /></a></strong>";
	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_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 = "<strong>Entidade: " + entidade + "<a href='javascript: void(0);' onClick='GTR_CurriculoDelEscola(this.parentNode.parentNode.rowIndex);'><img src='img/btn/btn_fechar.gif' alt='Excluir' border='0' /></a></strong>";
	HTML += "<ul>";
	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)
}
/* FIM CAD_CURRICULO */



function deleteArquivo(i)
{
	document.getElementById('tblArquivo').deleteRow(i)
}

function clienteAddArquivo(nomarquivo, nomarquivoenviado, codarquivo){
	var tabela = "tblArquivo";
	var linha = document.getElementById(tabela).insertRow(document.getElementById(tabela).rows.length);
	linha.className = "tr_listagem";
	
	// limpa caracteres
	nomarquivo.replace("'", "");
	
	var cmpNomArquivo	= "<input type='hidden' name='nu_produto_nome_up[]' value='"+nomarquivo+"'>";
	var cmpArquivo		= "<input type='hidden' name='nu_codarquivo_up[]' value='"+codarquivo+"'>";
	
	linha.insertCell(0).innerHTML = "<strong>" + nomarquivo + cmpNomArquivo + cmpArquivo + "<a href='javascript: void(0);' onClick='deleteArquivo(this.parentNode.parentNode.rowIndex);'><img src='img/btn/btn_fechar.gif' alt='Excluir' border='0' /></a></strong>";
	//linha.insertCell(1).innerHTML = cmpArquivo;
}

/*

function openBoxCarac(){
	document.getElementById('caixa_filtro').style.display = 'block';
	document.getElementById('caixa_filtro_alpha').style.display = 'block';
}
*/

function closeBoxCarac(){
	document.getElementById('caixa_filtro').style.display = 'none';
	document.getElementById('caixa_filtro_alpha').style.display = 'none';
}


function openBoxCarac(objId, pagina){
	// if the function argument is given to overlay,
	// it is assumed to be the onBeforeLoad event listener
	$j("#"+objId).overlay({
		mask: {color: '#666'},
		closeOnClick: false,
		/*effect: 'apple',*/
		onBeforeLoad: function() {
			// grab wrapper element inside content
			var wrap = this.getOverlay().find(".contentWrap");
			// load the page specified in the trigger
			wrap.html('Carregando...');
			wrap.load(pagina);
		},
		load: true
	});
}


function LimparFiltro(codcategoria){
	if ($('frmCarac') && $('frmCarac')['codcat_'+codcategoria] && $('frmCarac')['codcar_'+codcategoria]){
		$('frmCarac')['codcat_'+codcategoria].value = '';
		$('frmCarac')['codcar_'+codcategoria].value = '';
		$('frmCarac')['codoff_'+codcategoria].value = 'S';
		$('frmCarac').submit();
		$('conteudo').innerHTML = htmlAjaxLoader;
	}
}

function SelecaoFiltro(codcategoria, codcaracteristica){
	var ipt  = document.createElement('input');
	ipt.type = 'hidden';
	ipt.name = 'codcat_'+codcategoria;
	ipt.id = 'codcat_'+codcategoria;
	ipt.value = codcategoria;
	$j('codcat_'+codcategoria).remove();
	$j('#frmCarac').append(ipt);

	var ipt  = document.createElement('input');
	ipt.type = 'hidden';
	ipt.name = 'codcar_'+codcategoria;
	ipt.id = 'codcar_'+codcategoria;
	ipt.value = codcaracteristica;
	$j('codcar_'+codcategoria).remove();
	$j('#frmCarac').append(ipt);

	var ipt  = document.createElement('input');
	ipt.type = 'hidden';
	ipt.name = 'codoff_'+codcategoria;
	ipt.id = 'codoff_'+codcategoria;
	ipt.value = "";
	$j('codoff_'+codcategoria).remove();
	$j('#frmCarac').append(ipt);
	
	$('frmCarac').submit();
	$j("table[rel='#overlay_jqtool']").each(function() {
		if (typeof $j(this).overlay == 'function' && typeof $j(this).overlay().close == 'function')
			$j(this).overlay().close();
	});	
	
	$('conteudo').innerHTML = htmlAjaxLoader;
}

function mudaFilho(val) {
	if (val == "SIM") {
		$j('#nn_intqtdefilho').attr('disabled', '');
		$j("#nn_intqtdefilho").focus();
	} else {
		$j('#nn_intqtdefilho').attr('disabled', 'disabled');
		$j("#nn_intqtdefilho").val('');
	}
}

function mudaLinkVideo(idioma, video) {
	
	$j('#list_idioma li').each(function() {
		if ($j(this).hasClass("ativo"))
			$j(this).removeClass("ativo");
	});
	
	$j('#img_' + idioma).addClass("ativo");
	$j('#video_princ').attr('href','javascript: VideoYoutube("' + video + '");');
}
