function ttipo_pessoa(troca,cpf,cnpj) {
	if (troca==1) {
		if (document.getElementById('fisica').checked==true) {
			document.getElementById('dados_pessoais').style.display='';
			document.getElementById('dados_empresa').style.display='none';
			var texto=cpf;
		}
		if (document.getElementById('juridica').checked==true) {
			document.getElementById('dados_pessoais').style.display='none';
			document.getElementById('dados_empresa').style.display='';
			var texto=cnpj;
		}
	} else
		var texto=cpf;
	document.getElementById('cadsite_form').onsubmit=new Function(texto);
}

function cadsite_verifica_login(url,id) {
	var loading = new Element('img',{src:PATH_IMG+'loader_p.gif'});
	new Request({
		'url':url,
		'method':'get',
		'data':'login='+$(id).get('value'),
		onRequest: function() {
			loading.inject(document.body).position({'relativeTo':$(id),'position':'center'});			
		},
		onSuccess: function(responseText, responseXML) {
			loading.dispose();
			if (responseText=='true')
				$(id).setStyle('background-color','#BDE9A7');
			else
				$(id).setStyle('background-color','#FFA791');
		},
		onFailure: function(xhr) {
			loading.dispose();
			$(id).setStyle('background-color','#FFA791');
		}
	}).send();
}

function cadsite_valida_login(e) {
	var value = $(this).get('value');
	if (value.test('[^A-Za-z_@.]','g')) {
		var caret = $(this).getCaretPosition();
		$(this).set('value',value.replace(/[^A-Za-z_@.0-9]/g,'').toLowerCase()).setCaretPosition(caret+(e.key!='shift'?-1:0));
	}
}

function cadsite_voltar(passo) {
	$('cadastrando').value='0';
	$('passo_cadastro').value=passo;
	$('cadsite_form').submit();
}

