
/*
javascript dateSelector object

JDSS - December 2004

// updated
// 2006-03-27
// 2006-03-28

*/

// DEFINITIONS
monthsArray = new Array("January","February","March","April","May","June","July","August","September","October","November","December");

monthsArray_short = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

millisecs_in_day = 24 * 60 * 60 * 1000;

// END OF DEFINITIONS

// UTILITY FUNCTIONS
function _padNum( num )       // returns number as a string padded with leading zeros
					// returned string length can be supplied as 2nd argument
					// default = 2, e.g. padNum( 7 ) returns "07"
					// padNum( 7, 3 ) returns "007"
{
  // test to see if string length supplied as second argument
  // e.g. padNum( 6 ) should return "06" while padNum( 6, 3 ) should return "006"
  var len = ( arguments.length > 1 ) ? arguments[1] : 2;    // if no length supplied, default to 2, e.g. "04"

  var numstr = "" + num;
  while (numstr.length < len)
    numstr = "0" + numstr;

  return numstr;
}

// END OF UTILITY FUNCS

// OBJECT INSPECTOR (OF SORTS)
function _showInfo()
{
  document.writeln( "<table border=1 cellspacing=3>" );
  document.writeln( "<tr><td align='right'><b>objName</b></td><td>" + this.objName + "</td></tr>" );
  document.writeln( "<tr><td align='right'><b>id</b></td><td>" + this.id + "</td></tr>" );
  document.writeln( "<tr><td align='right'><b>date.toLocaleString()</b></td><td>" + this.date.toLocaleString() + "</td></tr>" );
  document.writeln( "<tr><td align='right'><b>params</b></td><td>" + this.year + "," + this.month + "," + this.day + "," + this.hour + "," + this.minute + "</td></tr>" );
  document.writeln( "<tr><td align='right'><b>select range</b></td><td>" + this.startYear + " to " + this.endYear + "</td></tr>" );
  document.writeln( "<tr><td align='right'><b>targetType</b></td><td>" + this.targetType + "</td></tr>" );
  document.writeln( "<tr><td align='right'><b>testVal</b></td><td>" + this.testVal + "</td></tr>" );
  document.writeln( "</table>" );
  document.writeln( "<br>" );
}

// DATE FUNCTIONS
function _updateParamsFromDate()
{
  this.day = this.date.getDate();
  this.month = this.date.getMonth();
  this.year = this.date.getFullYear();
  this.hour = this.date.getHours();
  this.minute = this.date.getMinutes();

  this.correctEndTime();
}

function _setDateTime( epoch_msecs )                              // milliseconds after 1/1-1970
{
  this.date.setTime( epoch_msecs );      // sets the object new time despite false params, (eg 30 Feb)
  this.updateParamsFromDate();           // updates params
}

function _updateDateFromParams()
{
  var newDate = new Date( this.year, this.month, this.day, this.hour, this.minute, "00" );    // yyyy,mm,dd,hh,mm,ss
                                                                    // creates a date even from false params, (eg 30 Feb)
  this.setDateTime( newDate.getTime() );	// sets the object new time, & then calls function to regenerate the params 
}

function _setMinute( num )
{
  if (num > -1 && num < 60) {
    this.minute = num;
    this.updateDateFromParams();
  }
}

function _setHour( num )
{
  if (num > -1 && num < 24) {
    this.hour = num;
    this.updateDateFromParams();
  }
}

function _setDay( num )
{
  if (num > 0 && num < 32) {
    this.day = num;
    this.updateDateFromParams();
  }
}

function _setMonth( num )
{
  if (num > -1 && num < 12) {
    this.month = num;
    this.updateDateFromParams();
  }
}

function _setYear( num )
{
  if ( num >= this.startYear && num <= this.endYear ) {
    this.year = num;
    this.updateDateFromParams();
  }
}

function _setEndMinute( num )
{
  if (num > -1 && num < 60) {
    this.endminute = num;
    this.updateDateFromParams();
  }
}

function _setEndHour( num )
{
  if (num > -1 && num < 24) {
    this.endhour = num;
    this.updateDateFromParams();
  }
}

function _setEndTime( sql_time )
{
  if( sql_time ) {
    var timeArray = sql_time.split(":");
    var hr_str = timeArray[0];
    var min_str = timeArray[1];

    if( hr_str && min_str ) {
      this.setEndHour( parseInt( hr_str,10 ) );
      this.setEndMinute( parseInt( min_str,10 ) );
    }
  }
}

