
/**
*
*   custom accordeon
*
**/



(function(jQuery){
     jQuery.fn.extend({  
         accordion: function() {   
         	//400
         	//
         	    
            return this.each(function() {
            	
            	var $ul = jQuery(this);
            	
				if($ul.data('accordiated'))
					return false;
								
				jQuery.each($ul.find('ul, li>div'), function(){
					jQuery(this).data('accordiated', true);
					jQuery(this).hide();
				});
				
				
				jQuery.each($ul.find('a'), function(){
					jQuery(this).click(function(e){
						activate(this);
						return void(0);
					});
				});

				
				
				
				// HASH TAG
				var active = (location.hash)?jQuery(this).find('a[href=' + location.hash + ']')[0]:'';

				if(active){
					activate(active, 'toggle');
					//jQuery(active).parents().show($mySPEED);
					jQuery(active).parents().show('fast');
				}
				
				
				function activate(el,effect){
					if($mySPEED > 0){
						jQuery(el).parent('li').toggleClass('active').siblings().removeClass('active').children('ul, div').slideUp('fast');
						jQuery(el).siblings('ul, div')[(effect || 'slideToggle')]((!effect)?'fast':null);
					}else{
						jQuery(el).parent('li').toggleClass('active').siblings().removeClass('active').children('ul, div').slideUp($mySPEED);
						jQuery(el).siblings('ul, div')[(effect || 'slideToggle')]((!effect)?$mySPEED:null);
					}	
									
				}
				
            });
        } 
    }); 
})(jQuery);
