setTimeout("document.ventaform.ventaH00.focus()",50)
//document.ventaform.elements[1].focus()
function chng(x) {
if(x==0) valact()
if(x==6) sumadc()
}
function exswap()
{
	return
}
function cons(xx) { botonpres=xx.value }
function closeform()
{
        swapin()
        fld=0
        if(botonpres=="Consultar")
        {
                for(i=0;i<nhd;i++) if( document.ventaform.elements[i].value!="") fld=1
                if(fld==0) document.ventaform.elements[0].value="*"
                return true
        }
	return true
}
function insert(rrow)
{
row=nhd+nrd*ncd+rrow*(ncd+1)
rw=(document.ventaform.elements[row].value)-1
if(document.ventaform.elements[row+1].value !="")
if(document.ventaform.elements[nhd+(nrd-1)*ncd].value=="")
{
	swapin()
	for(i=nrd-1;i>rw;i--) for (j=0;j<ncd;j++)
	document.ventaform.elements[nhd+i*ncd+j].value=document.ventaform.elements[nhd+i*ncd+j-ncd].value
	for (j=0;j<ncd;j++) document.ventaform.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.ventaform.elements[nhd+i*ncd+j].value=document.ventaform.elements[nhd+i*ncd+j+ncd].value
	for (j=0;j<ncd;j++)
	document.ventaform.elements[nhd+i*ncd+j].value=""
	swapout()
}
}
function clearform()
{
lreg=nhd+nrd*ncd+lin*(ncd+1)
for (i=0;i<lreg;i++)
{
	document.ventaform.elements[i].value=""
	if(document.ventaform.elements[i].type=="checkbox")
		document.ventaform.elements[i].checked=false
}
document.ventaform.elements[i++].disabled=false
document.ventaform.elements[i++].disabled=true
document.ventaform.elements[0].readOnly=false
tp=0
for (j=i;j< document.ventaform.elements.length;j++)
if(document.ventaform.elements[j].type=="text") document.ventaform.elements[j].value=""
swapout()
}

lreg=nhd+nrd*ncd+lin*(ncd+1)
if(document.ventaform.elements[lreg].disabled==true) sumadc()
function sumadc()
{
	swapin()
	sumakg=0
	sumavt=0
	sumaef=0
	sumach=0
	for(i=0;i<nrd;i++)
	{
		
		row=nhd+ncd*i
		if(document.ventaform.elements[row].value!="")
		{
			sumakg +=(document.ventaform.elements[row+9].value/1)
			sumavt +=(document.ventaform.elements[row+10].value/1)
			fp=document.ventaform.elements[row+12].value
			if(fp=="CH") sumach +=(document.ventaform.elements[row+11].value/1)
			if(fp=="EF") sumaef +=(document.ventaform.elements[row+11].value/1)
		}
	}
	document.ventaform.TOTKGS.value="TK: " +sumakg
	document.ventaform.TOTVTA.value="VT: " +sumavt
	document.ventaform.TOTEFE.value="EF: " +(sumaef - document.ventaform.elements[6].value)
	document.ventaform.TOTCHE.value="CH: " +sumach
	document.ventaform.TOTCRE.value="CR: " +(sumavt-sumaef-sumach)
}
function tkilos(rrow)
{
row=nhd+nrd*ncd+rrow*(ncd+1)
sumakg =0
for (i=3;i<10;i++) if(document.ventaform.elements[row+i].value!="")
	sumakg +=(document.ventaform.elements[row+i].value/1)
if(document.ventaform.elements[row+1].value!="") document.ventaform.elements[row+i].value=sumakg
}
