(function($) {
	$.fn.panel = function(settings) {
		var config = {
			'timeout': 5000,
			'close':'<div class="box_close" style="position:absolute;right:0px;top:0px">Bezár</div>',
			'reopen':null
		};
		
		if (settings) $.extend(config, settings);

		this.each(function() {
 			
 			var item = $(this);
 			this.timer = null; 			
			
  		this.timer = window.setTimeout(function(){
  			item.fadeOut(2000);
			},config.timeout);
  		
  		if (config.close)
  		{  			
  			var x = item.prepend(config.close);
  			var closeItem = item.children().first()
				closeItem.click(function(){
  				item.hide();
				});
				closeItem.hide();
				item.hover(function(){
					closeItem.fadeIn(200);
				}, function(){
					closeItem.fadeOut(200);
				});
			}
			
			item.hover(function(){
				clearTimeout(this.timer);
        item.stop();
        item.fadeTo(200,1);
			},function(){
				this.timer = window.setTimeout(function(){
  				item.fadeOut(2000);
					},config.timeout);
			});
			
			if (config.reopen) {
				$(config.reopen).click(function() {
					clearTimeout(this.timer);
					item.show();
				});
			} 		
			
			item.hide();	
			item.fadeIn('1500');	

     });
 
     return this;
 
   };
 
 })(jQuery);
