// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

Event.addBehavior({
  	'body': function() {
    	var busy = $div({id:'busy'}, "Loading...");
    	busy.hide();
    	// NOTE You could also use 'this' here
    	//      since it is the document.body.
    	document.body.appendChild(busy);
  	},
  	'div#calendar div.day:click': function() {
		new Ajax.Request('/calendar/selday/?date=' + this.id);
		return false;
  	}
});

Ajax.Responders.register({
  onCreate: function() {
    if($('busy') && Ajax.activeRequestCount > 0)
      Effect.Appear('busy',{duration:0.5,queue:'end'});
  },
  onComplete: function() {
    if($('busy') && Ajax.activeRequestCount == 0)
      Effect.Fade('busy',{duration:1.0,queue:'end'});
  }
});
