﻿/*!
 * Site: website.com
 * Author: Author
 * Updated: 2010.01.01
 * Updated by: Lijian 
 * 
 */
/**
 * @method 多级菜单
 * Description
 * e.g menu('#nav');
 * @param string 导航的ID或者class表达式
 * @returns {param2} the value of the field, as set in the className
 */
var flag = 0;
function menu(nav,child){	
	$('li:has(>'+child+')',nav).addClass('parent');
	$('li:has(>'+child+') > a',nav).addClass('hasSubnav');
	$("li.parent",nav).hover(function(){
		$(this).addClass('on'); $('> a', this).addClass('hover');
		$(this).children(child).slideDown();
		 jQuery.fx.off = true;
	}, function(){
		$(this).children(child).fadeOut();
		$(this).removeClass('on'); $('> a', this).removeClass('hover');
	    jQuery.fx.off = false;
	});
}/**
 * @method 选项卡
 * Description
 * e.g tab(".nav",".content","on","mouseover");
 * @nav string 选项卡切换按钮外层的css表达式
 * @nav string 选项卡切换内容外层的css表达式
 * @nav string 当前选项的class名称
 */
function tab(nav,content,on,type)
{
	$(nav).children().bind(type,(function(){
		var tab=$(this);
		var tab_index=tab.prevAll().length;
		$(nav).children().removeClass(on);
		tab.addClass(on);
		$(content).children().hide();
		$(content).children().eq(tab_index).fadeIn();
	}));
}
/**
 * @method accordion
 * Description
 * e.g accordion(".nav",".content","on","mouseover");
 * @nav string 选项卡切换按钮外层的css表达式
 * @nav string 选项卡切换内容外层的css表达式
 * @nav string 当前选项的class名称
 */
function accordion(nav,content,on,type){
	$(nav).bind(type, function(){
		var $cur = $(this);	
		$(nav).removeClass(on);
		$(content).hide();
		$cur.addClass(on);
		$cur.next(content).show();
	})
}

/**
 * @method sliderBar action
 * Description
 * e.g sliderBar("#sliderBar","li","dl","mouseover");
 * @nav 特定区域的标签，建议 id ， 这样jquery 读取速度快
 * @childTag 第一级列表 标签，也可以使用相同class去读取，一般都是用 标签去读取。
 * @listTag 第二级菜单 标签
 * @actionType 事件驱动方法
 */
function sliderBar( nav,childTag,listTag,actionType ){
	var $list = $(childTag,nav);
	var curIndex = 0;
	$list.each( function(index){
		$( this,nav ).bind(actionType,function(){
			var o = $( $list[index],nav );
			var prevObj = $( $list[curIndex],nav );
			if( !o.find(".arrows").hasClass("arrowsDown") ){
				prevObj.find(".arrows").addClass("arrowsRight").removeClass("arrowsDown");
				if(prevObj.has(listTag)){
					prevObj.find(listTag).slideUp();
				}
				o.find(".arrows").addClass("arrowsDown").removeClass("arrowsRight ");
				if(o.has(listTag)){
					//o.find(listTag).slideDown();
					o.find(listTag).show(300);
				}
			}
			curIndex = index;
		});
	} );
}

/*页面行为绑定*/
$(function(){
	//menu(".nav");
	//tab(".tabnav",".tabcontent","on","mouseover");
	//accordion(".nav",".content","on","mouseover");
	sliderBar("#sliderBar","li","dl","click");
	try{$(".sectionTopSellers .inner").jCarouselLite({	
		btnPrev: ".sectionTopSellers .previous",
		btnNext: ".sectionTopSellers .next",
		visible: 4,
		scroll: 1	
	});	
	}catch(ex){}
})