function _setTime( sql_time )
{
  if( sql_time ) {
    var timeArray = sql_time.split(":");
    var hr_str = timeArray[0];
    var min_str = timeArray[1];

    if( hr_str && min_str ) {
      this.setHour( parseInt( hr_str,10 ) );
      this.setMinute( parseInt( min_str,10 ) );
    }
  }
}

function _zeroTimes()
{
  this.hour = this.endhour = this.minute = this.endminute = 0;
}

function _zeroEndTime()
{
  this.endhour = this.hour;
  this.endminute = this.minute;
}

function _setToNow()
{
  this.date = new Date();
  this.updateParamsFromDate();           // updates params
  this.zeroEndTime();
}

function _addDay()
{
  var numdays = arguments.length ? arguments[0] : 1;    // if no length supplied, default to 1 (day)
  if( isNaN( numdays ) ==  false  && numdays ) {
    var curr = this.get_timestamp();
    curr += ( numdays * millisecs_in_day );
    this.setDateTime( curr );
  }
}

function _addWeek()
{
  var numweeks = arguments.length ? arguments[0] : 1;    // if no length supplied, default to 1 (week)
  if( isNaN( numweeks ) ==  false  && numweeks ) {
    this.addDay( numweeks * 7 );
  }
}

function _addMonth()
{
  var nummonths = arguments.length ? arguments[0] : 1;    // if no length supplied, default to 1 (month)

  if( isNaN( nummonths )==false  && nummonths ) {

    var yearincrement = 0;

    if(  nummonths > 0 ) {
      while ( nummonths > 12 ) {
        nummonths -= 12;
        yearincrement++;
      }
      var month = this.month + nummonths;
      var year = this.year + yearincrement;
      if( month > 11 ) {
        month -= 12 ;
        year++;
      }
    }

    else {
      nummonths *= -1;
      while ( nummonths > 12 ) {
        nummonths -= 12;
        yearincrement++;
      }
      var month = this.month - nummonths;
      var year = this.year - yearincrement;
      if( month < 0 ) {
        month += 12 ;
        year--;
      }
    }

    this.month = month;
    var curr_month = month;              // store in case month changes with updateDateFromParams if day (28+) is invalid
    this.year = year;
    this.updateDateFromParams();

    while( curr_month != this.month ) {
      this.addDay(-1);                   // for days over 28, to retain month name integrity (although not day!)
    }
  }
}

function _addYear()
{
  var numyears = arguments.length ? arguments[0] : 1;    // if no length supplied, default to 1 (week)
  if( isNaN( numyears ) ==  false  && numyears ) {
    this.year += numyears;
    this.updateDateFromParams();
  }
}

function _setFromSQL_DateTime( str )		// typical str: '2004-03-24 16:19:00'
{
  if( str ) {
    var dateTimeArray = str.split(" ");
    var dateArray = dateTimeArray[0].split("-");
    var timeArray = dateTimeArray[1] ? dateTimeArray[1].split(":") : 0;

    var num = parseInt( dateArray[0],10 );                // year
    if ( num >= this.startYear && num <= this.endYear )
      this.year = num;

    num = parseInt( dateArray[1],10 );                    // month
    if (num > 0 && num < 13)
      this.month = num - 1;

    num = parseInt( dateArray[2],10 );                    // day
    if (num > 0 && num < 32)
      this.day = num;

    if( timeArray ) {
      num = parseInt( timeArray[0],10 );                  // hour
      if (num > -1 && num < 24)
        this.hour = num;

      num = parseInt( timeArray[1],10 );                  // minute
      if (num > -1 && num < 60)
        this.minute = num;
    }

    this.updateDateFromParams();
  }
}

function _setFromSQL_Time( str )		// typical str:  '16:19:00'
{
  if( str ) {

    var timeArray = str.split(":");

    if( timeArray ) {
      var num = parseInt( timeArray[0], 10 );                  // hour
      if (num > -1 && num < 24)
        this.hour = num;

      if( timeArray[1] ) {
        num = parseInt( timeArray[1], 10 );                      // minute
        if (num > -1 && num < 60)
          this.minute = num;
      }
    }
    this.updateDateFromParams();
  }
}

