// PINTA BOTAO
function pintaBotao(obj,v) {
		if(v==1) obj.style.backgroundColor="#E1EBE0"; // pinta
		if(v==0) obj.style.backgroundColor="#FFFFFF"; // despinta
}

// ENVIA EMAIL DE CONTATO
function validaContato() {
	nome	=document.frmContato.nome.value;
	email	=document.frmContato.email.value;
	telefone=document.frmContato.telefone.value;
	texto	=document.frmContato.texto.value;
	tipocontato	=document.frmContato.tipocontato.value;
	
	formOk=true;
	if(nome=="") formOk=false;
	if(email=="") formOk=false;
	if(telefone=="") formOk=false;
	if(texto=="") formOk=false;
	if(tipocontato=="") formOk=false;
	
	if(!formOk) alert("Você deve preencher todos os campos!");
	else document.frmContato.submit();
	
	return;
}

// FAZ CADASTRAMENTO DE UM LOGIN
function validaFormCadastro() {
	// iguala o username com o email
	document.frmCadastrar.username.value=document.frmCadastrar.email.value;
	
	nome		=document.frmCadastrar.nome.value;
	email		=document.frmCadastrar.email.value;
	telefone	=document.frmCadastrar.telefone.value;
	username	=document.frmCadastrar.username.value;
	telefone	=document.frmCadastrar.telefone.value;
	password1	=document.frmCadastrar.password1.value;
	password2	=document.frmCadastrar.password2.value;
	empresa		=document.frmCadastrar.empresa.value;
	
	formOk=true;
	if(nome=="") formOk=false;
	if(email=="") formOk=false;
	if(telefone=="") formOk=false;
	if(username=="") formOk=false;
	if(telefone=="") formOk=false;
	if(password1=="") formOk=false;
	if(password2=="") formOk=false;
	if(empresa=="") formOk=false;
	
	if(!formOk) { alert("Você deve preencher todos os campos!"); }
	else {
		if(password1!=password2) { alert("As senhas devem ser iguais!"); }
		else xajax_realizaCadastroLogin(document.frmCadastrar.email.value,document.frmCadastrar.username.value,document.frmCadastrar.password1.value,document.frmCadastrar.nome.value,document.frmCadastrar.telefone.value,document.frmCadastrar.empresa.value);
	};
	
	return;
}

// ARRUMA ALTURA DE DUAS COLUNAS
function fixH(one,two) {
	if (document.getElementById(one)) {
		var lh=document.getElementById(one).offsetHeight;
		var rh=document.getElementById(two).offsetHeight;
		var nh = Math.max(lh, rh); 
		document.getElementById(one).style.height=nh+"px";
		document.getElementById(two).style.height=nh+"px";
	}
}

// ARRUMA ALTURA DE TRES COLUNAS
function sortNum(a,b) { return b-a } 
function fixH2(one,two,three) {
	if (document.getElementById(one)) {
		var obj=new Array(3);
		var option=[one,two,three];
		for(var i=0; i<option.length; i++) {
			document.getElementById(option[i]).style.height="auto";
			obj[i]=document.getElementById(option[i]).offsetHeight;
			nh=obj.sort(sortNum);
		} 
		nh1=nh.splice(1,2);
		for(var i=0; i<option.length; i++) {
			if (i==2) { // se for a terceira coluna, corrige-a
				new_nh = eval(nh)-8; // -8
				document.getElementById(option[i]).style.height=new_nh+"px";
			}
			else { // se forem as outras colunas que não a terceira
				document.getElementById(option[i]).style.height=nh+"px";
			}
		}
	}
}