  //-------------------------------------------------------------------------------------------------------------------------
  // functions for the separate date input control
  //-------------------------------------------------------------------------------------------------------------------------

  function handleYearSelection( yearElement, monthElementName, dayElementName, hasMonthValue, allowFutureDates, allowPastDates ) {
      var i = null;
      var option = null;
      var now = new Date();
      var monthElement = document.getElementById( monthElementName )
      var dayElement = document.getElementById( dayElementName );
      var selectedYear = yearElement.options[yearElement.selectedIndex].value;

      if( yearElement.selectedIndex != 0 ) {
          if( monthElement ) {
              monthElement.disabled = false;
          }

          if( hasMonthValue && dayElement ) {
              dayElement.disabled = false;
          }

          if( !allowFutureDates ) {
              if( selectedYear == now.getYear()) {
                  i = now.getMonth();
                  for( i; i > 0; i-- ) {
                      option = monthElement.options[i];
                      option.style.color = '#A0A0A0';
                  }
              }
              else {
                  i = 1;
                  for( i; i < 13; i++ ) {
                      option = monthElement.options[i];
                      option.style.color = '#000000';
                  }

                  i = 1;
                  for( i; i < 32; i++ ) {
                      option = dayElement.options[i];
                      option.style.color = '#000000';
                  }
              }
          }

          if( !allowPastDates ) {
              if( selectedYear == now.getYear()) {
                  i = now.getMonth()+2;
                  for( i; i < 13; i++ ) {
                      option = monthElement.options[i];
                      option.style.color = '#A0A0A0';
                  }
              }
              else {
                  i = 1;
                  for( i; i < 13; i++ ) {
                      option = monthElement.options[i];
                      option.style.color = '#000000';
                  }

                  i = 1;
                  for( i; i < 32; i++ ) {
                      option = dayElement.options[i];
                      option.style.color = '#000000';
                  }
              }
          }
      }
      else {
          if( monthElement ) {
              monthElement.disabled = true;
              monthElement.selectedIndex = 0;
          }

          if( dayElement ) {
              dayElement.disabled = true;
              dayElement.selectedIndex = 0;
          }
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function handleMonthSelection( yearElementName, monthElement, dayElementName, allowFutureDates, allowPastDates ) {
      var i = null;
      var option = null;
      var now = new Date();
      var yearElement = document.getElementById( yearElementName );
      var dayElement = document.getElementById( dayElementName );
      var selectedYear = yearElement.options[yearElement.selectedIndex].value;
      var selectedMonth = monthElement.options[monthElement.selectedIndex].value;

      if( monthElement.selectedIndex != 0 ) {
          if( dayElement ) {
              dayElement.disabled = false;

              if( !allowFutureDates ) {
                  if( (selectedYear == now.getYear()) && (selectedMonth < now.getMonth()+1) ) {
                      monthElement.selectedIndex = 0;
                      dayElement.selectedIndex = 0;
                      dayElement.disabled = true;
                  }
                  else {
                      if( (selectedYear == now.getYear()) && (selectedMonth == now.getMonth()+1) ) {
                          i = now.getDate()-1;
                          for( i; i > 0; i-- ) {
                              option = dayElement.options[i];
                              option.style.color = '#A0A0A0';
                          }
                      }
                      else {
                          i = 1;
                          for( i; i < 32; i++ ) {
                              option = dayElement.options[i];
                              option.style.color = '#000000';
                          }
                      }
                  }
              }

              if( !allowPastDates ) {
                  if( (selectedYear == now.getYear()) && (selectedMonth > now.getMonth()+1) ) {
                      this.selectedIndex = 0;
                      dayElement.selectedIndex = 0;
                      dayElement.disabled = true;
                  }
                  else {
                      if( (selectedYear == now.getYear()) && (selectedMonth == now.getMonth()+1) ) {
                          i = now.getDate()+1;
                          for( i; i < 32; i++ ) {
                              option = dayElement.options[i];
                              option.style.color = '#A0A0A0';
                          }
                      }
                      else {
                          i = 1;
                          for( i; i < 32; i++ ) {
                              option = dayElement.options[i];
                              option.style.color = '#000000';
                          }
                      }
                  }
              }
          }
      }
      else {
          if( dayElement ) {
              dayElement.disabled = true;
              dayElement.selectedIndex = 0;
          }
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function handleDaySelection( yearElementName, monthElementName, dayElement, allowFutureDates, allowPastDates ) {
      var option = null;
      var now = new Date();
      var yearElement = document.getElementById( yearElementName );
      var monthElement = document.getElementById( monthElementName );
      var selectedYear = yearElement.options[yearElement.selectedIndex].value;
      var selectedMonth = monthElement.options[monthElement.selectedIndex].value;
      var selectedDay = dayElement.options[dayElement.selectedIndex].value;

      if( !allowFutureDates ) {
          if( (selectedYear == now.getYear()) && (selectedMonth == now.getMonth()+1) && (selectedDay < now.getDate())) {
              dayElement.selectedIndex = 0;
          }
      }

      if( !allowPastDates ) {
          if( (selectedYear == now.getYear()) && (selectedMonth == now.getMonth()+1) && (selectedDay > now.getDate())) {
              dayElement.selectedIndex = 0;
          }
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------
  //-------------------------------------------------------------------------------------------------------------------------

  function confirmDestructiveAction( anUrl, aShouldUseXMLHTTP, aMessage  ) {
      if( confirm( aMessage )) {
          if( aShouldUseXMLHTTP ) {
              sendRequest( anUrl, "" );
          }
          else
              window.location.href = anUrl;
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function isInternetExplorer() {
      var browser=navigator.appName;
      return ( browser.toLowerCase() != "netscape" );
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function sendNavigatorRequest( anElement, anURL, aContext, aNoBorderChange ) {
      if( (aNoBorderChange == null) || aNoBorderChange ) {
          if( (anElement.type == "th") && isInternetExplorer() && anElement.filters ) {
              var filter = anElement.filters( "DXImageTransform.Microsoft.Gradient" );

              if( filter && filter.enabled ) {
                  filter.EndColorStr = ( filter.EndColor > filter.StartColor ) ? "#FFFFFF" : "#C0C0C0";
                  filter.StartColorStr = ( filter.EndColor > filter.StartColor ) ? "#C0C0C0" : "#FFFFFF";
              }
              else {
                  anElement.style.borderStyle="solid";
                  anElement.style.borderWidth="1px;";
                  anElement.style.borderColor="#636E87";
              }
          }
          else {
              anElement.style.borderStyle="solid";
              anElement.style.borderColor="#636E87";
          }
      }

      sendRequest( anURL, aContext );
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function mouse_over( element ) {
       element.style.border="1px solid #636E87";
       element.style.backgroundColor="DEDEEB";
       element.style.paddingBottom="2px";
       element.style.paddingTop="0px";
       element.style.paddingRight="0px";
       element.style.paddingLeft="0px";
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function mouse_out( element, color ) {
      element.style.border="1px";
      element.style.borderColor=color;
      element.style.backgroundColor=color;
      element.style.paddingBottom="3px";
      element.style.paddingTop="1px";
      element.style.paddingRight="1px";
      element.style.paddingLeft="1px";
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function movebox( e, activeField, nextField, maxlen ) {
      var evnt = (!e) ? window.event : e;

      var activeElement = document.getElementById( activeField );
      var nextElement = document.getElementById( nextField );
      if( nextElement != null ) {
          if((activeElement.value.length == maxlen) && (evnt.keyCode != 9) && (evnt.keyCode != 16)) {
              nextElement.focus();
          }
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function setDefaultYearValue( e, dayObject, monthObject, yearObject ) {
      var evnt = (!e) ? window.event : e;

      var dayElement = document.getElementById( dayObject );
      var monthElement = document.getElementById( monthObject );
      var yearElement = document.getElementById( yearObject );

      if( ( yearElement.value.length == 0 ) && ( dayElement.value.length > 0 ) && ( monthElement.value.length > 0 )) {
          if(( evnt.toElement == null ) || ((evnt.toElement.name != monthObject) && (evnt.toElement.name != dayObject) && (evnt.toElement.name != yearObject)) ){
              d = new Date();
              yearElement.value = d.getFullYear();
          }
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function doExpandOrCollapse( cellName, url, className, isNode ) {
      var cell = document.getElementById( cellName );
      var row = cell.parentNode;
      var detailsRow = document.getElementById( cell.id + "_details" );

      if( detailsRow != null ) {
          detailsRow.style.display=detailsRow.style.display == "none" ? "" : "none";

          var image = document.getElementById( row.id + "_img" );
          if( image != null ) {
              if( detailsRow.style.display == '' ) {
                  image.src = "/displayers/../misc/resources/collapse_node.gif";
              }
              else
                  image.src = "/displayers/../misc/resources/expand_node.gif";
          }
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function doShowDetails( cellName, url, className, isNode, mayUpdateLinks ) {
      var cell = document.getElementById( cellName );
      var row = cell.parentNode;
      var table = row.parentNode;
      if( isNode ) {
          var image = document.getElementById( row.id + "_img" );
          if( image != null ) {
              image.src = "/displayers/../misc/resources/collapse_node.gif";
          }

          // TODO, GR: Remove a.s.a.p. ...this code is Sundio specific.
          if( (mayUpdateLinks == null) || mayUpdateLinks ) {
              var link = document.getElementById( cellName + "_link" );
              if( (link != null) && (link.style.textDecoration != "none")) {
                  link.style.textDecoration = "none";
                  link.style.color = "black";
                  link.removeAttribute( "href" );
              }
              else {
                  if( (link != null) && (link.style.textDecoration == "none") && (link.tag != null)) {
                      link.href = link.tag;
                      link.removeAttribute( "style" );
                  }
              }
          }
      }
      if( document.getElementById( cell.id + "_details" ) == null ) {
          var newRow = table.insertRow( row.rowIndex + 1 );
          newRow.id = cell.id + "_details";
          newRow.className = className;
          newRow.style.display = "";
          var newCell = newRow.insertCell(-1);
          newCell.colSpan=row.cells.length;
          newCell.className = className;
          newCell.id = newRow.id + "_content";
          sendRequest( url, newCell.id, null, null, true, isNode, true );
      }
      else {
          if( isNode && (image != null) ) {
              image.src = "/displayers/../misc/resources/expand_node.gif";
          }

          table.deleteRow( row.rowIndex + 1 );

          if( isNode ) {
              sendRequest( url, cell.id, null, null, true, isNode, true );
          }
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function doCancelBubble() {
      if( !e ) {
          var e = window.event;
      }
      try {
          e.cancelBubble = true;
      } catch( exception ) {
          try {
              e.stopPropagation();
          } catch( exception ) {}
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function doDisableButton( buttonElement, className ) {
      // INFO, GR: I would like to remove the onClick event from the element,
      //      instead of disabling it. Disabling the button embosses the button text.

      buttonElement.disabled = true;
      buttonElement.className = className;
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function getClientWidth() {
      if( typeof( window.innerWidth ) == "number" ) {
          return window.innerWidth;
      } else if( document.body && document.body.clientWidth ) {
          return document.body.clientWidth;
      } else if( document.documentElement && document.documentElement.clientWidth ) {
          return document.documentElement.clientWidth;
      }
      else
          return 0;
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function getClientHeight() {
      if( typeof( document.scrollHeight ) == "number" ) {
          return document.scrollHeight;
      } else if( document.body && document.body.scrollHeight ) {
          return document.body.scrollHeight;
      } else if( document.documentElement && document.documentElement.scrollHeight ) {
          return document.documentElement.scrollHeight;
      }
      else
          return 0;
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function getScrollX() {
      var scrOfX = 0;
      if( typeof( window.pageYOffset ) == "number" ) {
          scrOfX = window.pageXOffset;
      } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
          scrOfX = document.body.scrollLeft;
      } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
          scrOfX = document.documentElement.scrollLeft;
      }
      return scrOfX;
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function getScrollY() {
      var scrOfY = 0;
      if( typeof( window.pageYOffset ) == "number" ) {
          scrOfY = window.pageYOffset;
      } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
          scrOfY = document.body.scrollTop;
      } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
          scrOfY = document.documentElement.scrollTop;
      }
          return scrOfY;
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function handleWindowResize() {
      var popupMask = document.getElementById( "ecl_popup_context_mask" );
      if( (popupMask != null) && (popupMask.style.visibility == "visible")) {
          popupMask.style.width = getClientWidth();
          popupMask.style.height = getClientHeight();
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function showFloatingContext( obj, url, center, topMargin ) {
      var objct = document.getElementById( obj );
      var popupMask = document.getElementById( "ecl_popup_context_mask" );
      if( popupMask != null ) {
          popupMask.style.width = getClientWidth() + 'px';
          popupMask.style.height = getClientHeight() + 'px';

          if( popupMask.style.visibility != "visible" ) {
              popupMask.style.visibility = "visible";
          }
      }
      objct.innerHTML = "";
      if( center ) {
          objct.style.top = getScrollY();
      }

      sendRequest( url, objct.id, null, null, true, null, true );

      objct.style.height = "auto";
      if( topMargin ) {
          objct.style.marginTop = topMargin + "px";
      }
      else
          objct.style.marginTop = "100px";
      objct.style.left = Math.round( (getClientWidth() - objct.clientWidth) / 2 );
      objct.style.visibility = /*(objct.style.visibility == "visible") ? "hidden" :*/ "visible";
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function hideFloatingContext( obj, clearMaskOnly, leavePopupMask ) {
      if( !clearMaskOnly ) {
          var objct = document.getElementById( obj );
          if( objct != null ) {
              var shadow = document.getElementById( objct.id + ".shadow" );
              if( shadow ) {
                  shadow.style.visibility = "hidden";
              }

              objct.innerHTML = "";
              objct.style.visibility = "hidden";
              objct.style.left = "0px";
          }
      }
      if( !leavePopupMask ) {
          hidePopupContextMask();
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function hidePopupContextMask() {
      var popupMask = document.getElementById( "ecl_popup_context_mask" );

      if( popupMask != null ) {
          document.body.style.cursor = "auto";
          popupMask.style.visibility = "hidden";
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function setElementFocus( elementName, formName ) {
      var element = null;

      if( formName ) {
          var form = document.getElementById( formName );

          if( form ) {
              element = form.elements[elementName];
          }
      }

      if( element == null ) {
          element = document.getElementById( elementName );
      }

      if( element != null ) {
          try{
              element.focus();

              if( element.type != "button" ) {
                  element.select();
              }
          }
          catch(e) {
          }
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------`

  function replaceElementText( elementName, text ) {
      var element = document.getElementById( elementName );

      if( element ) {
          if( document.all ) {
              element.innerText = text;
          }
          else
              element.textContent = text;
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------
  // Calendar
  //-------------------------------------------------------------------------------------------------------------------------

  var calendar;

  function initializeCalendar( name, date, allowPast, dateControlName, allowFuture ) {
      var selectedDate = date != null ? new Date( date ) : new Date();
      var node = document.getElementById( name )

      calendar = new Calendar( node, allowPast, allowFuture );
      calendar.originalDate = new Date( date );
      calendar.dateControlName = dateControlName;
      calendar.setDate( selectedDate, allowPast, allowFuture );

      return calendar;
  }

  //-------------------------------------------------------------------------------------------------------------------------

  function Calendar( node, allowPast, allowFuture ) {
      this.container = node;
      this.allowPast = allowPast;
      this.allowFuture = allowFuture;
      this.currentCell = null;
      this.originalDate = null;
      this.dateControlName = null;
      this.selectedColor = "#84C0FC";
      this.hoverColor = "#FD6E22";
      this.weekendColor = "#F2F2F7";
      this.workdayColor = "#FFFFFF";

      this.table = node.getElementsByTagName( "table" )[0];
      this.body = node.getElementsByTagName( "tbody" )[0];

      if( window.addEventListener ) {
          this.table.addEventListener( "mousedown", this.scope( this.getDate ), false );
          this.table.addEventListener( "mousemove", this.scope( this.hoverDate ), false );
      }
      else {
          this.table.attachEvent( "onclick", this.scope( this.getDate ));
          this.table.attachEvent( "onmousemove", this.scope( this.hoverDate ));
      }

      var selects = node.getElementsByTagName( "select" );

      for( var i=0; i<selects.length; i++) {
          if( window.addEventListener ) {
              selects[i].addEventListener( "change", this.scope( this.upDate ), false);
          }
          else
              selects[i].attachEvent( "onchange", this.scope( this.upDate ));
      }

      var now = new Date();
      this.now = new Date(now.getFullYear(), now.getMonth(), now.getDate());
      this.chooseDate( selects[0], allowPast, allowFuture );
  }

  //-------------------------------------------------------------------------------------------------------------------------

  Calendar.prototype = {
      setColors:function( selectedColor, hoverColor, weekendColor, workdayColor ) {
          this.selectedColor = selectedColor || this.selectedColor;
          this.hoverColor = hoverColor || this.hoverColor;
          this.weekendColor = weekendColor || this.weekendColor;
          this.workdayColor = workdayColor || this.workdayColor;
      },

      //--------------------------------------

      upDate:function( e ) {
          var target = e.target || e.srcElement;

          if( target ) {
              this.chooseDate(target, this.allowPast, this.allowFuture );
          }
      },

      //--------------------------------------

      chooseDate:function( target, allowPast, allowFuture ) {
          if( /year|month/i.test( target.className )) {
              var selects = target.parentNode.getElementsByTagName( "select" );
              var year = parseInt( selects[0].value, 10 );
              var month = parseInt( selects[1].value, 10 )-1;
          } else {
              var date = target.value.split( "/" );
              var year = parseInt( date[0], 10 );
              var month = parseInt( date[1] || 1, 10 )-1;
          }

          this.setDate( new Date(year, month, 1 ), allowPast, allowFuture);
      },

      //--------------------------------------

      setSelects:function() {
          function selectValue( select, value ) {
              for( var i=0; i<select.options.length; i++ ) {
                  if( select.options[i].value == value ) {
                      select.selectedIndex = i;
                      break;
                  }
              }
          }

          var date = this.selectedDate;
          var selects = this.container.getElementsByTagName( "select" );

          if( this.allowPast ) {
              selectValue( selects[0], date.getFullYear() );
              selectValue( selects[1], date.getMonth()+1 );
          } else {
              var s = date.getFullYear() + '/' + /[0-9]{2}$/.exec( '0' + (date.getMonth()+1))[0] + '/01';
              selectValue( selects[0], s );
          }
      },

      //--------------------------------------

      setDate:function( date, allowPast, allowFuture ) {
          this.currentDate = date;
          this.currentMonth = date.getMonth();
          this.currentYear = date.getFullYear();
          this.selectedDate = new Date(date.getTime());
          this.setSelects();
          this.createTable( allowPast, allowFuture );
      },

      //--------------------------------------

      hoverDate:function( e ) {
          var target = e.target || e.srcElement;
          var day = target.innerHTML;
          var previousDay = this.currentCell ? this.currentCell.innerHTML : '';
          var selectedDay = this.selectedDate.getDate();
          var selectedYear = this.selectedDate.getFullYear();
          var selectedMonth = this.selectedDate.getMonth();

          if( this.currentCell && (!target || target != this.currentCell)) {
              if(/td/i.test( this.currentCell.nodeName ) && /^[0-9]+$/.test( day ) && !/ecl_calendar_weekend/.test( this.currentCell.className )) {
                  if((selectedDay == previousDay ) && (selectedYear == this.currentYear) && (selectedMonth == this.currentMonth )) {
                      this.currentCell.style.backgroundColor = this.selectedColor;
                  }
                  else
                      this.currentCell.style.backgroundColor = this.workdayColor;
              }
              else if( /ecl_calendar_weekend/.test( this.currentCell.className )) {
                  if((selectedDay == previousDay ) && (selectedYear == this.currentYear) && (selectedMonth == this.currentMonth )) {
                      this.currentCell.style.backgroundColor = this.selectedColor;
                  }
                  else
                      this.currentCell.style.backgroundColor = this.weekendColor;
              }
              else {
                  if((selectedDay == previousDay ) && (selectedYear == this.currentYear) && (selectedMonth == this.currentMonth )) {
                      this.currentCell.style.backgroundColor = this.selectedColor;
                  }
                  else
                      this.currentCell.style.backgroundColor = this.workdayColor;
              }
          }

          if( /td/i.test( target.nodeName ) && /^[0-9]+$/.test( day ) && !/ecl_calendar_past/.test( target.className )) {
              this.currentCell = target
              target.style.backgroundColor = this.hoverColor;
          }
      },

      //--------------------------------------

      getDate:function( e ){
          var target = e.target || e.srcElement;
          var day = target.innerHTML;

          if( /td/i.test( target.nodeName ) && /^[0-9]+$/.test( day ) && !/ecl_calendar_past/.test( target.className )) {
              try {
                  newDate = new Date(this.currentYear, this.currentMonth, day );
                  this.setDate( newDate, this.allowPast, this.allowFuture );

                  if( this.dateControlName != "" ) {
                      var dayControl = document.getElementById( this.dateControlName + "_day" );
                      var monthControl = document.getElementById( this.dateControlName + "_month" );
                      var yearControl = document.getElementById( this.dateControlName + "_year" );

                      dayControl.value = day;
                      monthControl.value = this.currentMonth+1;
                      yearControl.value = this.currentYear;

                      try {
                          if( this.container.parentElement ) {
                              var calendarRow = this.container.parentElement.parentElement;
                          }
                          else
                              var calendarRow = this.container.parentNode.parentNode;

                          calendarRow.style.display = calendarRow.style.display == "none" ? "" : "none";
                      }
                      catch(e) {}
                  }
                  else {
                      var dayControl = document.getElementById( this.container.id + "_day" );

                      dayControl.value = day;
                  }
              }
              catch( actionException ) {
                  // TODO, GR: Raise exception?
              }
          }
      },

      //--------------------------------------

      createTable:function( allowPast, allowFuture ) {
          var date = this.currentDate;

          date.setDate(1);
          var day, row, cell, endmode = false;
          var month = date.getMonth();
          var first = date.getDay();
          var days = first + 42;
          var body = document.createElement( "tbody" );

          this.currentCell = null;
          this.table.removeChild( this.body );
          this.body = this.table.appendChild( body );

          for( var i=0; i<days; i++ ) {
              day = i+1 - first;
              date.setMonth( month );

              if( day > 0 ) {
                  date.setDate( day );

                  if( date.getMonth() != month ) {
                      day = ' ', endmode = true;
                  }
              }
              else
                  day = ' ';

              if( i%7 == 0 ) {
                  if( endmode ) {
                      break;
                  }

                  row = this.body.insertRow( i/7 );
              }

              cell = row.insertCell(i%7)
              cell.align = "center";
              cell.innerHTML = day;

              if((date > this.now) && ((allowFuture == "false") || !allowFuture)) {
                  cell.className = 'ecl_calendar_past';
              }

              if((date < this.now) && ((allowPast == "false") || !allowPast)) {
                  cell.className = 'ecl_calendar_past';
              }

              if( (day > 1) && (Math.abs( this.selectedDate - date ) < 86400000) ) {
                  cell.className += ' ecl_calendar_today';
              }

              if( i%7 == 0 || i%7 == 6 ) {
                  cell.className += ' ecl_calendar_weekend';
              }
          }
      },

      //--------------------------------------

      scope:function( method ) {
          var scope = this;

          return function() {
              return method.apply( scope, arguments );
          }
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------
  // TODO, GR: The following functions are Zoover specific and need refactoring
  //-------------------------------------------------------------------------------------------------------------------------

  function loadCropScripts( aCallBack ) {
      LazyLoad.load( ['/misc/cropper/prototype.js', '/misc/cropper/builder.js', '/misc/cropper/dragdrop.js', '/misc/cropper/cropper.js'], aCallBack );
  }

  //-------------------------------------------------------------------------------------------------------------------------`

  function handleEndCrop( coords, dimensions ) {
      var element = document.getElementById( 'pos_x1' );
      if( element ) {
          element.value = coords.x1;
      }

      var element = document.getElementById( 'pos_y1' );
      if( element ) {
          element.value = coords.y1;
      }

      var element = document.getElementById( 'pos_x2' );
      if( element ) {
          element.value = coords.x2;
      }

      var element = document.getElementById( 'pos_y2' );
      if( element ) {
          element.value = coords.y2;
      }
  }

  //-------------------------------------------------------------------------------------------------------------------------`