//general javascript function
var calendarObjForForm = new DHTMLSuite.calendar({callbackFunctionOnDayClick:'getDateFromCalendar',isDragable:false,displayTimeBar:false}); 

calendarObjForForm.setCallbackFunctionOnClose('myOtherFunction');

function myOtherFunction()
{

}

function getDateFromCalendar(inputArray)
	{
		var references = calendarObjForForm.getHtmlElementReferences(); // Get back reference to form field.
		references.myDate.value = inputArray.year + '-' + inputArray.month+ '-' + inputArray.day;// + ' ' + inputArray.hour + ':' + inputArray.minute;
		calendarObjForForm.hide();	
		
	}	
	
function pickDate(inputObject, maxYear)
{
	if(maxYear!='0'){
		var myCalendarModel5 = new DHTMLSuite.calendarModel( );
		myCalendarModel5.addInvalidDateRange({year: maxYear,month:1,day:1},false);
	
		calendarObjForForm.setCalendarModelReference(myCalendarModel5);
	}
	
	calendarObjForForm.setCalendarPositionByHTMLElement(inputObject,0,inputObject.offsetHeight+2);	// Position the calendar right below the form input
	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();
		

	}		
}	

function showDiv(name)
{

	document.getElementById(name).style.display = 'block';
}

function preloadImages()
{
  if(document.images)
  {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = preloadImages.arguments;
    
    for(i=0; i<args.length; i++)
    {
      if (args[i].indexOf("#")!=0)
      {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
		 
      }
    }
  }
}

function hideDiv(name)
{

	document.getElementById(name).style.display = 'none';
}


function getCheckedValue(className) {
	//if(!radioObj)
//		return "";
	radioObj = $('.'+className);
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}