function _setYearRange( startYear, endYear )
{
  if( this.year_drawn )
    return;
  if ( 1 ) {	// really needs to check for range outside what is actually possible
    this.startYear = startYear;
    this.endYear = endYear;
/*
    if( this.year < this.startYear || this.year > this.endYear )	// stored date outside select range
      this.year = this.startYear;
*/
    if( this.year < this.startYear )					// start year greater than stored year
      this.startYear = this.year;
    else if( this.year > this.endYear )					// end year less than stored year
      this.endYear = this.year;
  }
}

function _drawDaySelector()
{
  if( this.day_drawn )
    return;
  document.write( "<select id='" + this.id + "_day' onchange='javascript:" + this.objName + ".dayChanged( this )'>\n" );
  for( var x=1; x<= 31; x++ ) {
    document.write( "\t<option value='" + x + "'");
    document.write( x == this.day ? " SELECTED" : "" );
    document.write( ">" + x + "\n" );
  }
  document.write( "</select>\n" );

  this.day_drawn = 1;
}

function _drawMonthSelector()
{
  if( this.month_drawn )
    return;
  document.write("<select id='" + this.id + "_month' onchange='javascript:" + this.objName + ".monthChanged( this )'>\n");
  for( var i in monthsArray ) {
    document.write( "\t<option value='" + i + "'");
    document.write( i == this.month ? " SELECTED" : "" );
    document.write( ">" + monthsArray[i] + "\n" );
  }
  document.write( "</select>\n" );

  this.month_drawn = 1;
}

function _drawYearSelector()
{
  if( this.year_drawn )
    return;
  document.write( "<select id='" + this.id + "_year' onchange='javascript:" + this.objName + ".yearChanged( this )'>\n" );
  for( var x = this.startYear; x <= this.endYear; x++ ) {
    document.write( "\t<option value='" + x + "'");
    document.write( x == this.year ? " SELECTED" : "" );
    document.write( ">" + x + "\n" );
  }
  document.write( "</select>\n" );

  this.year_drawn = 1;
}

function _drawHourSelector()
{
  if( this.hour_drawn )
    return;
  document.write( "<select id='" + this.id + "_hour' onchange='javascript:" + this.objName + ".hourChanged( this )'>\n" );
  for( var x = 0; x < 24; x++ ) {
    document.write( "\t<option value='" + x + "'");
    document.write( x == this.hour ? " SELECTED" : "" );
    document.write( ">" + this.padNum(x) + "\n" );
  }
  document.write( "</select>\n" );

  this.hour_drawn = 1;
}

function _drawMinuteSelector()
{
  if( this.minute_drawn )
    return;
  document.write("<select id='" + this.id + "_minute' onchange='javascript:" + this.objName + ".minuteChanged(this)'>\n");
  for( var x = 0; x < 60; x++ ) {
    document.write( "\t<option value='" + x + "'");
    document.write( x == this.minute ? " SELECTED" : "" );
    document.write( ">" + this.padNum(x) + "\n" );
  }
  document.write( "</select>\n" );

  this.minute_drawn = 1;
}

function _drawEndHourSelector()
{
  if( this.endhour_drawn )
    return;
  document.write( "<select id='" + this.id + "_endhour' onchange='javascript:" + this.objName + ".endhourChanged( this )'>\n" );
  for( var x = 0; x < 24; x++ ) {
    document.write( "\t<option value='" + x + "'");
    document.write( x == this.endhour ? " SELECTED" : "" );
    document.write( ">" + this.padNum(x) + "\n" );
  }
  document.write( "</select>\n" );

  this.endhour_drawn = 1;
}

function _drawEndMinuteSelector()
{
  if( this.endminute_drawn )
    return;
  document.write("<select id='" + this.id + "_endminute' onchange='javascript:" + this.objName + ".endminuteChanged(this)'>\n");
  for( var x = 0; x < 60; x++ ) {
    document.write( "\t<option value='" + x + "'");
    document.write( x == this.endminute ? " SELECTED" : "" );
    document.write( ">" + this.padNum(x) + "\n" );
  }
  document.write( "</select>\n" );

  this.endminute_drawn = 1;
}

function _drawDateSelector()
{
  this.drawDaySelector();
  this.drawMonthSelector();
  this.drawYearSelector();
}

function _drawTimeSelector()
{
  this.drawHourSelector();
  this.drawMinuteSelector();
}

