// Versão: 1.3.1 - 21/07/2008
function fn_edit_item(id) {
if (document.getElementById("count_" + id))
var count = document.getElementById("count_" + id).value;
else
var count = eval("document.formulario.count_" + id + ".value")
var newFields = document.getElementById("readroot_" + id).cloneNode(true);
newFields.id = id + count; // unset original span name
newFields.style.display = ""; // unset original display:none style
fn_changeid(newFields, count)
var insertHere = document.getElementById("tableaux_" + id);
insertHere.parentNode.insertBefore(newFields,insertHere);
count++;
if (document.getElementById("count_" + id))
document.getElementById("count_" + id).value = count;
else
eval("document.formulario.count_" + id + ".value = count");
if (document.getElementById("titulo_" + id + "0")) document.getElementById("titulo_" + id + "0").style.display = '';
}
trava_delete_aux = new Array()
function fn_delete_item(table_id,ix,field_row_id) {
if (!field_row_id) field_row_id = "id_" + table_id;
if (document.getElementById(field_row_id + ix))
var row_id = document.getElementById(field_row_id + ix).value;
else
var row_id = 0;
if (row_id == 0) {
fn_remove_item(table_id,ix);
} else {
if (trava_delete_aux[table_id] &&
trava_delete_aux[table_id][row_id] &&
trava_delete_aux[table_id][row_id] == 1) {
alert("O registro de " + table_id + " não pode ser excluído")
//} else if (confirm("Deseja realmente excluir " + table_id + "?")) {
} else if (confirm("Deseja realmente excluir este registro?")) {
var del_list = eval("document.formulario.delete_list_" + table_id + ".value") + "," + row_id;
eval("document.formulario.delete_list_" + table_id + ".value = del_list");
fn_remove_item(table_id,ix);
}
}
}
function fn_remove_item(id,ix) {
if (document.getElementById("count_" + id))
var count = document.getElementById("count_" + id).value;
else
var count = eval("document.formulario.count_" + id + ".value")
var remove = document.getElementById(id + ix);
remove.parentNode.removeChild(remove);
var fieldlist = fn_getid(document.getElementById("readroot_" + id));
fieldlist[fieldlist.length] = id;
var ini = Math.round(ix)+1;
for (var i=ini; i<count; i++) {
for (var j=0; j<fieldlist.length; j++) {
var new_id = fieldlist[j] + (i-1);
obj = document.getElementById(fieldlist[j]+i);
if (obj) {
obj.removeAttribute("name"); // otherwise IE7 confuses ID and NAME
obj.id = new_id;
obj.name = new_id;
//if (fieldlist[j] == "0documento_titulo") obj.value = document.getElementById(new_id).id;
}
}
}
count--;
if (document.getElementById("count_" + id))
document.getElementById("count_" + id).value = count;
else
eval("document.formulario.count_" + id + ".value = count");
if (count > 0 && document.getElementById("titulo_" + id + "0"))
document.getElementById("titulo_" + id + "0").style.display = '';
}
function fn_getid(obj) {
var Nodes = obj.childNodes;
var list = new Array();
for (var i=0; i<Nodes.length; i++) {
if (Nodes[i].id)
list[list.length] = Nodes[i].id;
if (Nodes[i].hasChildNodes()) {
var temp = fn_getid(Nodes[i]);
for (var j=0; j<temp.length; j++) {
list[list.length] = temp[j];
}
}
}
return list
}
function fn_changeid(obj,ix) {
var Nodes = obj.childNodes;
for (var i=0; i<Nodes.length; i++) {
if (Nodes[i].id) {
Nodes[i].id += ix;
if (Nodes[i].name &&
Nodes[i].type &&
Nodes[i].type == "select-multiple")
Nodes[i].name = Nodes[i].name.replace("[]","") + ix + "[]";
else if (Nodes[i].name)
Nodes[i].name += ix;
//alert(Nodes[i].name)
}
if (Nodes[i].hasChildNodes()) {
fn_changeid(Nodes[i],ix);
}
}
}
|