/*
	Author: Andrew Saponenko (Zombie)
	Email: roguevoo@gmail.com
	License: Free for All
*//*
jQuery.extend({
	zAccordion: function(options){
		var defaults = {
			height: 'auto',
			parent:undefined,
			head:undefined,
			selected:'acc_selected',
			event:'mouseover',
			fxspeed:'slow',
			expandeble: false,
			index:0
		};

	    var opt = jQuery.extend(defaults,options);

	    if( !opt.head || !opt.parent ) return;

		var current = 0;
        var parent = jQuery(opt.parent);
        parent.css({
            height:opt.height
        });

        var lengths = [];

        function show_up( item )
        {
            var h = lengths[ item.attr('index') ];

            jQuery(item).animate({height:h},{queue:false,complete:function(){
                jQuery(item).addClass(opt.selected);
            }});
        }

        function hide_out( item )
        {
            jQuery(item).animate({height:0},{queue:false,complete:function(){
                jQuery(item).removeClass(opt.selected);
            }});
        }

		jQuery(opt.parent).find(opt.head).each( function(i){

			var self = jQuery(this);
			
			if( i == opt.index ){
				self.addClass(opt.selected);
				self.next().show();
				current = self;
			}else{
				hide_out(self.next());
			}

            lengths[i] = self.next().height();
            self.next().attr('index', i);
            
            jQuery(this).bind(opt.event,{},function(){
                hide_out(current.next());
                current = jQuery(this);
                show_up(current.next());
		   });
	   });

	   return;
	}
});

jQuery.fn.extend({
	zAccordion: function(options){
		var opt = options;
		opt.parent = jQuery(this);
		jQuery.zAccordion( opt );
	}
});*/

/*
	Author: Andrew Saponenko (Zombie)
	email: roguevoo@gmail.com
	License: Free for All
*/
jQuery.extend({
	zAccordion: function(options){
		var defaults = {
			height:		'auto',
			parent:		undefined,
			head:		undefined,
			selected:	'acc_selected',
			event:		'mouseenter',
			fxspeed:	'slow',
			fxbegin:{
				'opacity':	0.0
			},
			fxend:{
				'opacity':	1.0
			}
		}

	    var opt = jQuery.extend(defaults,options);

		var active = undefined;
		var collection = [];

	    if( !opt.head || !opt.parent ) return;

		function select(event)
		{
			var index = event.data;
			if( active == index ) return true;
			active = index;

			if( collection[active] !== undefined )
			{
				collection[active].head.addClass(opt.selected);
				collection[active].body.animate(opt.fxend,{
					queue:false,
					duration:opt.fxspeed
				});
			}

			jQuery( collection ).each(function(i){
				if( i == active ) return;
				this.head.removeClass(opt.selected);
				this.body.animate(opt.fxbegin,{
					queue:false,
					duration:opt.fxspeed/*,
					complete:function(){
						jQuery(this).hide()
					}*/
				});
			});
		}

		jQuery(opt.parent).each(function(){

			jQuery(this).find(opt.head).each(function(index){
				var t = jQuery(this);
				t.css({cursor:'pointer'}).bind(opt.event,index, select );
				collection[index] = {
					head:t,
					body:t.next()
				};
			});

			jQuery(collection).each(function(index){
				if( index == 0 )
				{
					this.head.addClass(opt.selected);
					this.body.show().animate(opt.fxend,{
						queue:false,
						duration:opt.fxspeed
					});
				}
				else
				{
					this.body.animate(opt.fxbegin,{
						queue:false,
						duration:1/*,
						complete:function(){
							jQuery(this).hide()
						}*/
					});
				}
			});
		});
	}
});

jQuery.fn.extend({
	zAccordion: function(options){
		var opt = options;
		opt.parent = jQuery(this);
		jQuery.zAccordion( opt );
	}
})