function dinput(field)
{
	field.focused=0;
	field.dateBlured = dateBlured;
	field.closeCalander = closeCalander;
	field.dinputFocus=dinputFocus;
	field.dinputBlure=dinputBlure;
	field.setCalander=setCalander;
	field.updateCal=updateCal;
}
function setCalander(cal)
{
	this.cal=cal;
	this.calDiv=cal.div;
	this.calName=cal.name;
	this.cal.showCalander();
	this.calDiv.dinput=field;
	this.calDiv.mout=mout;
	this.calDiv.style.top=parseInt(this.style.top);
	this.calDiv.style.left=parseInt(this.style.left)+parseInt(this.style.width);

}
function mout()
{
	this.mo=0;
	if(this.dinput.focused==0)
	{
		this.dinput.dateBlured();
	}
}
function dinputFocus()
{
	this.calDiv.style.visibility = 'visible';
	this.focused=1;
	//#document.getElementById('debug').innerHTML=this.calDiv.mo+' '+this.focused+' '+this.id;
}
function dinputBlure()
{
	this.focused=0;
	this.dateBlured();
	//#document.getElementById('debug').innerHTML=this.calDiv.mo+' '+this.focused+' '+this.id;
}
function updateCal()
{
	var tmp = this.cal.parseDate(this.calDiv.dinput.value);
	if(tmp==null)
	{
		return;
	}
	this.cal.setDate(tmp[0],tmp[1]-1,tmp[2]);
	this.cal.showCalander();
}
function closeCalander(  )
{
	//alert(id);
	//calDiv=document.getElementById(id);
	//#document.getElementById('debug').innerHTML=calDiv.mo+' '+this.focused+' '+this.id;
	if((this.calDiv.mo==0)&&(this.focused!=1))
	{
		this.calDiv.style.visibility='hidden';
	}
}
function dateBlured(  )
{
	if(this.tout)
	{
		window.clearTimeout(this.tout);
	}
	//alert("closeCalander("+this.calName+")");
	this.tout = window.setTimeout("this.closeCalander()",500);
}
