function check(valor) 
{
	if (valor=="consumidor")
	{
		document.getElementById('form_cliente').style.visibility = 'hidden';
		document.getElementById('form_rh').style.visibility = 'hidden';
		document.getElementById('mot_ocorr').style.visibility = 'visible';
		document.getElementById('form_cons').style.visibility = 'visible';
		document.getElementById('obrigatorio').style.top = '530';
	}			
	
	if (valor=="cliente")
	{
		document.getElementById('form_cons').style.visibility = 'hidden';
		document.getElementById('form_rh').style.visibility = 'hidden';
		document.getElementById('mot_ocorr').style.visibility = 'visible';
		document.getElementById('form_cliente').style.visibility = 'visible';
		document.getElementById('obrigatorio').style.top = '620';
	}

	if (valor=="rh")
	{
		document.getElementById('form_cons').style.visibility = 'hidden';
		document.getElementById('form_cliente').style.visibility = 'hidden';
		document.getElementById('form_rh').style.visibility = 'visible';
		document.getElementById('obrigatorio').style.top = '1030';
		document.getElementById('mot_ocorr').style.visibility = 'hidden';
	}
}

function no_changes(e)
{
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;

	return false;
}

function limpar()
{
	window.location='contato.php?marca=' + document.frm1.marca.value;
}

function no_update(tipo)
{
	if (tipo = 'emp')
	{
		document.frm1.cnpj.readOnly			= true;
		document.frm1.raz_soc.readOnly		= true;
		document.frm1.email_emp.readOnly	= true;
		document.frm1.endereco_emp.readOnly	= true;
		document.frm1.bairro_emp.readOnly	= true;
		document.frm1.cep_emp.readOnly		= true;
		document.frm1.ddd_emp.readOnly		= true;
		document.frm1.telefone_emp.readOnly	= true;
		document.frm1.estado_emp.disabled	= true;
		document.frm1.cidade_emp.disabled	= true;
	}

	if (tipo = 'cli')
	{
		document.frm1.cpf.readOnly			= true;
		document.frm1.nome.readOnly			= true;
		document.frm1.nascimento.readOnly	= true;
		document.frm1.email_vis.readOnly	= true;
		document.frm1.endereco_vis.readOnly	= true;
		document.frm1.bairro_vis.readOnly	= true;
		document.frm1.cep_vis.readOnly		= true;
		document.frm1.ddd_vis.readOnly		= true;
		document.frm1.telefone_vis.readOnly	= true;
		document.frm1.celular.readOnly		= true;
		document.frm1.estado_vis.disabled	= true;
		document.frm1.cidade_vis.disabled	= true;
	}
}

function isValidDate(tObject, dt_fmt)
{
	var dt_format = 'DD\/MM\/YYYY';
	
	if( dt_fmt != undefined ) 
	{ 
		dt_format = dt_fmt;  
	}

	if( dt_format.indexOf('-') >=0 )
	        div = '-';
	else
	        div = '/';
	
	tObject.value = clean(tObject.value);
	dt_fmt        = clean(dt_format);
	
	if(isValidNumber(tObject.value)) 
	{
		if((tObject.value.length == 0)||(tObject.value == '')){ return false; }
		var old_data = tObject.value;
		var erro  = false;
		var erro1 = false;
		var meses = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
		if(tObject.value.length == 8)
		{
			  var dia;
			  var mes;
			  var ano;
			  var nova_data;
			  
			  var pD = dt_fmt.indexOf('D');
			  var pM = dt_fmt.indexOf('M');
			  var pY = dt_fmt.indexOf('Y');
			  
			  dia = tObject.value.substring(pD,pD+2);
			  mes = tObject.value.substring(pM,pM+2);
			  ano = tObject.value.substring(pY,pY+4);
			  
			  if(mes > 12  ){ erro1 = true; }
			  if(ano < 1800){ erro1 = true; }
	
			  if(mes==02)
				 if((ano%4)==0) meses[1] = 29;
	
			  if(dia > meses[mes-1] ) { erro1 = true; }
			  
			  nova_data = '';
			  if( ( pD < pM ) && ( pD < pY ) )
			  {
			  	nova_data += dia + div;
			  	
			  	if( pM < pY )
			  		nova_data += mes + div + ano;
			  	else
			  		nova_data += ano + div + mes;
			  }
			  else
			  {
			  	if( pM < pY )
			  		nova_data = mes + div + dia + div + ano;
			  	else
			  		nova_data = ano + div + mes + div + dia;
			  }
			  //nova_data     = dia + div + mes + div + ano;
			  tObject.value = nova_data;
		 } 
		 else { erro = true; }
	} 
	else 
	{
		erro = true;
	}
	 if(erro || erro1){
	   if(erro1)
		   window.alert('Data inválida!');
	   else 
		   window.alert('Campo é do tipo data!');
	   tObject.focus();
	   tObject.value = '';
	 } else {
	   tObject.value = nova_data;
	 }   
}