/*
 Simple dropdown box 

 Dependencies: 
 	jQuery Lib - http://jquery.com/
 	author: Dyagovchenko Sergey (http://d.sumy.ua/)
*/
(function($) {
	$.fn.extend({
		simplebox : function(options){
			// default values
			// speed: slow, fast
			// effect: none, slide, fade
			var options = $.extend({speed: 0, effect: 'none', do_after: function(){}}, options);
			var link = $(this);
			var box_id = link.attr('rel'); 
			var box = $(box_id);
			
			if(options.speed == 'none') options.speed = 0;

			link.click(function(){ str = options.effect + ' >> ';
				if(box.is(':visible'))
				{
					switch(options.effect)
					{
						case 'slide':
							box.slideUp(options.speed);
							str += 'slide!';
							break;

						case 'fade':
							box.fadeIn(options.speed);
							str += 'fade!';
							break;

						case 'none':
						default:
							box.hide(options.speed);
							str += 'none!';
							break;
					}
				}
				else
				{
					switch(options.effect)
					{
						case 'slide':
							box.slideDown(options.speed, options.do_after);
							str += 'show slide!';
							break;
						
						case 'fade':
							box.fadeOut(options.speed, options.do_after);
							//box.show();
							str += 'show fade!';
							break;

						case 'none':
						default:
							box.show(options.speed, options.do_after);
							str += 'show none!';
							break;
					}					
				}
//alert(str);
				return false;
			});

			$(document).mouseup(function(e) {
				var elem = $(e.target); 
				if (elem.parents(box_id).length == 0)
				{
					if(elem.attr('id') != link.attr('id'))
					{
						box.hide();
					}
				}
			});			
		}
	})
})(jQuery);
