var calendarObjForForm = new DHTMLSuite.calendar({minuteDropDownInterval:10,numberOfRowsInHourDropDown:5,callbackFunctionOnDayClick:'getDateFromCalendar',isDragable:true,displayTimeBar:false}); 

var myCalendarModel = new DHTMLSuite.calendarModel();
myCalendarModel.setLanguageCode('fr');
calendarObjForForm.setCalendarModelReference(myCalendarModel);

var orioaiDateFormat = '';

function pickDate(buttonObj,inputObject, localOrioaiDateFormat)
{
	orioaiDateFormat = localOrioaiDateFormat;
	
	calendarObjForForm.setCalendarPositionByHTMLElement(inputObject,0,inputObject.offsetHeight+2);	// Position the calendar right below the form input
	calendarObjForForm.setInitialDateFromInput(inputObject,orioaiDateFormat);	// Specify that the calendar should set it's initial date from the value of the input field.
	//calendarObjForForm.setInitialDateFromInput(inputObject,'yyyy-mm-dd');	// Specify that the calendar should set it's initial date from the value of the input field.
	calendarObjForForm.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(calendarObjForForm.isVisible()){
		calendarObjForForm.hide();
	}else{
		calendarObjForForm.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.
		calendarObjForForm.display();
	}		
}

/* inputArray is an associative array with the properties
year
month
day
calendarRef - Reference to the DHTMLSuite.calendar object.
*/
function getDateFromCalendar(inputArray, abc)
{
	var references = calendarObjForForm.getHtmlElementReferences(); // Get back reference to form field.
	
	var value = new String(orioaiDateFormat);
	value = value.replace("dd", inputArray.day);
	value = value.replace("MM", inputArray.month);
	value = value.replace("yyyy", inputArray.year);
	
	references.myDate.value = value;//inputArray.day + '-' + inputArray.month + '-' + inputArray.year;
	//references.myDate.value = inputArray.year + '-' + inputArray.month + '-' + inputArray.day;
	calendarObjForForm.hide();	
	
}