function _drawDateTimeSelector()
{
  document.write( "<b>Date</b>&nbsp;" );
  this.drawDateSelector();
  document.write( "&nbsp;&nbsp;<b>Time</b>&nbsp;" );
  this.drawTimeSelector();
}

function _drawEndTimeSelector()
{
  this.drawEndHourSelector();
  this.drawEndMinuteSelector();
}

function _drawDateTimeSelector_withEndTime()
{
  this.drawDateTimeSelector();
  document.write( "&nbsp;&nbsp;<b>End</b>&nbsp;" );
  this.drawEndTimeSelector();
}

function _drawDateTimeSelector_noTitles()
{
  this.drawDateSelector();
  document.write( "&nbsp;&nbsp;&nbsp;" );
  this.drawTimeSelector();
}

function _drawDateTimeSelector_withEndTime_minTitles()
{
  this.drawDateTimeSelector_noTitles();
  document.write( "&nbsp;<b>to</b>&nbsp;" );
  this.drawEndTimeSelector();
}

function _drawDateOnlySelector()
{
  this.drawDateSelector();

  this.endhour = this.hour = 0;
  this.endminute = this.minute = 0;
}

function _drawDayOfYearSelector()
{
  this.drawDaySelector();
  this.drawMonthSelector();

  this.endhour = this.hour = 0;
  this.endminute = this.minute = 0;
  this.year = 2000;		// ensures leap day is available
}

function _drawMonthAndYearSelector()
{
  this.drawMonthSelector();
  this.drawYearSelector();

  this.endhour = this.hour = 0;
  this.endminute = this.minute = 0;
  this.day = 1;
}

function _get_sql_datetime()
{
  return( "" + this.year + "-" + this.padNum( this.month + 1 ) + "-" + this.padNum( this.day ) + " " + this.padNum( this.hour ) + ":" + this.padNum( this.minute ) + ":00" );
}

function _get_sql_date()
{
  return( "" + this.year + "-" + this.padNum( this.month + 1 ) + "-" + this.padNum( this.day ) );
}

function _get_sql_year()
{
  return( "" + this.year );
}

function _get_sql_time()
{
  return( "" + this.padNum( this.hour ) + ":" + this.padNum( this.minute ) + ":00" );
}

function _get_php_secs()
{
  var js_millisecs = this.date.getTime();
  return( Math.round(js_millisecs/1000) );
}

function _get_timestamp()
{
  var js_millisecs = this.date.getTime();
  return( Math.round(js_millisecs/1000) * 1000 );
}

function _get_output_val()
{
  var js_millisecs = this.date.getTime();
  var output = js_millisecs;

  switch( this.targetType ) {

     case "js_timestamp" :
            output = Math.round(js_millisecs/1000) * 1000;	// as this dateSelector does not deal in millisecs !!
            break;

     case "php_timestamp" :
            output = this.get_php_secs();
            break;

     case "sql_date" :
            output = this.get_sql_date();
            break;

     case "sql_datetime" :
            output = this.get_sql_datetime();
            break;

     case "sql_time" :
            output = this.get_sql_time();
            break;

     case "sql_year" :
            output = this.get_sql_year();
            break;

     case "gmt_str" :
            output = this.date.toGMTString();
            break;

     case "locale_str" :
            output = this.date.toLocaleString();
            break;

     default :
            output = js_millisecs;
            break;
  }

  return output;
}

function _void_func()
{
  ;
}

function _refresh_outputs()
{
  if( this.day_drawn )
    document.getElementById( "" + this.id + "_day" ).selectedIndex = this.day - 1;                  // redisplay day
  if( this.month_drawn )
    document.getElementById( "" + this.id + "_month" ).selectedIndex = this.month;                  // redisplay month
  if( this.year_drawn )
    document.getElementById( "" + this.id + "_year" ).selectedIndex = this.year - this.startYear;   // redisplay year
  if( this.hour_drawn )
    document.getElementById( "" + this.id + "_hour" ).selectedIndex = this.hour;                    // redisplay hour
  if( this.minute_drawn )
    document.getElementById( "" + this.id + "_minute" ).selectedIndex = this.minute;                // redisplay minute
  if( this.endhour_drawn )
    document.getElementById( "" + this.id + "_endhour" ).selectedIndex = this.endhour;              // redisplay endhour
  if( this.endminute_drawn )
    document.getElementById( "" + this.id + "_endminute" ).selectedIndex = this.endminute;          // redisplay endminute

  if( this.targetField_id ) {
    var output = this.get_output_val();
    document.getElementById( this.targetField_id ).value = output;
  }

  if( this.endtime_targetField_id ) {
    var et_str = "" + this.padNum( this.endhour ) + ":" + this.padNum( this.endminute ) + ":00"
    document.getElementById( this.endtime_targetField_id ).value = et_str;
  }

  this.output_refreshed_func();
}

