function openCampos(){
	if(document.getElementById('campos').style.display == 'none')
		document.getElementById('campos').style.display='block';
	else
		document.getElementById('campos').style.display='none';
}

function validateFields(emailToCommentValidate, nomeCommentValidate){
	if(document.getElementById('text').value == ""){
		alert("O campo comentário deve estar preenchido");
		return false;
	}
	if(emailToCommentValidate == true){
		if(document.getElementById('email').value == ""){
			alert("O campo e-mail deve estar preenchido");
			return false;
		}

		<!-- Validar email -->
	}
	if(nomeCommentValidate != true){
		if(document.getElementById('username').value == ""){
			alert("O campo Nome deve estar preenchido");
			return false;
		}
	}
	return true;
}

function validateArtigoComment() {
	var username = document.getElementById('username');
	if (username != null && username.value == '') {
		alert(msgInvalidUserName);
		return false;
	}

	if (emailToCommentValidate) {
		var email = document.getElementById("email");
		if (email != null && email.value == '') {
			alert(msgInvalidEmail);
			return false;
		}
	}

	var text = document.getElementById('text');
	if (text != null) {
		if (text.value == '') {
			alert(msgInvalidComment);
			return false;
		}

		if (text.value.length > 1000) {
			alert("O valor máximo do comentário é 1000 caracteres.");
			return false;
		}
	}
	return true;
}

function limitaTamanho(campo, limite){
    valor = campo.value;
    limite = parseInt(limite);

    if (valor.length > limite) {
    	campo.value = valor.substring(0, limite);
    	document.getElementById(campo.id + "_label").innerHTML = (campo.value.length + "/" + limite);
    	return false;
    }
    document.getElementById(campo.id + "_label").innerHTML = (valor.length + "/" + limite);
    return true;
}
