// by Anatoly Rr 

(function($) {
	$.fn.tree = function(options) {
		var defaults = {
			tresholdWidth: 200,
			minifiedWidth: 200
		};
		var opts = $.extend(defaults, options);


		
		// leafs = this.find('li').filter(function(i){return $(this).children('ul').lenght==0;});
		// leafs.addClass('leaf');
		leafs = this.find('li:not(:has(ul))');
		leafs.addClass('leaf');
		
		this.addClass('tree-ul');
		this.find('li').click( function() 
		{
			$(this).toggleClass('open');

			// solution for IE
			ul = $($(this).children('ul')[0]);
			ul.toggleClass('open');
			// alert (ul.attr('className'));
			
			return false;
		});
		
		this.find('a').click( function ()
		{
			window.location=this.href;
			return false;
		});
	};	
})(jQuery);

