var MyDraggable = Class.create();
MyDraggable.prototype = (new Rico.Draggable()).extend( {

   initialize: function( htmlElement, name ) {
      this.type        = 'MyDraggable';
      this.htmlElement = $(htmlElement);
      this.originZone  = "not defined";
   },
   // Zwrot id parentNode lub alternatyw, jeeli
   // parentNode nie posiada poprawnego atrybutu id.
   getContainer: function() {
      var el = this.htmlElement;
      if(el.parentNode) {
         if(el.parentNode.id){
            return  el.parentNode.id;
         } else {
            return "no_id_"+el.parentNode.nodeName;
         }
      } else {
         return this.name+"_no_supported_parentNode";
      }
   },
   // Przechowanie pocztkowego przecignicia jako "shelf".
   // danie Ajax zostanie przeprowadzone jedynie wtedy, gdy
   // pocztkowym przecigniciem jest "shelf".
   startDrag: function() {
      this.originZone=this.getContainer();
   },
   // Przeprowadzenie dania Ajax jedynie wtedy, gdy pocztkiem 
   // przecignicia jest "shelf", a stref upuszczenia jest "basket".
   endDrag: function() {
      if(this.originZone == "shelf" &&
            this.getContainer() == "basket"){
         var bk=this.htmlElement.childNodes[0].id;
         new Ajax.Request("/parkerriver/s/checkout", {method: "get",
               parameters: "book="+bk,
               onComplete:function(request){
            $("outcome").innerHTML=request.responseText;}});

      }
   }

} );
