if(document.dtp33form.elements[0].value!="") sumadc()
function chng(x) {
if(x==1) valact()
}
//function exswap()
//{
	//return
//}
function item2(rrow)
{
row=nhd+nrd*ncd+rrow*(ncd+1)
document.dtp33form.elements[row+1].value= document.dtp33form.elements[row+2].value
document.dtp33form.elements[row+3].value=und[document.dtp33form.elements[row+2].value]
}
function item1(rrow)
{
row=nhd+nrd*ncd+rrow*(ncd+1)
document.dtp33form.elements[row+2].value= document.dtp33form.elements[row+1].value
document.dtp33form.elements[row+3].value=und[document.dtp33form.elements[row+2].value]
}

function calc(rrow,ccol)
{
	row=nhd+nrd*ncd+rrow*(ncd+1)
	if(document.dtp33form.elements[row+2].value/1)
	{
		cant=document.dtp33form.elements[row+4].value/1
		unit=document.dtp33form.elements[row+5].value/1
		mont=suma(document.dtp33form.elements[row+6].value)
		if(ccol==1) if(mont/1 && cant/1) unit=punto(mont/cant)
				else if(unit/1 && cant/1) mont=punto0(unit*cant)
		if(ccol==2) if(unit/1 && cant/1) mont=punto0(unit*cant)
		if(ccol==3) if(mont/1 && cant/1) unit=punto(mont/cant)
		if(!cant) cant=""
		if(!unit) unit=""
		if(!mont) mont=""
		document.dtp33form.elements[row+4].value=cant
		document.dtp33form.elements[row+5].value=unit
		document.dtp33form.elements[row+6].value=mont
	}
	else
	{
                document.dtp33form.elements[row+4].value=""
                document.dtp33form.elements[row+5].value=""
                document.dtp33form.elements[row+6].value=""
        }
sumadc()
}
	
function cons(xx) { botonpres=xx.value }
function closeform()
{
        swapin()
        fld=0
        if(botonpres=="Consultar")
        {
                for(i=0;i<nhd+ncd;i++) if( document.dtp33form.elements[i].value!="") fld=1
                if(fld==0) document.dtp33form.elements[0].value=""
                return true
        }
	return true
}
function insert(rrow)
{
row=nhd+nrd*ncd+rrow*(ncd+1)
rw=(document.dtp33form.elements[row].value)-1
if(document.dtp33form.elements[row+1].value !="")
if(document.dtp33form.elements[nhd+(nrd-1)*ncd].value=="")
{
	swapin()
	for(i=nrd-1;i>rw;i--) for (j=0;j<ncd;j++)
	document.dtp33form.elements[nhd+i*ncd+j].value=document.dtp33form.elements[nhd+i*ncd+j-ncd].value
	for (j=0;j<ncd;j++) document.dtp33form.elements[nhd+i*ncd+j].value=""
	swapout()
}
else alert ("NO PERMITE NUEVA INSERCION")
else
{
	swapin()
	for(i=rw; i<nrd-1;i++) for (j=0;j<ncd;j++)
	document.dtp33form.elements[nhd+i*ncd+j].value=document.dtp33form.elements[nhd+i*ncd+j+ncd].value
	for (j=0;j<ncd;j++)
	document.dtp33form.elements[nhd+i*ncd+j].value=""
	swapout()
}
}
function clearform()
{
lreg=nhd+nrd*ncd+lin*(ncd+1)
for (i=0;i<lreg;i++)
{
	document.dtp33form.elements[i].value=""
	if(document.dtp33form.elements[i].type=="checkbox")
		document.dtp33form.elements[i].checked=false
}
document.dtp33form.elements[i++].disabled=false
document.dtp33form.elements[i++].disabled=true
document.dtp33form.elements[0].readOnly=false
tp=0
for (j=i;j< document.dtp33form.elements.length;j++)
if(document.dtp33form.elements[j].type=="text") document.dtp33form.elements[j].value=""
swapout()
}
function punto(h)
{
        sig=""
        if (h/1 <0) { sig="-" ;h *= -1 }
        h = h/1 + .00005
        h=h + ""
        sp=h.split(".")
        if(sp[1]==undefined) sp[1]="00000"
        sp[1]=sp[1].substr(0,4)
        return(sig+sp[0]+"."+sp[1])
}
function punto0(h)
{
        sig=""
        if (h/1 <0) { sig="-" ;h *= -1 }
        h = h/1 + .05
        h=h + ""
        sp=h.split(".")
        if(sp[1]==undefined) sp[1]=""
        sp[1]=sp[1].substr(0,4)
        return(sig+sp[0])
}
function suma(h)
{
        sp=h.split("+")
        if(sp[1]==undefined) return(sp[0]/1)
	else return (sp[0]/1+sp[1]/1)
}
function sumadc()
{
        swapin()
        sumadb=0
        sumacr=0
        for(i=0;i<nrd;i++)
        {

                row=nhd+ncd*i
                if(document.dtp33form.elements[row].value!="") sumadb +=document.dtp33form.elements[row+5].value/1
        }
        document.dtp33form.NT.value=punto0(sumadb)
        document.dtp33form.IV.value=punto0(sumadb*.19)
        document.dtp33form.TT.value=punto0(sumadb*1.19)
}

