if(document.ventalocal.elements[0].value!="") totl()
function prd1(codp)
{
	x=codp.name
	z=x.substr(13,2)/1
	reg=(nhd+ncd*nrd+1)/1+z*(ncd+1)/1
	y=document.ventalocal.elements[(reg+1)]
	w=document.ventalocal.elements[(reg+2)]
	if(codp.value!="" &&  codp.value!=" ") { w.value=precl[codp.value]; y.value=codp.value }
	else { w.value="";y.value="" }
	document.ventalocal.elements[(reg+3)].value=""
	document.ventalocal.elements[(reg+4)].value=""
	totl()
}
function prd2(codp)
{
	x=codp.name
	z=x.substr(13,2)/1
	reg=(nhd+ncd*nrd+2)/1+z*(ncd+1)/1
	y=document.ventalocal.elements[(reg-1)]
	w=document.ventalocal.elements[(reg+1)]
	if(codp.value!="" &&  codp.value!=" ") { w.value=precl[codp.value]; y.value=codp.value }
	else { w.value="";y.value="" }
	document.ventalocal.elements[(reg+3)].value=""
	document.ventalocal.elements[(reg+2)].value=""
	totl()
}
function calct(codp)
{
        x=codp.name
        z=x.substr(13,2)/1
        reg=(nhd+ncd*nrd+4)/1+z*(ncd+1)/1
        y=document.ventalocal.elements[reg-1]
	w=document.ventalocal.elements[(reg+1)]
	w.value=codp.value*y.value
        if(w.value==0) w.value=""
	totl()
}
function totl(x)
{
        swapin()
        suma=0
        sumc=0
        for(i=0;i<nrd;i++)
        {
                row=nhd+ncd*i
                if(document.ventalocal.elements[row/1+1].value!="") sumc +=(document.ventalocal.elements[row/1+3].value)/1
                if(document.ventalocal.elements[row/1+1].value!="") suma +=(document.ventalocal.elements[row/1+4].value)/1
	}
        if(!suma) document.ventalocal.net.value=""
	document.ventalocal.net.value=punt0(suma)
        if(!sumc) document.ventalocal.cant.value=""
	document.ventalocal.cant.value=punt0(sumc)
}
function punt0(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()
        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)
}
