/** constructor
       @param duration integer seconds
       @param <optional> function to run while waiting.
    */
   function Pause(duration, busy){
      this.duration= duration * 1000;
      this.busywork = null; // function to call while waiting.
      this.runner = 0;
      if (arguments.length == 2) {
         this.busywork = busy;
      }
      this.pause(this.duration);
   } // Pause class
   /** pause method
       @param duration: integer in seconds
    */
   Pause.prototype.pause = function(duration){
      if ( (duration == null) || (duration < 0)) {return;}
      var later = (new Date()).getTime() + duration;
      while(true){
         if ((new Date()).getTime() > later) {
            break;
         }
         this.runner++;
         if (this.busywork != null) {
            this.busywork(this.runner);
         }
      } // while
   } // pause method
function hideIt(id) {
new Effect.BlindUp('id',{duration: 0.2, from: 0.0, to: 1});
}
function removeChildren(parent) {
var childFree = document.getElementById(parent);
  while (childFree.hasChildNodes()) {
    var firstChild = childFree.firstChild;
    childFree.removeChild(firstChild);
   }
}
function showIt(day,month,inhalt) {
  // hier muessen die Kinder von calendarEventsList geloescht werden und der Tag als ueberschrift gesetzt werden.
    removeChildren("calendarEventsList");
  //Ausschreiben der Monate:
   Monatsname = new Array("Januar", "Februar", "M&auml;rz", "April", "Mai", "Juni", "Juli","August", "September", "Oktober", "November", "Dezember");
$('calendarEventsList').insert("<h2>Veranstaltungen am "+day+"."+Monatsname[month - 1]+"</h2>");

var events = inhalt.split("!&");
//gehe alle events durch
for (var i=1; i<=events.length+1; i++) {
    var elemente = events[i].split("&&");
for (var y=0; y < elemente.length; y++) {
if (y==0) { id=elemente[y]; };
if (y==1) { ort=elemente[y]; };
if (y==2) { titel=elemente[y]; };

}

// Die Variablen fuer das einzelne Event sind gesetzt jetzt kann das html gebaut werden
     var calendarListe='calendarEventLink'+i;
     var advancedEvent='advancedEvent'+i;
  
     var attrs = {
     href   : '../home/veranstaltung-'+id+".html",
     target : '',
     id : calendarListe,
     onmouseover : '$(\'' + calendarListe + 'advanced\').appear();',
     onmouseout : '$(\'' + calendarListe + 'advanced\').hide();'
     };
   var link = new Element('a', attrs);
   link.update(titel);
   $('calendarEventsList').insert(link);
//$(calendarListe).appendAfter('A',{href:'otherpage.html', className:'red'}).update('Continue...');
if( i%2 == 0 ) {
     $(calendarListe).wrap('li', { className:"calendarListeGerade " + advancedEvent   });
   } else {
     $(calendarListe).wrap('li', { className:"calendarListeUngerade " + advancedEvent  });
}

// Das HTML des einzelEvents ist fertig jetzt kann das naechste drankommen

}
}

