// Set the next date field with the given daysAhead.
function setNextDate(theForm,daysAhead)
{
	var dd = parseInt(theForm.fDate.value.substring(0,2),10)
	var mm = parseInt(theForm.fDate.value.substring(3,5),10)-1
	var yy = parseInt(theForm.fDate.value.substring(6,10),10)
	var newDate = new Date(yy, mm, dd+daysAhead)
	dd = Right("10"+newDate.getDate().toString(),2)
	mm = Right("10"+(newDate.getMonth()+1).toString(),2)
	yy = newDate.getYear().toString()
	theForm.sDate.value= dd+"/"+mm+"/"+yy
}


function returnCalendar(URL, formName, sDate, width, height)
{
	popUpWindow(URL, formName, sDate, width, height)
}

function returnDate(ddMMyyyy,frmName,fldName)
{
	var dd = ddMMyyyy.substring(0,2)
	var mm = ddMMyyyy.substring(2,4)
	var yy = ddMMyyyy.substring(4,8)
	var actionField = eval("window.opener.document." + frmName + "."+ fldName)
	actionField.value = yy+ "-" + mm + "-" +dd
	window.close()
}		

function returnSeparateDate(ddMMyyyy,frmName,fldYear,fldMonth,fldDay)
{
	var dd = ddMMyyyy.substring(0,2)
	var mm = ddMMyyyy.substring(2,4)
	var yy = ddMMyyyy.substring(4,8)
	var fldYY = eval("window.opener.document." + frmName + "."+ fldYear)
	var fldMM = eval("window.opener.document." + frmName + "."+ fldMonth)
	var fldDD = eval("window.opener.document." + frmName + "."+ fldDay)
	fldYY.value = parseInt(yy,10)
	fldMM.value = parseInt(mm,10)
	fldDD.value = parseInt(dd,10)
	window.close()
}		

function popUpWindow(URL, width, height) {
	popwin = window.open(URL, "PopUpWindow", "'toolbar=no,location=no,directories=no,status=no,left=500,menubar=no,scrollbars=no,resizable=no,width=" + width +",height=" + height)
	popwin.opener = self
	popwin.focus()
}
