function agregarFila(obj){
obj.value = parseInt(obj.value) + 1;
var oId = obj.value;
var codigo = document.getElementById("cod");
var descripcion = document.getElementById("descripcion");
var cantidad = document.getElementById("cantidad");
var precioventa = document.getElementById("precioventa");
var neto = document.getElementById("total6");
var id = document.getElementById("id");
var stock = document.getElementById("stock");
var ivaart = document.getElementById("ivaart");
var ivatotal = document.getElementById("ivatotal");
var importe = document.getElementById("importe");
var strHtml1 = codigo.value + '<input type="hidden" id="hdncodigo_' + oId + '" name="hdncodigo_' + oId + '" value="' + codigo.value + '"/>' ;
var strHtml2 = descripcion.value + '<input type="hidden" id="hdndescripcion_' + oId + '" name="hdndescripcion_' + oId + '" value="' + descripcion.value + '"/>' ;
var strHtml3 = cantidad.value + '<input type="hidden" id="hdncantidad_' + oId + '" name="hdncantidad_' + oId + '" value="' + cantidad.value + '"/>' ;
var strHtml4 = precioventa.value + '<input type="hidden" id="hdnprecioventa_' + oId + '" name="hdnprecioventa_' + oId + '" value="' + precioventa.value + '"/>' ;
var strHtml5 = importe.value + '<input type="hidden" id="hdnimporte_' + oId + '" name="hdnimporte_' + oId + '" value="' + importe.value + '"/>' ;
var strHtml6 = '<img src="images/delete.png" width="16" height="16" alt="Eliminar" onclick="if(confirm(\'Realmente desea eliminar este articulo?\')){eliminarFila(' + oId + ');}"/>';
var strHtml7 = id.value + '<input type="hidden" id="hdnid_' + oId + '" name="hdnid_' + oId + '" value="' + id.value + '"/>' ;
var strHtml8 = stock.value + '<input type="hidden" id="hdnstock_' + oId + '" name="hdnstock_' + oId + '" value="' + stock.value + '"/>' ;
var strHtml9 = ivaart.value + '<input type="hidden" id="hdniva_' + oId + '" name="hdniva_' + oId + '" value="' + ivaart.value + '"/>' ;
var strHtml10 = ivatotal.value + '<input type="hidden" id="hdnivatotal_' + oId + '" name="hdnivatotal_' + oId + '" value="' + ivatotal.value + '"/>' ;
strHtml9 += '<input type="hidden" id="hdnIdCampos_' + oId +'" name="hdnIdCampos[]" value="' + oId + '" />';
var objTr = document.createElement("tr");
objTr.id = "rowDetalle_" + oId;
var objTd1 = document.createElement("td");
objTd1.id = "tdDetalle_1_" + oId;
objTd1.innerHTML = strHtml1;
var objTd2 = document.createElement("td");
objTd2.id = "tdDetalle_2_" + oId;
objTd2.innerHTML = strHtml2;
var objTd3 = document.createElement("td");
objTd3.id = "tdDetall_3_" + oId;
objTd3.innerHTML = strHtml3;
var objTd4 = document.createElement("td");
objTd4.id = "tdDetalle_4_" + oId;
objTd4.innerHTML = strHtml4;
var objTd5 = document.createElement("td");
objTd5.id = "tdDetalle_5_" + oId;
objTd5.innerHTML = strHtml5;
var objTd6 = document.createElement("td");
objTd6.id = "tdDetalle_6_" + oId;
objTd6.innerHTML = strHtml6;
var objTd7 = document.createElement("hidden");
objTd7.id = "tdDetalle_7_" + oId;
objTd7.innerHTML = strHtml7;
var objTd8 = document.createElement("hidden");
objTd8.id = "tdDetalle_8_" + oId;
objTd8.innerHTML = strHtml8;
var objTd9 = document.createElement("hidden");
objTd9.id = "tdDetalle_9_" + oId;
objTd9.innerHTML = strHtml9;
var objTd10 = document.createElement("hidden");
objTd10.id = "tdDetalle_10_" + oId;
objTd10.innerHTML = strHtml10;
objTr.appendChild(objTd1);
objTr.appendChild(objTd2);
objTr.appendChild(objTd3);
objTr.appendChild(objTd4);
objTr.appendChild(objTd5);
objTr.appendChild(objTd6);
objTr.appendChild(objTd7);
objTr.appendChild(objTd8);
objTr.appendChild(objTd9);
objTr.appendChild(objTd10);
var objTbody = document.getElementById("tbDetalle");
objTbody.appendChild(objTr);
document.getElementById("baseimponible").value=parseFloat(Math.round(document.getElementById("baseimponible").value*100)/100) + parseFloat(document.getElementById("importe").value);
return false; //evita que haya un submit por equivocacion.
}