/*******************************************************************************
*  mtstudios_utilities.js : 22.06.2005
* -----------------------------------------------------------------------------
*  A group of useful JavaScript utilities that can aid in the development
*  of webpages.
*******************************************************************************/

/* Calendar Popup */

var popUp; 

function OpenCalendar(idname, postBack)
{
	popUp = window.open('Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupcal', 
		'width=175,height=190,left=200,top=250');
}

/* Other Calendar Popup - If a date is entered in the startdate then set the 2nd popup to that date, but override if 2nd HAS a date! */
function OpenCalendarDepart(startdate, enddate, postBack)
{
	if (document.forms[0].elements[enddate].value != '')
	{
		popUp = window.open('Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + enddate + '&selected=' + document.forms[0].elements[enddate].value + '&postBack=' + postBack, 
		'popupcal', 
		'width=175,height=190,left=200,top=250');
	}
	else
	{
		popUp = window.open('Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + enddate + '&selected=' + document.forms[0].elements[startdate].value + '&postBack=' + postBack, 
		'popupcal', 
		'width=175,height=190,left=200,top=250');
	}

}

function SetDate(formName, id, newDate, postBack)
{
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = newDate;
	if (postBack)
		__doPostBack(id,'');
}