(function ($) {

/**
 * ListFilter
 * @constructor jQuery
 */
$.widget('ui.ListFilter', $.extend({}, $.ui.Component.prototype, {
    type: 'ListFilter',
    init: function () {
        var self = this;
        
        $('div.usualBlock').each(function(){
        	$(this).find('ul').hide().filter(':first').show();
        	$(this).find('ul:first li').each(function(i){
        		if (i > 3) {
					$(this).hide();
				}
        	});
        });

		$('div.usualBlock a.more').click(
			function(){
	        	$(this).parents('div.usualBlock').find('ul').show();
	        	$(this).parents('div.usualBlock').find('ul li').show();
				$(this).parents('div.absoluteBlock').addClass("openBlock");

				if($.browser.msie){
					$(this).parents('div.absoluteBlock').width($(this).parents('div.absoluteBlock').find('ul').length*140);
					$(this).parents('div.absoluteBlock').animate({opacity: 1.0}, 950);
					$(this).parents('div.absoluteBlock').find('h5').width($(this).parents('div.absoluteBlock').width()-32);
				}
				
				$(this).parents('div.usualBlock').height($(this).parents('div.usualBlock').find('div.absoluteBlock').height()+13);

				return false;
 			}
		);
		$('div.usualBlock a.closeBlock').click(
			function(){
				$(this).parents('div.usualBlock').find('ul').hide().filter(':first').show();
	        	$(this).parents('div.usualBlock').find('ul:first li').each(function(i){
	        		if (i > 3) {
						$(this).hide();
					}
	        	});
				$(this).parents('div.absoluteBlock').removeClass("openBlock");

				if($.browser.msie){
					$(this).parents('div.absoluteBlock').width(160);
					$(this).parents('div.absoluteBlock').find('h5').width('auto');
				}
				$(this).parents('div.usualBlock').height('auto');

				return false;
			}
		);
     }
}));

})(jQuery);
