// maakt gebruik van: common_util.js, common_language.js, common_datearray_rss.js

var dt_current = new Date();
dt_current.setUTCHours(0,0,0,0);

var datearray = new DateArray('datearray');
// De in de constructie meegegeven naam moet gelijk zijn aan de naam van de variabele.
// De naam wordt namelijk gebruikt in de constructie van de JavaScript-functie-aanroepen.
// Doordat de naam meegegeven wordt en gebruikt wordt in de functie-aanroepen wordt het
// mogelijk met meerdere onafhankelijk van elkaar opererende datearrays te werken.
// Als de naam bij de constructie ontbreekt/leeg is, wordt 'datearray' als naam gebruikt.
// Er is dus altijd een naam.

var calendar_daycolor     = '#ffffff';
var calendar_weekendcolor = '#ffeeff';
var calendar_holidaycolor = '#fff3ee';
var calendar_othercolor   = '#eeeeee';

var calendar_textcolor             = '#000000';
var calendar_todaytextcolor        = '#ff0000';
var calendar_othertextcolor        = '#cccccc';
var calendar_weekendtextcolor      = '#0000ff';
var calendar_otherweekendtextcolor = '#ccccff';

var calendar_bookingcolor     = '#ff0000';
var calendar_optioncolor      = '#ffdd00';
var calendar_overbookingcolor = '#000000';

var calendar_floatingbackgroundcolor = '#fdf7d1';

///////////////////////////////////////////////////////////////// DateArrayColor
function DateArrayColor(date,color) {
  this.date=date;
  this.color=color;
  this.bcolor=calendar_daycolor;
  this.count=0;
}

//////////////////////////////////////////////////////////////////// DateInteger
function DateInteger(date,name) {
  this.date=date;
  this.name=name;
  this.index=-1;
  this.arrayname='';
  
  this.withpijlspan=false;
  this.withdayspan=true;
  this.withenter=true;
  this.withzero=true;
  this.withtoday=true;
  this.withcalender=true;
  this.showzerodate=false;

  this.editwidth=80; //px

  this.floating=false;
  this.floatingleft=-this.editwidth; //px
  this.floatingtop=2; //px
  this.floatingheight=212; //px
  this.floatingmonthwidth=203; //px

  this.entertitle=rss(rssProcess_L);
  this.zerotitle=rss(rssNone_L);
  this.todaytitle=rss(rssToday_L);
  this.calendertitle=rss(rssSelect_L);
  this.selecttitle=Capitalize(rss(rssSelect_L));
  if (name!='') {
    this.entertitle=rss(rssProcess_1_L,name);
    this.calendertitle=rss(rssSelect_1_L,name);
    this.selecttitle=Capitalize(rss(rssSelect_1_L,name));
  }
  
  this.readonly=false;
  this.selectspanexists=false; //for internal use only; is set in datearray.setselectspan()
  
  this.setdatefunction='';
}
DateInteger.prototype.make=function(readonly) {
  if (readonly==null) readonly=false; //false=editable; true=readonly
  this.readonly=readonly;
  
  var t='';
  
  if (readonly) {
    if (this.showzerodate) t+=dateString(this.date,'wdmy');
                      else t+=dateString(this.date,'zwdmy');
  } else {
    t+='<table cellspacing="0" cellpadding="0" border="0">'+
       '<tr>';
  
    if (this.withpijlspan)
    t+='<td style="width:16px;"><span id="_'+this.arrayname+'_dateinput_pijlspan_'+this.index+'"></span></td>';
    if (this.withdayspan)
    t+='<td style="width:20px;"><span id="_'+this.arrayname+'_dateinput_dayspan_'+this.index+'"></span></td>';
    
    t+='<td>';
  
    t+='<input type="text" id="_'+this.arrayname+'_dateinput_input_'+this.index+'"';
    t+=' title="'+rss(rssDdMmYyyy)+'"';
    t+=' style="width:'+this.editwidth+'px;"';
    t+=' onchange="javascript:'+this.arrayname+'.change('+this.index+')"';
    t+=' onkeypress="javascript:'+this.arrayname+'.keypress(event,'+this.index+')"'+
       ' onfocus="javascript:'+this.arrayname+'.focus('+this.index+')"'+
       '>';

    t+='</td>'+
       '<td>';
     
    if (this.withenter)
    t+='<img'+ifstring(this.entertitle!='',' title="'+this.entertitle+'"','')+' src="'+common_path+'img/Enter.gif" border="0" style="vertical-align: top" onclick="javascript:'+this.arrayname+'.enterclick('+this.index+')">';
    if (this.withzero)
    t+='<img'+ifstring(this.zerotitle!='',' title="'+this.zerotitle+'"','')+' src="'+common_path+'img/Leeg.gif" border="0" style="vertical-align: top" onclick="javascript:'+this.arrayname+'.zeroclick('+this.index+')">';
    if (this.withtoday)
    t+='<img'+ifstring(this.todaytitle!='',' title="'+this.todaytitle+'"','')+' src="'+common_path+'img/Is.gif" border="0" style="vertical-align: top" onclick="javascript:'+this.arrayname+'.todayclick('+this.index+')">';
    if (this.withcalender) {
      if ((this.selectspanexists)||(this.floating))
    t+='<img'+ifstring(this.calendertitle!='',' title="'+this.calendertitle+'"','')+' src="'+common_path+'img/cal.gif" border="0" style="vertical-align: top" onclick="javascript:'+this.arrayname+'.calenderclick('+this.index+')">';
      if (this.floating)
    t+='<span id="_'+this.arrayname+'_dateinput_floatingspan_'+this.index+'"></span>';
    }
    t+='</td>'+
       '</tr>'+
       '</table>';
  }
  return t;
}
DateInteger.prototype.write=function() {
  if ((this.date==0)&&(!this.showzerodate)) {
    if (getid('_'+this.arrayname+'_dateinput_dayspan_'+this.index)) getid('_'+this.arrayname+'_dateinput_dayspan_'+this.index).innerHTML="&nbsp;&nbsp;";
    if (getid('_'+this.arrayname+'_dateinput_input_'+this.index)) getid('_'+this.arrayname+'_dateinput_input_'+this.index).value="";
  } else {
    if (getid('_'+this.arrayname+'_dateinput_dayspan_'+this.index)) getid('_'+this.arrayname+'_dateinput_dayspan_'+this.index).innerHTML=dateString(this.date,'w');
    if (getid('_'+this.arrayname+'_dateinput_input_'+this.index)) getid('_'+this.arrayname+'_dateinput_input_'+this.index).value=dateString(this.date,'dmy');
  }
}

