function chng(x) {
if(x==0) valact()

if(x==3||x==21) dob(x,1)
}
//function exswap()
//{
	//return
//}
function cons(xx) { botonpres=xx.value }
function closeform()
{
        swapin()
        fld=0
        if(botonpres=="Consultar")
        {
                for(i=0;i<nhd+ncd;i++) if( document.fdav1form.elements[i].value!="") fld=1
                if(fld==0) document.fdav1form.elements[0].value=""
                return true
        }
	return true
}
function insert(rrow)
{
row=nhd+nrd*ncd+rrow*(ncd+1)
rw=(document.fdav1form.elements[row].value)-1
if(document.fdav1form.elements[row+1].value !="")
if(document.fdav1form.elements[nhd+(nrd-1)*ncd].value=="")
{
	swapin()
	for(i=nrd-1;i>rw;i--) for (j=0;j<ncd;j++)
	document.fdav1form.elements[nhd+i*ncd+j].value=document.fdav1form.elements[nhd+i*ncd+j-ncd].value
	for (j=0;j<ncd;j++) document.fdav1form.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.fdav1form.elements[nhd+i*ncd+j].value=document.fdav1form.elements[nhd+i*ncd+j+ncd].value
	for (j=0;j<ncd;j++)
	document.fdav1form.elements[nhd+i*ncd+j].value=""
	swapout()
}
}
function clearform()
{
lreg=nhd+nrd*ncd+lin*(ncd+1)
for (i=0;i<lreg;i++)
{
	document.fdav1form.elements[i].value=""
	if(document.fdav1form.elements[i].type=="checkbox")
		document.fdav1form.elements[i].checked=false
}
document.fdav1form.elements[i++].disabled=false
document.fdav1form.elements[i++].disabled=true
document.fdav1form.elements[0].readOnly=false
tp=0
for (j=i;j< document.fdav1form.elements.length;j++)
if(document.fdav1form.elements[j].type=="text") document.fdav1form.elements[j].value=""
swapout()
}
function uplphoto()
{
var obj_calwindow = window.open('upload/',"","width=300,height=300,top=50,left=50,titlebar=no,resizable=no,mimimizable=no,dialog=no")
}
dob(3,0)
dob(21,0)
function dob(x,y)
{
	if(document.fdav1form.elements[0].value!="")
	{
		if(document.fdav1form.elements[x].value!="")
		{
			var bod=document.fdav1form.elements[x].value
			var tod=today("")
			tod=tod.split("/")
			bod=bod.split("/")
			m=
			a=tod[2]- bod[2]
			m=tod[0]- bod[0]
			d=tod[1]- bod[1]
			if (d<0) m -=1
			if (m<0)
			{
				 m +=12
				a--
			}
			document.fdav1form.elements[x+1].value=a + "a" + m + "m"
		}
	}
}
function today(x,y)
{
	brs=whichBrs()
	var time=new Date()
	var lmonth=time.getMonth()+1
	if(lmonth<10) lmonth="0"+lmonth
	var lday=time.getDate()
	if(lday/1 <10) lday="0"+lday
	var year=time.getYear()
	if(brs=="Firefox" || brs=="Safari") year +=1900
	var lmin=time.getMinutes()
	if(lmin<10) lmin="0"+lmin
	var lhour=time.getHours()
	if(lhour<10) lhour="0"+lhour
	tm=""
	if (y==1) tm= " " + lhour + ":" + lmin
	if(x.type!="undefined"&&x.value=="")
	{
		x.value=lmonth+"/"+lday+"/"+year+tm
		x.select()
	}
	else return lmonth+"/"+lday+"/"+year+tm
}
function todayt(x)
{
	brs=whichBrs()
	var time=new Date()
	var lmonth=time.getMonth()+1
	if(lmonth<10) lmonth="0"+lmonth
	var lday=time.getDate()
	if(lday/1 <10) lday="0"+lday
	var year=time.getYear()
	if(brs=="Firefox" || brs=="Safari") year +=1900
	var lmin=time.getMinutes()
	if(lmin<10) lmin="0"+lmin
	var lhour=time.getHours()
	if(lhour<10) lhour="0"+lhour
	if(x.type!="undefined"&&x.value=="")
	{
		x.value=lmonth+"/"+lday+"/"+year+" "+lhour+":"+lmin
		x.select()
	}
	else return lmonth+"/"+lday+"/"+year+" "+lhour+":"+lmin
}
