var maximo_caracteres = 150;	
		
function contarLetras(txt){
	var caracteres_digitados = txt.length;		
	
	if( caracteres_digitados >= 150 ){
		document.getElementById('contador').value = "0";
		document.getElementById('descricao').value = txt.substr(0,( maximo_caracteres - 1 ));			
	}else{
		document.getElementById('contador').value = "" + ( maximo_caracteres - caracteres_digitados );
	}	
}

function validacao(){
	d = document.form_troca_link;
	
	if(d.empresa.value == ""){
		alert("Please,\ntype the name of your company.");
		d.empresa.focus();
		return false;
	}
	
	if(d.email.value == ""){
		alert("Please,\ntype your e-mail.");
		d.email.focus();
		return false;
	}
	
	if(d.email.value.indexOf("@")<0){
		alert("Please,\ntype a valid e-mail.");
		d.email.focus();
		return false;
	}
	
	if(d.categoria.value == "0"){
		alert("Please,\nchoose a category.");
		d.categoria.focus();
		return false;
	}
	
	if(d.titulo.value == ""){
		alert("Please,\ntype a title for your link.");
		d.titulo.focus();
		return false;		
	}
	
	if((d.link_cliente.value == "")||(d.link_cliente.value == "http://")){
		alert("Please,\ntype the link that you want on our site.");
		d.link_cliente.focus();
		return false;
	}
	
	if((d.site.value == "")||(d.site.value == "http://")){
		alert("Please,\nindicate in which page our link will be.");
		d.site.focus();
		return false;
	}		
	
	return true;
}