////////////////////////////////////////////////////////////////////// DateArray
function DateArray(arrayname) {
  this.array=new Array();
  this.index=-1; //index actieve dateedit
  if (arrayname==null) name='datearray';
  this.arrayname=arrayname; //wordt gebruikt in functie-aanroepen
  
  //calendar
  this.firstmonth = new Date();
  this.firstmonth.setUTCHours(0,0,0,0);
  this.firstmonth.setUTCDate(1);
  this.monthcount = 3; //1; 2; 3
  this.calendarsvertical=true; //voorheen integer: =1; //0=horizontal; 1=vertical
  this.dt_month01 = new Date(this.firstmonth.getTime());
  this.dt_month02 = new Date(this.firstmonth.getTime());
  this.dt_month03 = new Date(this.firstmonth.getTime());

  this.selectspan='';

  this.datelistfunction='';
  this.dcol=new Array();
}
DateArray.prototype.add=function(date,name) {
  var idx=this.array.length;
  this.array[idx]=new DateInteger(date,name);
  this.array[idx].index=idx;
  this.array[idx].arrayname=this.arrayname;
  return idx;
}
DateArray.prototype.adddateinteger=function(DateIntegerObject) {
  var idx=this.array.length;
  this.array[idx]=DateIntegerObject;
  this.array[idx].index=idx;
  this.array[idx].arrayname=this.arrayname;
  return idx;
}
DateArray.prototype.length=function() {
  return this.array.length;
}
DateArray.prototype.name=function(index) {
  var t='';
//  for (var i=0; i<this.array.length; i++)
//  if (this.array[i].permission==perm) t=this.array[i].name;
  if ((index>=0)&&(index<this.array.length))
  t=this.array[index].name;
  return t;
}
DateArray.prototype.date=function(idx) {
  var t='';
  if ((idx>=0)&&(idx<this.array.length))
  t=this.array[idx].date;
  return t;
}
DateArray.prototype.setselectspan=function(spanname) {
  this.selectspan=spanname;
  for (var i=0; i<this.array.length; i++)
  this.array[i].selectspanexists=(spanname!='');
}
DateArray.prototype.keypress=function(e,idx) {
  if (enterkeyevent(e)) this.enterclick(idx);
}
DateArray.prototype.focus=function(idx) {
  if (this.index==idx) return;
  
  this.index=idx;
  for (var i=0; i<this.array.length; i++)
  if (i==idx) {
    if (getid('_'+this.arrayname+'_dateinput_pijlspan_'+i)) getid('_'+this.arrayname+'_dateinput_pijlspan_'+i).innerHTML="&raquo;";
    if (getid('_'+this.arrayname+'_dateinput_input_'+i)) getid('_'+this.arrayname+'_dateinput_input_'+i).setAttribute("style",'background-color: #ccccff; width:'+this.array[idx].editwidth+'px;');
  } else {
    if (getid('_'+this.arrayname+'_dateinput_pijlspan_'+i)) getid('_'+this.arrayname+'_dateinput_pijlspan_'+i).innerHTML="&nbsp;";
    if (getid('_'+this.arrayname+'_dateinput_input_'+i)) getid('_'+this.arrayname+'_dateinput_input_'+i).setAttribute("style",'background-color: #ffffff; width:'+this.array[idx].editwidth+'px;');
  }

/*
  this.firstmonth.setTime(this.array[idx].date);
  this.firstmonth.setUTCHours(0,0,0,0);
  this.firstmonth.setUTCDate(1);
  if (getid(this.selectspan)) {
    getid(this.selectspan).innerHTML=this.makecalendar();
    getid("_'+this.arrayname+'_selecttitlespan").innerHTML=this.array[idx].selecttitle;
    this.calendarupdate();
  }
*/
}
DateArray.prototype.change=function(idx) {
  this.enterclick(idx);
}
DateArray.prototype.enterclick=function(idx) {
  this.array[idx].date=stringDate(getid('_'+this.arrayname+'_dateinput_input_'+idx).value);
  this.array[idx].write();
  if (this.array[idx].setdatefunction!='') eval(this.array[idx].setdatefunction);
}
DateArray.prototype.zeroclick=function(idx) {
  this.array[idx].date=0;
  this.array[idx].write();
  if (this.array[idx].setdatefunction!='') eval(this.array[idx].setdatefunction);
}
DateArray.prototype.todayclick=function(idx) {
  var d=new Date(); d.setUTCHours(0,0,0,0);
  this.array[idx].date=d.getTime();
  this.array[idx].write();
  if (this.array[idx].setdatefunction!='') eval(this.array[idx].setdatefunction);
}
DateArray.prototype.calenderclick=function(idx) {
  this.index=idx-1; //forces calendars to refresh
  this.focus(idx);

  if (this.array[idx].date==0) this.firstmonth.setTime(dt_current.getTime());
                          else this.firstmonth.setTime(this.array[idx].date);
  this.firstmonth.setUTCHours(0,0,0,0);
  this.firstmonth.setUTCDate(1);
  if (this.array[this.index].floating) {
    if (getid('_'+this.arrayname+'_dateinput_floatingspan_'+this.index)) {
      getid('_'+this.arrayname+'_dateinput_floatingspan_'+this.index).innerHTML=this.makecalendar();
//      getid('_'+this.arrayname+'_selecttitlespan').innerHTML=this.array[idx].selecttitle;
//      this.calendarupdate();
    }
    this.floatingcalendar_show(this.index);
    this.calendarupdate();
  } else {
    if (getid(this.selectspan)) {
      getid(this.selectspan).innerHTML=this.makecalendar();
      getid('_'+this.arrayname+'_selecttitlespan').innerHTML=this.array[idx].selecttitle;
      this.calendarupdate();
    }
  }
}
DateArray.prototype.dateclick=function(dat) {
  if ((this.index<0)||(this.index>=this.array.length)) return;
  
  this.array[this.index].date=dat;
  this.array[this.index].write();
  if (this.array[this.index].setdatefunction!='') eval(this.array[this.index].setdatefunction);

  if (this.array[this.index].floating)
  this.floatingcalendar_hide(this.index);
}

