$(document).ready(function(){
	//全部分类
  $('#hd-category').mouseDelay(300).hover(function(){
  	$(this).addClass('hover');
  },function(){$(this).removeClass('hover');
  });
  $('#hd-category .hcc .cata-item').hover(function(){
		$('#hd-category .hcc .cata-item').removeClass('hover');
		$(this).addClass('hover');
  },function(){$(this).removeClass('hover')
  });
	//分类筛选
	$("#filter-select .fs-switch").click(function(){
    $("#filter-select .con").slideToggle("fast");
    $("#filter-select .title .more").toggle();
    $("#filter-select .fs-switch").toggleClass('fs-close');
  });
	//销售排行
  $('#top10 div ul li').hover(function(){$('#top10 div ul li').removeClass('hover');}); //移动到li上 先移除其它li上的hover
  $('#top10 div ul li').hover(function(){$(this).addClass('hover');});
	//$('#top10 div ul').hover(function(){$(this).addClass('hover')},function(){$('.tp-item-1').addClass('hover')})//移开鼠标回到hover回到第一
	//商品列表
	$('#goods-list li').hover(function(){
  $(this).addClass('hover');
  },function(){$(this).removeClass('hover')
  });
	//商品页购买按钮box
	$('.add-cart-box').hover(function(){
  $(this).addClass('hover');
  },function(){$(this).removeClass('hover')
  });
	//商品页tab
	$('#goods-page .tabs li').click(function(){
			$('#goods-page .tabs li').removeClass('intro')
			$('#goods-page #goods-desc,#goods-page #goods-comment,#goods-page #goods-asked,#goods-page #goods-shopping-tips').removeClass('hide')
	})
	$('#goods-page .tabs li.go-goods-desc').click(function(){
			$('#goods-page #goods-desc .tabs li.go-goods-desc').addClass('intro')
	})
	$('#goods-page .tabs li.go-goods-comment').click(function(){
			$('#goods-page #goods-desc').addClass('hide');
			$('#goods-page #goods-comment .tabs li.go-goods-comment').addClass('intro')
	})
	$('#goods-page .tabs li.go-goods-asked').click(function(){
			$('#goods-page #goods-desc,#goods-page #goods-comment').addClass('hide');
			$('#goods-page #goods-asked .tabs li.go-goods-asked').addClass('intro')
	})
	$('#goods-page .tabs li.go-goods-shopping-tips').click(function(){
			$('#goods-page #goods-desc,#goods-page #goods-comment,#goods-page #goods-asked').addClass('hide');
			$('#goods-page #goods-shopping-tips .tabs li.go-goods-shopping-tips').addClass('intro')
	})
	
	
	//返回头部
	$('#gotoplink').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);});	
	//去评论
	$('#goods-info .text .comment').click(function(){$('html,body').animate({scrollTop:$('#goods-comment').offset().top}, 800);});	
	//商品介绍
	//$('.go-goods-desc').click(function(){$('html,body').animate({scrollTop:$('#goods-desc').offset().top}, 800);});	
	//评价
	//$('.go-goods-comment').click(function(){$('html,body').animate({scrollTop:$('#goods-comment').offset().top}, 800);});	
	//咨询
	//$('.go-goods-asked').click(function(){$('html,body').animate({scrollTop:$('#goods-asked').offset().top}, 800);});	
	//咨询
	//$('.go-goods-shopping-tips').click(function(){$('html,body').animate({scrollTop:$('#goods-shopping-tips').offset().top}, 800);});	
	//$('#gotocomment').click(function(){$('html,body').animate({scrollTop:$('#comment_no_login').offset().top}, 800);});	
	//左侧列表动画伸缩
	jQuery('.sidebar ul li').bind('mouseenter',function(){
	jQuery(this).animate({
	    paddingLeft: "10px" }, 200)
    }).bind('mouseleave',function(){
        jQuery(this).animate({
            paddingLeft: "0"}, 500)
    });
});
//首页幻灯片
$(function(){
	(function(){
		var curr = 0;
		$("#focus-nav .trigger").each(function(i){
			$(this).hover(function(){
				curr = i;
				$("#slide li").eq(i).fadeIn(1000).siblings("li").hide();
				$(this).siblings(".trigger").removeClass("imgSelected").end().addClass("imgSelected");
				return false;
			});
		});
				var timer = setInterval(function(){
			todo = (curr + 1) % 3;
			$("#focus-nav .trigger").eq(todo).hover();
		},8000);
		
		//鼠标悬停在触发器上时停止自动翻
		$("#focus-nav a").hover(function(){
				clearInterval(timer);
			},
			function(){
				timer = setInterval(function(){
					todo = (curr + 1) % 3;
					$("#focus-nav .trigger").eq(todo).hover();
				},4000);			
			}
		);
	})();
});
/*!
 * jQuery.mouseDelay.js v1.2 延时插件
 * Copyright 2011, TangBin
 * Dual licensed under the MIT or GPL Version 2 licenses.
 */
(function($,g){var h={},id=1,etid=g+'ETID';$.fn[g]=function(e,f){id++;f=f||this.data(etid)||id;e=e||150;if(f===id)this.data(etid,f);this._hover=this.hover;this.hover=function(c,d){c=c||$.noop;d=d||$.noop;this._hover(function(a){var b=this;clearTimeout(h[f]);h[f]=setTimeout(function(){c.call(b,a)},e)},function(a){var b=this;clearTimeout(h[f]);h[f]=setTimeout(function(){d.call(b,a)},e)});return this};return this};$.fn[g+'Pause']=function(){clearTimeout(this.data(etid));return this};$[g]={get:function(){return id++},pause:function(a){clearTimeout(h[a])}}})(jQuery,'mouseDelay');
//商品页商品数量
var setAmount={
					min:1,
					max:999,
					reg:function(x){
						return new RegExp("^[1-9]\\d*$").test(x);
					},
					amount:function(obj,mode){
						var x=$(obj).val();
						if (this.reg(x)){
							if (mode){
								x++;
							}else{
								x--;
							}
						}else{
							alert("请输入正确的数量！");
							$(obj).val(1);
							$(obj).focus();
						}
						return x;						
					},
					reduce:function(obj){
						var x=this.amount(obj,false);
						if (x>=this.min){
							$(obj).val(x);
						}else{
							alert("商品数量最少为"+this.min);
							$(obj).val(1);
							$(obj).focus();
						}
					},
					add:function(obj){
						var x=this.amount(obj,true);
						if (x<=this.max){
							$(obj).val(x);
						}else{
							alert("商品数量最多为"+this.max);
							$(obj).val(999);
							$(obj).focus();
						}
					},
					modify:function(obj){
						var x=$(obj).val();
						if (x<this.min||x>this.max||!this.reg(x)){
							alert("请输入正确的数量！");
							$(obj).val(1);
							$(obj).focus();
						}
					}
				}
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				

