anchor.diff:        // Get a reference to Y.DataType.Date
         var dtdate = Y.DataType.Date;
   
  -      var divLength = $("#available p").length
  -      for (var i = 0; i < divLength; i++) {
  -        var availableDay = $("#available p")[i].id
  -        if (availableDay[0] === "0") {
  -          availableDay = availableDay[1];
  -        }
  -        availableDay = "_" + availableDay;
  +      $.each($("#available p"), function(index, element) {
  +        availableDay = $(element).attr("id")
  +        availableDay = "_" + +availableDay;
           $("td[id$='" + availableDay + "']:not(.yui3-calendar-column-hidden)").addClass("available").css("background-color", "#14A714")
  +      });
  +
  +      $.each($("#booked p"), function(index, element) {
  +        bookedDay = $(element).attr("id")
  +        bookedDay = "_" + +bookedDay;
  +        $("td[id$='" + bookedDay + "']:not(.yui3-calendar-column-hidden)").addClass("booked").css("background-color", "#C9302C")
  +      })
  +
  +
  +      function currentUserId() {
  +        var logout_href = $("a:contains('Logout')").attr("href");
  +        var start_of_userid_on_logout_href = logout_href.lastIndexOf("/")+1;
  +        var user_id = logout_href.slice(start_of_userid_on_logout_href);
  +        return user_id;
         }
   
         // Listen to calendar's selectionChange event.
  
positive.code:        </div>
        </div>
      </div>
    </div>
  </div>
  </div>
negative.code: 
          var newDate = ev.newSelection[0];
          var date = dtdate.format(newDate);
          var day = date.slice(-2);
          var day_id = "#" + day;
          var day_selector = +day; // convert possible leading-zero, single-digit to integer (+"01" = 1)
  
          var selected_day_node = $("td[id$='_" + day_selector + "']:not(.yui3-calendar-column-hidden):not(.booked)");
          $.each(selected_day_node, function(index, node){
            var user_id = currentUserId();
            node = $(node);
            if (node.hasClass("available")) {
              node.removeClass("available").css("background-color", "white");
              var request = $.ajax({
                url: "/users/" + user_id + "/availabilities/" + $(day_id).text(),
                type: "DELETE"
              });
            } else {
              node.addClass("available").css("background-color", "#14A714");
              var request = $.ajax({
                url: "/users/" + user_id + "/availabilities",
                type: "POST",
                data: { date: date}
              });
              request.done(function(response) {
                if (response["id"]) {
                  $("#available").append("<p id= " + response['day'] + " class='id_for_me'>" + response['id'] + "</p>");
                }
              });
            }
          });
        });
      });
    });
  