
  /////////////////////////////////////////////////////
  //                                                 //
  //          C-NOOFS Forecast Viewer v0.6           //
  //               Web User Interface                //
  //                                                 //
  /////////////////////////////////////////////////////
  

/**
 * Builds the modal calendar dialog
 */
function DateChooser(textField)
{
	this.RunDateOverlay = new YAHOO.widget.Panel("wait", { width: "600px", fixedcenter: true, close: false, draggable: false, modal: true, visible: false } );
	this.RunDateOverlay.setHeader("<div id=\"CalendarCloseButton\" class=\"close\"></div>Choose Run Date(s)");
	this.RunDateOverlay.setBody("<div class=\"yui-skin-sam\"><div id=\"CalendarOverlay\" style=\"display:none;margin:0px auto;\"></div><input type=\"button\" value=\"View Selected Dates\" id=\"CalendarSaveButton\" class=\"floatRight\"></div></div>");
	this.RunDateOverlay.render(document.body);
	
	this.RunDateCalendar = new YAHOO.widget.CalendarGroup("RunDateCalendar","CalendarOverlay", {visible:true, pages:3, MULTI_SELECT: true});
	
	// Select today
	var dt = new Date();
	this.RunDateCalendar.select(dt);
	this.RunDateCalendar.render();
	this.RunDateOverlay.render(document.body);
}

DateChooser.prototype.RunDateOverlay = {}
DateChooser.prototype.RunDateCalendar = {}


DateChooser.prototype.getSelected = function()
{
	return this.RunDateCalendar.getSelectedDates();	 
}

/**
 * Enable the modal calendar dialog
 */
DateChooser.prototype.Show = function() 
{
	this.RunDateCalendar.show();	
	this.RunDateOverlay.show();
}

/**
 * Disable the modal calendar dialog
 */
DateChooser.prototype.Hide = function() 
{
	this.RunDateCalendar.hide();	
	this.RunDateOverlay.hide();
}

/**
 * Set handler to be triggered when user closes the dialog
 */
DateChooser.prototype.setSaveHandler = function(handler)
{
 	var DC = this;
	YAHOO.util.Event.addListener("CalendarCloseButton", "click", function(e) { handler(e); DC.Hide(); });
	YAHOO.util.Event.addListener("CalendarSaveButton", "click", function(e) { handler(e); DC.Hide(); });
}

