// JavaScript Document
$D = function(id) 
{
	return document.getElementById(id);
}

$DN = function(id) 
{
	return document.getElementsByName(id);
}
//ALTERA A COR DO CAMPO
function alteraCampoCor(id,status)
{
	//alert('ok');
	if(status=='on')
	{
		$D(id).style.backgroundColor="#EDECFF";
	}
	else
	{
		$D(id).style.backgroundColor="";
	}
}
function tiraDiv(div,div2)
{
	if(div2 != '')
	{
		$D(div2).style.display = 'none';	
	}
	$D(div).style.display = 'none';	
}

//APARECE A DIV NA PAGINA INICIAL
function apareceDiv(idOn,idOn2,idOff,idOff2)
{
	$D(idOn).style.display = '';
	$D(idOn2).style.display = '';
	$D(idOff).style.display = 'none';
	$D(idOff2).style.display = 'none';
	$DN('publico')[0].checked  = false;
	$DN('publico')[1].checked  = false;
}
//COLOCA O VALOR NO HIDDEN
function valorHidden(id)
{
	$D(id).value = '1';
}

//APARECE CAMPO CPF OU PASSAPORT
function mostraCampo(id)
{
	if($D(id).value == '')
	{
		$D('trPassaport').style.display = 'none';
		$D('trCpf').style.display = 'none';
	}
	else if($D(id).value == 'Brasil')
	{
		$D('trCpf').style.display = '';
		$D('passaporte').value = '';
		$D('trPassaport').style.display = 'none';
	}
	else if($D(id).value != 'Brasil')
	{
		$D('cpf').value = '';
		$D('trCpf').style.display = 'none';
		$D('trPassaport').style.display = '';
	}
}
//PULA CPF
function cpfPula(id,nextId)
{
	var cpf = $D(id).value;
	if(cpf.length == 3)
	{
		$D(id).value = cpf+".";
	}
	if(cpf.length == 7 )
	{
		$D(id).value = cpf+".";	
	}
	if(cpf.length == 11 )	
	{
		$D(id).value = cpf+"-";
	}
	if(cpf.length == 14 )	
	{
		$D(nextId).focus();
	}
}
//PULA CNPJ
function cnpjPula(id,nextId) 
{
	var cnpj = $D(id).value;
	if(cnpj.length == 2)
	{
		$D(id).value = cnpj+".";
	}
	if(cnpj.length == 6 )
	{
		$D(id).value = cnpj+".";
	}
	if(cnpj.length == 10 )
	{
		$D(id).value = cnpj+"/";
	}
	if(cnpj.length == 15 )
	{
		$D(id).value = cnpj+"-";
	}
	if(cnpj.length == 18 )	
	{
		$D(nextId).focus();
	}
}
function cnpjPula2(id,nextId) 
{
	var cnpj = $D(id).value;
	if(cnpj.length == 4)
	{
		$D(id).value = cnpj+"-";
	}
	if(cnpj.length == 7 )	
	{
		$D(nextId).focus();
	}
}
//PULA DATA
function mudaData(id,nextId)
{	
	var data = $D(id).value;	
	if(data.length == 2)	
	{		
		$D(id).value = data+'/';	
	}	
	else if(data.length == 5)	
	{			
		$D(id).value = data+'/';
	}
	else if(data.length == 10)	
	{	
		$D(nextId).focus();	
	}
}
//MUDA DDD
function mudaDDD(id,nextId)
{	
	var ddd = $D(id).value;	
	if(ddd.length == 2)	
	{		
		$D(nextId).focus();	
	}
}
//MUDA TEL
function mudaTel(id,nextId)
{	
	var tel = $D(id).value;	
	if(tel.length == 4)	
	{		
		$D(nextId).focus();;	
	}	
}



//MUDA CEP
function mudaCep(id,nextId)
{	
	var cep = $D(id).value;	
	if(cep.length == 5)	
	{		
		$D(id).value = cep+'-';	
	}	
	else if(cep.length == 9)	
	{			
		$D(nextId).focus();	
	}
}
//APARECE CAMPO HIDDEN
function apareceCampo(id,idHid,valor,trHidden)
{
	if($D(id).value == valor)
	{
		$D(idHid).style.display = '';
		$D(trHidden).style.display = '';
	}
	else
	{
		$D(idHid).style.display = 'none';		
		$D(trHidden).style.display = 'none';
	}
}

//APAGA VALOR DO CAMPO
function apagaCampo(id)
{
	$D(id).value = '';
}
//COLOCA VALOR CAMPO
function escreveValor(id,idV,valor)
{
	if($DN(id)[0].checked==true)
	{
		$D(idV).value = valor;
		$D(idV).readOnly = true;
	}else
	{
		$D(idV).value = '';
		$D(idV).readOnly = false;
	}
}

//MOUSE OVER
//function mouseOver(id,idSpan,idDivImg,hidMenu)
function mouseOver(id,bgColor)
{
	$D(id).style.backgroundColor = bgColor;
	/*if($D(idSpan))
	{
		$D(idSpan).className='btnRollOver';
	}
	if($D(idDivImg))
	{
		$D(idDivImg).style.display="block";
	}
	$D(hidMenu).value = id;*/
}
//MOUSE OVER DE IMAGEM
function mouseOverImf(id,img)
{
	$D(id).style.backgroundImage = "url(imagens/"+img+".gif)";
	$D(id).className='fonteBca';
}
//MOUSE OUT
//function mouseOut(idSpan,idDivImg,hidMenu)
function mouseOut(id,bgColor)
{
	$D(id).style.backgroundColor = bgColor;
	/*var id = $D(hidMenu).value;
	$D(id).style.backgroundColor = '#FFFFFF';
	if($D(idSpan))
	{
		$D(idSpan).className='btnRollOver';
	}
	if($D(idDivImg))
	{
		$D(idDivImg).style.display="none";
	}*/
}
//MOUSE OUT IMG
function mouseOutImg(id,img)
{
	$D(id).style.backgroundImage = "url(imagens/"+img+".gif)";
	$D(id).className='fonteCinza';
}

function valorHidden(idHid)
{
	$D('idHiddenMenu').value = idHid;
}


function mudaDiv(mudaDiv)
{
	
	var idAberto = $D('idHiddenMenu').value;
	
	if($D(mudaDiv).style.display == '') 
	{
		$D(mudaDiv).style.display = 'none';
		$D('idHiddenMenu').value = '';
	}
	else
	{		
		$D(mudaDiv).style.display = '';
		if($D('idHiddenMenu').value)
		{
			$D(idAberto).style.display = 'none';
			//alert('apaga id'+idAberto);
		}
		$D('idHiddenMenu').value = mudaDiv;
	}
}

//SOMENTE NUMEROS
function info()
{
	
}