///////////////////////////////////////////////////////////// DateArray.calendar

DateArray.prototype.makecalendar=function() {
  var t = "";
  var ix='_0';

  if ((this.array[this.index].floating)||(!this.calendarsvertical)) { //horizontal
    if (this.array[this.index].floating) {
    t+='<div id="'+this.arrayname+'_floatholderdiv_'+this.index+'" style="position:relative;">'+
       '<div id="'+this.arrayname+'_floatdiv_'+this.index+'"'+
       ' style="position:absolute;'+
              ' left:'+this.array[this.index].floatingleft+'px;'+
              ' top:'+this.array[this.index].floatingtop+'px;'+
              ' width:'+(this.monthcount*this.array[this.index].floatingmonthwidth)+'px;'+
              ' height:'+this.array[this.index].floatingheight+'px;'+
              ' background-color:'+calendar_floatingbackgroundcolor+';'+
              ' border:1px solid #000000;'+
              ' display:none;'+
              ' z-index:99;'+
              '"'+
       '>';
      ix='_'+this.index;
    }
    t+='<table width="100%" cellspacing="0" cellpadding="0" border="0">';
    if (!this.array[this.index].floating)
    t+='<tr class="tr_boxtitel"><td colspan="3"><b>&nbsp;<span id="_'+this.arrayname+'_selecttitlespan"></span></b></td></tr>';
    t+='<tr>'+
         '<td align="left">';
    if (this.monthcount>2)
        t+='<table cellspacing="0" cellpadding="0" border="0">'+
           '<tr>'+
             '<td>&nbsp;</td>'+
             '<td class="td_kalender_navigatieknop" onclick="javascript:'+this.arrayname+'.calendarnavigation(-3)">&nbsp;'+rss(rss3MonthBack_L)+'&nbsp;</td>'+
           '</tr>'+
           '</table>';
      t+='</td>'+
         '<td align="center">'+
           '<table>'+
           '<tr>'+
             '<td width="16"><a href="javascript:'+this.arrayname+'.calendarnavigation(-12)"><img title="'+rss(rssYearBack_L)+'" src="'+common_path+'img/JaarTerug.gif" border="0"></a></td>'+
             '<td width="16"><a href="javascript:'+this.arrayname+'.calendarnavigation(-1)"><img title="'+rss(rssMonthBack_L)+'" src="'+common_path+'img/MaandTerug.gif" border="0"></a></td>'+
             '<td width="16"><a href="javascript:'+this.arrayname+'.calendarnavigation(0)"><img title="'+rss(rssThisMonth_L)+'" src="'+common_path+'img/DezeMaand.gif" border="0"></a></td>'+
             '<td width="16"><a href="javascript:'+this.arrayname+'.calendarnavigation(1)"><img title="'+rss(rssMonthForward_L)+'" src="'+common_path+'img/MaandVerder.gif" border="0"></a></td>'+
             '<td width="16"><a href="javascript:'+this.arrayname+'.calendarnavigation(12)"><img title="'+rss(rssYearForward_L)+'" src="'+common_path+'img/JaarVerder.gif" border="0"></a></td>';
    if (this.array[this.index].floating)
          t+='<td width="16"><a href="javascript:'+this.arrayname+'.floatingcalendar_hide('+this.index+')"><img title="'+rss(rssCloseCalendar_L)+'" src="'+common_path+'img/cal_sluiten.gif" border="0"></a></td>';
    else
          t+='<td width="16"><a href="javascript:'+this.arrayname+'.calendarupdate()"><img title="'+rss(rssRefresh_L)+'" src="'+common_path+'img/Ververs.gif" border="0"></a></td>';
        t+='</tr>'+
           '</table>'+
         '</td>'+
         '<td align="right">';
    if (this.monthcount>2)
        t+='<table cellspacing="0" cellpadding="0" border="0">'+
           '<tr>'+
             '<td class="td_kalender_navigatieknop" onclick="javascript:'+this.arrayname+'.calendarnavigation(3)">&nbsp;'+rss(rss3MonthForward_L)+'&nbsp;</td>'+
             '<td>&nbsp;</td>'+
           '</tr>'+
           '</table>';
      t+='</td>'+
       '</tr>'+
       '</table>';
    t+='<table width="100%" cellspacing="0" cellpadding="0" border="0">'+
       '<tr>'+
         '<td>'+
           '<span id="_'+this.arrayname+'_maand01span'+ix+'"></span>'+
         '</td>'+
         '<td>';
    if (this.monthcount>1)
        t+='<span id="_'+this.arrayname+'_maand02span'+ix+'"></span>';
      t+='</td>'+
         '<td>';
    if (this.monthcount>2)
        t+='<span id="_'+this.arrayname+'_maand03span'+ix+'"></span>';
      t+='</td>'+
       '</tr>'+
       '</table>';
    if (this.array[this.index].floating)
    t+='</div>'+
       '</div>';
  } else { //vertical
    t ='<table width="100%" cellspacing="0" cellpadding="0" border="0">'+
       '<tr class="tr_boxtitel"><td><b>&nbsp;<span id="_'+this.arrayname+'_selecttitlespan"></span></b></td></tr>'+
       '<tr>'+
         '<td>'+
           '<table>'+
           '<tr>'+
             '<td width="16"><a href="javascript:'+this.arrayname+'.calendarnavigation(-12)"><img title="'+rss(rssYearBack_L)+'" src="'+common_path+'img/JaarTerug.gif" border="0"></a></td>'+
             '<td width="16"><a href="javascript:'+this.arrayname+'.calendarnavigation(-1)"><img title="'+rss(rssMonthBack_L)+'" src="'+common_path+'img/MaandTerug.gif" border="0"></a></td>'+
             '<td width="16"><a href="javascript:'+this.arrayname+'.calendarnavigation(0)"><img title="'+rss(rssThisMonth_L)+' ('+veldlijstWaarde(rss(rssMonthNameList),dt_current.getUTCMonth())+' '+dt_current.getUTCFullYear()+')'+'" src="'+common_path+'img/DezeMaand.gif" border="0"></a></td>'+
             '<td width="16"><a href="javascript:'+this.arrayname+'.calendarnavigation(1)"><img title="'+rss(rssMonthForward_L)+'" src="'+common_path+'img/MaandVerder.gif" border="0"></a></td>'+
             '<td width="16"><a href="javascript:'+this.arrayname+'.calendarnavigation(12)"><img title="'+rss(rssYearForward_L)+'" src="'+common_path+'img/JaarVerder.gif" border="0"></a></td>'+
             '<td width="16"><a href="javascript:'+this.arrayname+'.calendarupdate()"><img title="'+rss(rssRefresh_L)+'" src="'+common_path+'img/Ververs.gif" border="0"></a></td>'+
           '</tr>'+
           '</table>'+
         '</td>'+
       '</tr>'+
       '<tr><td><span id="_'+this.arrayname+'_maand01span'+ix+'"></span></td></tr>';
    if (this.monthcount>1)
    t+='<tr><td><span id="_'+this.arrayname+'_maand02span'+ix+'"></span></td></tr>';
    if (this.monthcount>2)
    t+='<tr><td><span id="_'+this.arrayname+'_maand03span'+ix+'"></span></td></tr>';
    t+='</table>';
  }

  return t;
}
DateArray.prototype.calendarnavigation=function(move) {
  if (move==0) {
    this.firstmonth = new Date();
    this.firstmonth.setUTCHours(0,0,0,0);
    this.firstmonth.setUTCDate(1);
  }
  this.firstmonth.setUTCMonth(this.firstmonth.getUTCMonth()+move);
  this.do_navigatie(this.index);
}
DateArray.prototype.calendarupdate=function() {
  if (getid(this.selectspan)) this.do_navigatie(this.index);
}
DateArray.prototype.do_navigatie=function(idx) {
  if (idx==null) idx=0;
  var ix='_0';
  if (this.array[idx].floating) ix='_'+idx;
//  getid("mededeling").innerHTML="&nbsp;De jaarkalender wordt geladen. Even geduld a.u.b. ...";

  this.dt_month01 = new Date(this.firstmonth.getTime());
  this.dt_month02 = new Date(this.dt_month01.getTime());
  this.dt_month02.setUTCMonth(this.dt_month02.getUTCMonth() + 1);
  this.dt_month03 = new Date(this.dt_month02.getTime());
  this.dt_month03.setUTCMonth(this.dt_month03.getUTCMonth() + 1);
  getid('_'+this.arrayname+'_maand01span'+ix).innerHTML=
    '<table cellspacing="0" border="0" width="200">'
   +'<tr><td width="100%" class="td_kalender_maandjaar" style="color:#ffffff;">&nbsp;'+veldlijstWaarde(rss(rssMonthNameList),this.dt_month01.getUTCMonth())+' '+this.dt_month01.getUTCFullYear()+'</td></tr>'
   +'<tr><td>&nbsp;'+rss(rssIsBeingUpdated_D_L)+'</td></tr>'
   +'</table>';
  if (this.monthcount>1)
  getid('_'+this.arrayname+'_maand02span'+ix).innerHTML=
    '<table cellspacing="0" border="0" width="200">'
   +'<tr><td width="100%" class="td_kalender_maandjaar" style="color:#ffffff;">&nbsp;'+veldlijstWaarde(rss(rssMonthNameList),this.dt_month02.getUTCMonth())+' '+this.dt_month02.getUTCFullYear()+'</td></tr>'
   +'<tr><td>&nbsp;'+rss(rssIsBeingUpdated_D_L)+'</td></tr>'
   +'</table>';
  if (this.monthcount>2)
  getid('_'+this.arrayname+'_maand03span'+ix).innerHTML=
    '<table cellspacing="0" border="0" width="200">'
   +'<tr><td width="100%" class="td_kalender_maandjaar" style="color:#ffffff;">&nbsp;'+veldlijstWaarde(rss(rssMonthNameList),this.dt_month03.getUTCMonth())+' '+this.dt_month03.getUTCFullYear()+'</td></tr>'
   +'<tr><td>&nbsp;'+rss(rssIsBeingUpdated_D_L)+'</td></tr>'
   +'</table>';
  if (this.datelistfunction!='') this.dcol=eval(this.datelistfunction);
                            else this.dcol.length=0;
  getid('_'+this.arrayname+'_maand01span'+ix).innerHTML=this.makemonthcalendar(this.dt_month01);
  if (this.monthcount>1)
  getid('_'+this.arrayname+'_maand02span'+ix).innerHTML=this.makemonthcalendar(this.dt_month02);
  if (this.monthcount>2)
  getid('_'+this.arrayname+'_maand03span'+ix).innerHTML=this.makemonthcalendar(this.dt_month03);
}
DateArray.prototype.makemonthcalendar=function(dtm) {
  var cursor = '';
  if (Microsoft) cursor=' style="cursor:hand"';
  var res = "";
  // calendar
  res+='<table class="table_kalender" cellspacing="1" cellpadding="0" border="0">';

  //month and year
  res+='<tr><td class="td_kalender_maand" colspan="8">&nbsp;'+veldlijstWaarde(rss(rssMonthNameList),dtm.getUTCMonth())+' '+dtm.getUTCFullYear()+'</td></tr>';

  // day names
  res+='<tr><td class="td_kalender_week">'+rss(rssWeek_A_L)+'</td>';
  for (var n=0; n<7; n++) res+='<td class="td_kalender_week">'+veldlijstWaarde(rss(rssDayCodeList),(NUM_WEEKSTART+n)%7)+'</td>';
  res+='</tr>';

  // days
  var dt_monthfirstday = new Date(dtm.getTime());
  dt_monthfirstday.setUTCDate(1 - (7 + dt_monthfirstday.getUTCDay() - NUM_WEEKSTART) % 7);
  var dt_current_day = new Date(dt_monthfirstday.getTime());
  var dt_current_day6 = new Date(dt_monthfirstday.getTime());
  dt_current_day6.setUTCDate(dt_current_day.getUTCDate()+6);
  var bcol = calendar_daycolor;
  var bbcol = calendar_daycolor;
  var fcol = calendar_textcolor;
  var txt=txt2="";
  for (var w=0; w<6; w++) {
    // print row header
    res+='<tr>';
    res+='<td class="td_kalender_nummer">';
    res+=dt_current_day.getWeekNumber();
    res+='</td>';
    for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
      //initialize colors
      bcol=calendar_daycolor; bbcol=calendar_daycolor;
      
      //check date colors
      for (var i=0; i<this.dcol.length; i++)
      if (this.dcol[i].date==dateString(dt_current_day.valueOf())) {
        bcol=this.dcol[i].color;
        bbcol=this.dcol[i].bcolor;
      }
      //set colors for date is in other than current month
      if (dt_current_day.getUTCMonth()!=dtm.getUTCMonth()) { bcol=calendar_othercolor; bbcol=calendar_othercolor; }

      //background color
      if (dt_current_day.getUTCDay() == 0 || dt_current_day.getUTCDay() == 6) // weekend day
      if (dt_current_day.getUTCMonth() == dtm.getUTCMonth()) { // of current month
        if (bcol==calendar_daycolor) bcol=calendar_weekendcolor;
        if (bbcol==calendar_daycolor) bbcol=calendar_weekendcolor;
      }

      txt=getfeestdag(dt_current_day.getTime());
      if (txt!='') {
        if (bcol==calendar_daycolor) bcol=calendar_weekendcolor;
        if (bbcol==calendar_daycolor) bbcol=calendar_weekendcolor;
      }

      txt2=getvakantie(dt_current_day.getTime());
      if (txt2!='') {
        if (bcol==calendar_daycolor) bcol=calendar_holidaycolor;
        if (bbcol==calendar_daycolor) bbcol=calendar_holidaycolor;
        if (txt!='') txt+=', ';
        txt+=txt2;
      }

      if (dt_current_day.getUTCDate() == dt_current.getUTCDate() &&
          dt_current_day.getUTCMonth() == dt_current.getUTCMonth() &&
          dt_current_day.getUTCFullYear() == dt_current.getUTCFullYear())
      // current date
        fcol=calendar_todaytextcolor;
      else
      if ((dt_current_day.getUTCDay()==0)||(dt_current_day.getUTCDay()==6))
        // weekend day
        if (dt_current_day.getUTCMonth()==dtm.getUTCMonth()) fcol=calendar_weekendtextcolor; // of current month
                                                        else fcol=calendar_otherweekendtextcolor; // of other month
      else
        // working day
        if (dt_current_day.getUTCMonth()==dtm.getUTCMonth()) fcol=calendar_textcolor; // of current month
                                                        else fcol=calendar_othertextcolor; // of other month

      res+='<td class="td_kalender_dag" style="background-color:'+bcol+'; border-bottom-color:'+bbcol+'; color:'+fcol+';" onclick="javascript:'+this.arrayname+'.dateclick('+dt_current_day.valueOf()+')"';
      if (txt!='') res+=' title="'+txt+'"';
      res+='>';

      if (dt_current_day.getUTCMonth() == dtm.getUTCMonth())
        res+=dt_current_day.getUTCDate();
      else
        res+='&nbsp;';
      res+='</td>';
      dt_current_day.setUTCDate(dt_current_day.getUTCDate()+1);
    }
    // print row footer
    res+='</tr>';
    dt_current_day6.setUTCDate(dt_current_day.getUTCDate()+6);
  }
  res+='</table>';
  return res;
}
DateArray.prototype.floatingcalendar_show=function(idx) {
  if (getid(this.arrayname+'_floatdiv_'+idx)) {
    getid(this.arrayname+'_floatdiv_'+idx).style.display='inline';
    this.do_navigatie(idx);
  }
}
DateArray.prototype.floatingcalendar_hide=function(idx) {
  if (getid(this.arrayname+'_floatdiv_'+idx)) getid(this.arrayname+'_floatdiv_'+idx).style.display='none';
}


