function chng(x) {
if(x==0) valact()
}
//function exswap()
//{
	//return
//}
function cons(xx) { botonpres=xx.value }
function closeform()
{
        swapin()
        fld=0
        zz=""
        for (i=0;i<281;i++) zz=zz + document.pymntform.elements[i].value + "|"
        window.opener.document.orderform.elements[30].value=zz
        window.opener.document.orderform.elements[22].value=punto(sumadb)
        window.opener.document.orderform.elements[23].value=punto(balanc)
        self.close()
}
function sumadc()
{
        swapin()
        sumadb=0
        sumacr=0
        for(i=0;i<nrd;i++)
        {

                row=nhd+ncd*i
                if(document.pymntform.elements[row].value!="")
                {
                        sumadb +=(document.pymntform.elements[row+6].value/1)
                }
        }
        document.pymntform.NETO.value=punt(window.opener.document.orderform.elements[21].value)
        document.pymntform.PAID.value=punt(sumadb+"")
        balanc= -sumadb/1 + window.opener.document.orderform.elements[21].value/1 
        //balanc=(document.pymntform.NETO.value/1 - sumadb/1)
        document.pymntform.BALANCE.value=punt(balanc+"")
}
function punto(h)
{
        sig=""
        if (h/1 <0) { sig="-" ;h *= -1 }
	h = h/1 + .005
	h=h + ""
	sp=h.split(".")
	if(sp[1]==undefined) sp[1]="00"
	sp[1]=sp[1].substr(0,2)
        zz=sp[0].toString()
        return(sig+zz+"."+sp[1])
}
function punt(h)
{
        sig=""
        if (h/1 <0) { sig="-" ;h *= -1 }
        h = h/1 + .005/1
        h=h + ""
        sp=h.split(".")
	if(sp[1]==undefined) sp[1]="00"
        sp[1]=sp[1].substr(0,2)
        zz=sp[0].toString()
        r=zz.length
        xx=""
        for (i=r;i>3;i -=3) xx= "," + zz.substr(i-3,3)+ xx
        if(r<4) xx= zz.substr(0,r)
        else xx= zz.substr(0,i)+ xx
        return(sig+xx+"."+sp[1])
}


function insert(rrow)
{
row=nhd+nrd*ncd+rrow*(ncd+1)
rw=(document.pymntform.elements[row].value)-1
if(document.pymntform.elements[row+1].value !="")
if(document.pymntform.elements[nhd+(nrd-1)*ncd].value=="")
{
	swapin()
	for(i=nrd-1;i>rw;i--) for (j=0;j<ncd;j++)
	document.pymntform.elements[nhd+i*ncd+j].value=document.pymntform.elements[nhd+i*ncd+j-ncd].value
	for (j=0;j<ncd;j++) document.pymntform.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.pymntform.elements[nhd+i*ncd+j].value=document.pymntform.elements[nhd+i*ncd+j+ncd].value
	for (j=0;j<ncd;j++)
	document.pymntform.elements[nhd+i*ncd+j].value=""
	swapout()
}
}
function clearform()
{
lreg=nhd+nrd*ncd+lin*(ncd+1)
for (i=0;i<lreg;i++)
{
	document.pymntform.elements[i].value=""
	if(document.pymntform.elements[i].type=="checkbox")
		document.pymntform.elements[i].checked=false
}
document.pymntform.elements[i++].disabled=false
document.pymntform.elements[i++].disabled=true
document.pymntform.elements[0].readOnly=false
tp=0
for (j=i;j< document.pymntform.elements.length;j++)
if(document.pymntform.elements[j].type=="text") document.pymntform.elements[j].value=""
swapout()
}
        j=window.opener.document.orderform.elements[30].value
        var els = j.split("|")
        for (i=0;i<281;i++) if(els[i]==undefined) document.pymntform.elements[i].value=""
        else document.pymntform.elements[i].value=els[i]
	if(els[0]=="") document.pymntform.elements[0].value=window.opener.document.orderform.elements[1].value
	swapout()
sumadc()
