var Schedule = new Class( {
	initialize:function()
	{
	    Schedule.current = this;
	    var today = new Date();
	    if( today.getHours() < 5)
	        today.setDate( today.getDate()-1);
        this.epoch = new Epoch('cal1','flat',$('calendar'),true, today);
        this.epoch.addDates( new Array( today), true);
    
	},
    sortDate:function(a, b)
    {
        return a - b;
    },
	redraw:function( el)
	{
	    var container = $('schedule');
	    container.empty();
	    this.epoch.selectedDates.sort(this.sortDate);
	    var prev;
        for( j =0; j < this.epoch.selectedDates.length;j++)
        {
            var date= this.epoch.selectedDates[j].dateFormat( 'd.m.Y');
            var div = new Element( 'div');
            div.toggleClass( 'day');
            div.setProperty( 'id', date);
            if( !prev)
                div.injectInside( container);
            else
                div.injectAfter( prev);
            prev = div;
            $('spinner').setStyle( 'display','block');
    		new Ajax( '/ajax/ajax-schedule.xl?day='+date, {method:'get',update:div,onComplete:this.hideSpinner}).request();            
    	}
	},
	hideSpinner:function()
	{
         $('spinner').setStyle( 'display','none');
	}
});