/* ========================================================================
 * menu-collapse
 * ======================================================================== */
+function ($) {
	$.fn.menucollapse = function (){
		var $this = $(this),
			$a = $this.find('li>a');
		$a.on('click',function(){
			$this.find('a').removeClass('curr');
			$(this).addClass('curr');
			var $arrow=$(this).find('span.arrow'),
				$ul=$(this).parent().children('ul.sub-menu');
			if($ul.length>0){
				if($ul.css('display')=="none"){
					$ul.slideDown();
					$arrow.html('');
				}else{
					$ul.slideUp();
					$arrow.html('');
				}
			}
		});
	}
	$('div[data-nav="menu"]').menucollapse();
}(jQuery);
/* ========================================================================
 * tabs
 * ======================================================================== */
+(function($){
	$.fn.tabs=function(options){
		if(this.length == 0) return this;
		if(this.length > 1){
			this.each(function(){$(this).tabs(options)});
			return this;
		}
		if($(this).data('binds')=='yes') return false;
		$(this).data('binds','yes');
		var defaults={};
		var opts=$.extend(defaults,options || {});
		var $this=$(this),
			$hd=$this.children('div.tabs-hd').children('a'),
			$bd=$this.children('div.tabs-bd').children('div.tabs-bd-box');
		
		$hd.on('click',function(){
			var $el=$(this),
				index=$el.index();
			$el.addClass('curr').siblings().removeClass('curr');
			$bd.eq(index).addClass('curr').siblings().removeClass('curr');
			if(opts.callback){
				opts.callback(index);
			}		
		})
	}
})(jQuery);
//函数节流
function throttle(fn, delay){
	var timer = null;
	return function(){
		var context = this, args = arguments;
        clearTimeout(timer);
        timer = setTimeout(function(){
            fn.apply(context, args);
        }, delay);
    };
};