
	var dateTimeCalendarObjForForm = new DHTMLSuite.calendar({minuteDropDownInterval:10,numberOfRowsInHourDropDown:5,callbackFunctionOnDayClick:'getDateTimeFromCalendar',isDragable:true,displayTimeBar:true}); 
	var dateOnlyCalendarObjForForm = new DHTMLSuite.calendar({minuteDropDownInterval:10,numberOfRowsInHourDropDown:5,callbackFunctionOnDayClick:'getDateOnlyFromCalendar',isDragable:true,displayTimeBar:false}); 
	var calendarObj;
	
	dateTimeCalendarObjForForm.setCallbackFunctionOnClose('myOtherFunction');
	dateOnlyCalendarObjForForm.setCallbackFunctionOnClose('myOtherFunction');
	
	var inputField;
	
	function myOtherFunction()
	{
		setOtherFieldValue(inputField);
	}
		
	function spadePickDate(buttonObj,inputObject, tag)
	{
		inputField = inputObject;
		calendarObj = dateOnlyCalendarObjForForm;
		formatStr = 'yyyy-mm-dd';
		if ( tag.indexOf( "Time" ) > 1 ) {
			calendarObj = dateTimeCalendarObjForForm;
			formatStr = 'yyyy-mm-dd hh:ii';
		} 
		
		calendarObj.setCalendarPositionByHTMLElement(inputObject,0,inputObject.offsetHeight+2);	// Position the calendar right below the form input
		calendarObj.setInitialDateFromInput(inputObject, formatStr);	// Specify that the calendar should set it's initial date from the value of the input field.
		calendarObj.addHtmlElementReference('myDate',inputObject);	// Adding a reference to this element so that I can pick it up in the getDateFromCalendar below(myInput is a unique key)
		if(calendarObj.isVisible()){
			calendarObj.hide();
		}else{
			calendarObj.resetViewDisplayedMonth();	// This line resets the view back to the inital display, i.e. it displays the inital month and not the month it displayed the last time it was open.
			calendarObj.display();
		}		
	}	
	/* inputArray is an associative array with the properties
	year
	month
	day
	hour
	minute
	calendarRef - Reference to the DHTMLSuite.calendar object.
	*/
	function getDateTimeFromCalendar(inputArray)
	{
		var references = calendarObj.getHtmlElementReferences(); // Get back reference to form field.
		references.myDate.value = inputArray.year + '-' + inputArray.month + '-' + inputArray.day + ' ' + inputArray.hour + ':' + inputArray.minute;
		calendarObj.hide();	
	}	
	function getDateOnlyFromCalendar(inputArray)
	{
		var references = calendarObj.getHtmlElementReferences(); // Get back reference to form field.
		references.myDate.value = inputArray.year + '-' + inputArray.month + '-' + inputArray.day;
		calendarObj.hide();	
	}	