function textareaSize(obj) {
    var maxlength = obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
    if (obj.getAttribute && obj.value.length > maxlength)
        obj.value = obj.value.substring(0,maxlength)
}

function updateFileDescription(obj, fileId, idCampo) {
    xajax_updateFileDescription(obj.value, fileId, idCampo);
}

function verificaNovoTipo(itemId, tipo, tipoPai) {
    if (itemId == 0) {
	var msg = 'Não é possível criar ';
	if (tipo == 'entidade') {
	    msg += 'uma nova entidade antes de inserir alguma informação sobre ';
	} else {
	    msg += 'um novo ' + tipo + ' antes de inserir alguma informação sobre ';
	}
	if (tipoPai == 'entidade') {
	    msg += 'a entidade';
	} else {
	    msg += 'o ' + tipoPai;
	}
	alert(msg);
	return false;
    } else if (tipo == 'relato') {
	window.location='mapsys-edit_relato.php?' + tipoPai + 'Id=' + itemId;
    } else if (tipo != 'projeto') {
	window.location='mapsys-view.php?tipo=' + tipo + '&new=1&fields[' + tipoPai + 'Id]=' + itemId;
    }
    return true;
}

function flipNovoProjeto(pontoId) {
    flip('adicionaProjeto');
    flip('novoProjeto');
    if (document.criaProjeto.projetoPontoId.value == '') {
	document.criaProjeto.projetoPontoId.value = pontoId
    }
}