/** rev0 **/
/** Created by DSI Ostrava **/
(function($){
	var $opt;
	function op($this){ $this.open(); }
    $.fn.extend({
    	
        divslider: function($options) {
			
			var $defaults = {
				speed : 500,
				autohide : false
            };
                 
            $opt =  $.extend($defaults, $options);
			$('.js').show();	
 
            return this.each(function() {
				// ALLOCATE OBJECTS             	
				var $obj = $(this);				
				var $items = $('.sliderHead', $obj);
				var $contents = $('.sliderContent', $obj);			
			
				$items.addClass('closed');				
				$contents.hide();				
				
				$items.click(function(){
					if ($(this).hasClass('closed')) {
						if ($opt.autohide) {
							if($('.opened', $obj).length > 0) {															
								$(this).openClose();
							} else $(this).open();
						} else $(this).open();						
					} else $(this).close();					
				});
				
				$('.closeThis', $obj).click(function(e){
					e.preventDefault();
					$(this).parents('.sliderContent').siblings('.sliderHead').close();
				});				
            });
		},
		open: function() {
			$(this).removeClass('closed').addClass('opened').siblings('.sliderContent').slideDown($opt.speed);
		},
		close: function() {
			$(this).removeClass('opened').addClass('closed').siblings('.sliderContent').slideUp($opt.speed);
		},
		openClose: function() {
			var $this = $(this);
			$('.opened').removeClass('opened').addClass('closed').siblings('.sliderContent').slideUp($opt.speed, function(){
				$this.removeClass('closed').addClass('opened').siblings('.sliderContent').slideDown($opt.speed);
			});
		},
		showAll: function() {			
			$(this).addClass('on').show().click(function(e){
				if ($(this).hasClass('on')) {
					$(this).removeClass('on').addClass('off');
					$('.closed').open();
				} else {
					$(this).removeClass('off').addClass('on');
					$('.opened').close();
				}				
			});
		}
	});	
})(jQuery);
