//
////
// jquery.ulTree.js
//
// the table manager allows support for sorting, highlighting and reloading a table
// needs to be placed to a <table> Object with <tbody> and <thead>
// exact one row in thead and tbody has to be set, since the plugin needs the info to
// set up the ulTree


/**
 * $Id: jquery.ULTree.js,v 1.2 2008/12/10 17:11:05 igor Exp $
 **/

//   _ultCache    _ultId   ult  ULTree   ulTree    müssen für neues Plugin ersetzt werden

(function($){

  $.fn.extend({
    ulTree : function(options)
    {
      if (!$.event._ultCache) $.event._ultCache = [];

      // initialise the date picker controller with the relevant settings...
      options = $.extend(
      {
        id : '',
        $context : ''
      }
      , options
      );

      return this.each(
        function()
        {
          var $this = $(this);
          var alreadyExists = true;

          if (!this._ultId) {
            this._ultId = $.event.guid++;
            $.event._ultCache[this._ultId] = new ULTree(this);
            alreadyExists = false;
          }

          var controller = $.event._ultCache[this._ultId];

          C.log("ulTree: ");
    

          controller.init(options);
          $this.ultInit();
        }
        )
    },
    ultInit : function()
    {
      $a = $context.find("li.city");
      a.parent().hide();

      C.log("KKKKKKKKKKKKKKKKKK");
      C.log($a);

    },
    _ultDestroy : function()
    {
    // TODO - implement this?
    }
  });

  // private internal function to cut down on the amount of code needed where we forward
  // dp* methods on the jQuery object on to the relevant DatePicker controllers...
  var _w = function(f, a1, a2, a3)
  {
    return this.each(
      function()
      {
        var c = _getController(this);
        if (c) {
          c[f](a1, a2, a3);
        }
      }
      );
  };

  function ULTree(ele)
  {
    this.ele = ele;

    // initial values...
    this.id				=	undefined;
    this.$context			=	undefined;
  };
  $.extend(
    ULTree.prototype,
    {
      init : function(s)
      {
        C.log(s.renderDirective);
        this.id = s.id;
        this.$context = $(s.id);


      //        this.inline = s.inline;
      //        if (this.inline) {
      //          this.context = this.ele;

      }
    }
    );


  function _getController(ele)
  {
    if (ele._ultId) return $.event._ultCache[ele._ultId];
    return false;
  };

  // make it so that no error is thrown if bgIframe plugin isn't included (allows you to use conditional
  // comments to only include bgIframe where it is needed in IE without breaking this plugin).
  if ($.fn.bgIframe == undefined) {
    $.fn.bgIframe = function() {
      return this;
    };
  };


  // clean-up
  $(window)
  .bind('unload', function() {
    var els = $.event._ultCache || [];
    for (var i in els) {
      $(els[i].ele)._dpDestroy();
    }
  });


})(jQuery);