function _draw_output( fieldName )			// late addition, selector object draws its own output 
{
  var disptype = arguments.length > 1 && arguments[1] ? "text" : "hidden";
  if( this.targetField_id && fieldName ) {
    var output_val = this.get_output_val();
    document.write( "<input type='" + disptype + "' name='" + fieldName + "' id='" + this.targetField_id + "' value='" + output_val + "' READONLY>" );
  }
}

function _yearChanged( selectorObj )
{
  var ind = selectorObj.selectedIndex;
  this.setYear( selectorObj.options[ind].value );
  this.refresh_outputs();
}

function _monthChanged( selectorObj )
{
  var ind = selectorObj.selectedIndex;
  this.setMonth( selectorObj.options[ind].value );
  this.refresh_outputs();
}

function _dayChanged( selectorObj )
{
  var ind = selectorObj.selectedIndex;
  this.setDay( selectorObj.options[ind].value );
  this.refresh_outputs();
}

function _hourChanged( selectorObj )
{
  var ind = selectorObj.selectedIndex;
  this.setHour( selectorObj.options[ind].value );
  this.refresh_outputs();
}

function _minuteChanged( selectorObj )
{
  var ind = selectorObj.selectedIndex;
  this.setMinute( selectorObj.options[ind].value );
  this.refresh_outputs();
}

function _endhourChanged( selectorObj )
{
  var ind = selectorObj.selectedIndex;
  this.setEndHour( selectorObj.options[ind].value );
  this.refresh_outputs();
}

function _endminuteChanged( selectorObj )
{
  var ind = selectorObj.selectedIndex;
  this.setEndMinute( selectorObj.options[ind].value );
  this.refresh_outputs();
}

function _correctEndTime( selectorObj )
{
  if( this.endhour < this.hour ) {
    this.endhour = this.hour;
  }
  if( this.endhour == this.hour ) {
    if( this.endminute < this.minute ) {
      this.endminute = this.minute;
    }
  }
}

function _store_endtime_target_id( endtime_targetField_id )
{
  this.endtime_targetField_id = endtime_targetField_id;
}

var dateSelector_id = 1;

// CONSTRUCTOR for the dateSelector object
/* the name of the variable used to store the object MUST be supplied as the first argument */
/* optional extra arguments:   output_field_id,   output_type,   timestamp (msecs since midnight 1/1/1970) */

