function ShowCalendar(img, fld, path) 
{


	//date to set the calendar to
	var inputdate = fld.value;

	//show or hide the calendar and move the frame
	var imgTop=0;
	var imgLeft=0;
	var imgHeight=img.height;
	var imgWidth=img.width;
	while(img&&img.tagName!="BODY")
	{
		imgTop+=img.offsetTop;
		imgLeft+=img.offsetLeft;
		img=img.offsetParent;
	}
	if (document.all.CalFrame.style.display == 'none') {
		document.all.CalFrame.style.display = 'block';
		if ((document.body.clientHeight - 40) - (imgTop + imgHeight) >= 172) 
		{
			document.all.CalFrame.style.top = imgTop + imgHeight;
		} 
		else 
		{
			document.all.CalFrame.style.top = imgTop - 172;
		}
		if (document.body.clientWidth - imgLeft >= 114) 
		{
			document.all.CalFrame.style.left = imgLeft;
		} 
		else 
		{
			document.all.CalFrame.style.left = imgLeft - (114 - imgWidth);
		}
		document.all.CalFrame.src = path + "calendar/Calendar.aspx?inputdate=" + inputdate;
	}
	else 
	{
		document.all.CalFrame.style.display = 'none';
	}	
	g_fld = fld
	g_fldEnd = 0
	
}

function ShowCalendarWk(img, startfld, endfld, path) 
{
	//date to set the calendar to
	var inputdate = startfld.value;

	//show or hide the calendar and move the frame
	var imgTop=0;
	var imgLeft=0;
	var imgHeight=img.height;
	var imgWidth=img.width;
	while(img&&img.tagName!="BODY")
	{
		imgTop+=img.offsetTop;
		imgLeft+=img.offsetLeft;
		img=img.offsetParent;
	}
	alert('moo');
	if (document.all.CalFrame.style.display == 'none') {
		document.all.CalFrame.style.display = 'block';
		if ((document.body.clientHeight - 40) - (imgTop + imgHeight) >= 172) 
		{
			document.all.CalFrame.style.top = imgTop + imgHeight;
		} 
		else 
		{
			document.all.CalFrame.style.top = imgTop - 172;
		}
		if (document.body.clientWidth - imgLeft >= 114) 
		{
			document.all.CalFrame.style.left = imgLeft;
		} 
		else 
		{
			document.all.CalFrame.style.left = imgLeft - (114 - imgWidth);
		}
		document.all.CalFrame.src = path + "calendar/Calendar.aspx?inputdate=" + inputdate;
	}
	else 
	{
		document.all.CalFrame.style.display = 'none';
	}	
	g_fld = startfld
	g_fldEnd = endfld	
}

function SetDate(selecteddate) 
{
	if (g_fldEnd == 0)
	{
		g_fld.value = selecteddate;
	}
	else
	{
		var dt = new Date(selecteddate);
		var msStartDate = dt.getTime() - dt.getDay() * 86400000;
		var msEndDate = dt.getTime() + ((6 - dt.getDay()) * 86400000);
		var start = new Date(msStartDate);
		var end = new Date(msEndDate);
		g_fld.value = start.getMonth()+1 + "/" + start. getDate() + "/" + start.getFullYear();
		g_fldEnd.value = end.getMonth()+1 + "/" + end. getDate() + "/" + end.getFullYear();
	}
}