function dateSelector( objName )          
{
  var argc = arguments.length;
  var argv = arguments;

  this.objName = objName;   // actual name of dateSelector object (supplied by user) e.g. dsr = new dateSelector( "dsr" );

  this.id = "dateSelector_" + ( dateSelector_id < 10 ? "0" : "") + dateSelector_id;   // makes unique id for this object
  dateSelector_id++;
 
  // optional target field id to store (a version) of the date
  this.targetField_id = argc > 1 ? ( argv[1] ? argv[1] : 0 ) : 0;
  this.targetType = argc > 2 ? ( argv[2] ? argv[2] : 0 ) : "js_timestamp";            // optional target field display type

  // optional initial datetime value (epoch millisecs) (creates stored date object)
  this.date = argc > 3 ? new Date( argv[3] ) : new Date();
 
  // optional target field id to store the 'end time' output
  this.endtime_targetField_id = 0;

  this.minute_drawn = 0;
  this.hour_drawn = 0;
  this.day_drawn = 0;
  this.month_drawn = 0;
  this.year_drawn = 0;

  this.endminute_drawn = 0;
  this.endhour_drawn = 0;

  // parameters to store, then draw or create date
  this.day = this.date.getDate();
  this.month = this.date.getMonth();
  this.year = this.date.getFullYear();
  this.hour = this.date.getHours();
  this.minute = this.date.getMinutes();

  this.endhour = this.hour;
  this.endminute = this.minute;

  this.updateDateFromParams = _updateDateFromParams;
  this.updateParamsFromDate = _updateParamsFromDate;

  // store year range
  this.startYear = this.year - 4;
  this.endYear = this.year + 16;

  this.drawDaySelector = _drawDaySelector;
  this.drawMonthSelector = _drawMonthSelector;
  this.drawYearSelector = _drawYearSelector;
  this.drawHourSelector = _drawHourSelector;
  this.drawMinuteSelector = _drawMinuteSelector;

  this.drawEndHourSelector = _drawEndHourSelector;
  this.drawEndMinuteSelector = _drawEndMinuteSelector;

  this.yearChanged = _yearChanged;
  this.monthChanged = _monthChanged;
  this.dayChanged = _dayChanged;
  this.hourChanged = _hourChanged;
  this.minuteChanged = _minuteChanged;

  this.endhourChanged = _endhourChanged;
  this.endminuteChanged = _endminuteChanged;
  this.correctEndTime = _correctEndTime;

  this.refresh_outputs = _refresh_outputs;

  this.output_refreshed_func = _void_func;

  // UTILITY FUNCTIONS
  this.padNum = _padNum;

  // USER GET DATE/TIME VALUE FUNCTIONS
  this.get_sql_datetime = _get_sql_datetime;       // returns sql string representing date/time
  this.get_sql_date = _get_sql_date;               // returns sql string representing date
  this.get_sql_time = _get_sql_time;       	   // returns sql string representing time
  this.get_sql_year = _get_sql_year;               // returns four digit year string
  this.get_php_secs = _get_php_secs;               // returns php timestamp (secs since midnight 1st January 1970)
  this.get_timestamp = _get_timestamp;             // returns js timestamp (millisecs since midnight 1st January 1970)
  this.get_output_val = _get_output_val;           // returns output field value in currently set format

  // USER SET DATE/TIME FUNCTIONS
  this.setDateTime = _setDateTime;                 // set time stamp (millisecs since midnight 1st January 1970)
  this.setDay = _setDay;                           // set day of month (1-31)
  this.setMonth = _setMonth;                       // set month (0-11)
  this.setYear = _setYear;                         // set year (full range not yet determined)
  this.setHour = _setHour;                         // set hour (0-23)
  this.setMinute = _setMinute;                     // set minute (0-59)
  this.setTime = _setTime;                         // set hour and min using sql time as param (00:00:00 format)

  this.setEndHour = _setEndHour;                   // set end hour (0-23)
  this.setEndMinute = _setEndMinute;               // set end minute (0-59)
  this.setEndTime = _setEndTime;                   // set end hour and min using sql time as param (00:00:00 format)
  this.zeroTimes = _zeroTimes;                     // set start and end times to 0
  this.zeroEndTime = _zeroEndTime;                 // set end hour and min to current time

  this.setToNow = _setToNow;                       // set set date & time to current on PC

  this.setFromSQL_DateTime = _setFromSQL_DateTime; // set from SQL Date/Time string (or just Date string)
  this.setFromSQL_Time = _setFromSQL_Time;         // set from SQL Time string

  this.setYearRange = _setYearRange;               // not available after any DRAW SELECTOR function

  this.addDay = _addDay;                           // increment the date by a number of days
  this.addWeek = _addWeek;                         // increment the date by a number of weeks
  this.addMonth = _addMonth;                       // increment the date by a number of months
  this.addYear = _addYear;                         // increment the date by a number of years

  // DRAW SELECTOR FUNCTIONS
  this.drawDateSelector = _drawDateSelector;
  this.drawTimeSelector = _drawTimeSelector;
  this.drawDateTimeSelector = _drawDateTimeSelector;
  this.drawDateTimeSelector_noTitles = _drawDateTimeSelector_noTitles;
  this.drawDateOnlySelector = _drawDateOnlySelector;
  this.drawDayOfYearSelector = _drawDayOfYearSelector;
  this.drawMonthAndYearSelector = _drawMonthAndYearSelector;
  this.drawEndTimeSelector = _drawEndTimeSelector;
  this.drawDateTimeSelector_withEndTime = _drawDateTimeSelector_withEndTime;
  this.drawDateTimeSelector_withEndTime_minTitles = _drawDateTimeSelector_withEndTime_minTitles;

  // DRAW SELECTOR FUNCTION
  this.draw_output = _draw_output;                 // late addition, selector object draws its own output

  this.store_endtime_target_id = _store_endtime_target_id;

  // FOR TEST
  this.showInfo = _showInfo;
  this.testVal = 'xx';

  return this;
}

