﻿$(document).ready(function(){
	///头部logo链接
	$("img#outLink").mouseover(function(){
		$("img#outLink").attr("src","../images/top_linkOn.gif");
		$("div#outLink_box .logos_tbl").show();
	})
	$("img#outLink").mouseout(function(){
		$("img#outLink").attr("src","../images/top_linkOff.gif");
		$("div#outLink_box .logos_tbl").hide();
	})
	$("div#outLink_box .logos_tbl").mouseover(function(){
		$("img#outLink").attr("src","../images/top_linkOn.gif");
		$("div#outLink_box .logos_tbl").show();
	})
	$("div#outLink_box .logos_tbl").mouseout(function(){
		$("img#outLink").attr("src","../images/top_linkOff.gif");
		$("div#outLink_box .logos_tbl").hide();
	})
	
	///导航
	$("div.nav li.c1_tit").mouseover(function(){
		if($(this).children("div.c2_tit").size()!=0){
			$(this).children("div.c2_tit").show();
			$(this).children("a.c1_tit").addClass("c1_curr");
		}
	})
	$("div.nav li.c1_tit").mouseout(function(){
		if($(this).children("div.c2_tit").size()!=0){
			$(this).children("div.c2_tit").hide();
			$(this).children("a.c1_tit").removeClass("c1_curr");
		}
	})
	
	//首页焦点图
	var _img_num = $("#ad_images>img").size();
	var _width_step = 980; //单个图片所占实际宽度
	var _width_total = _img_num*_width_step;
	if($("#ad_images").size()!=0){
		var _cX = $("#ad_images").position().left;
	}
	
	function slide(index){
		$("#ad_images").animate({left:-index*_width_step+"px"}); 
	}
	
	var num=0;
	var total=$("#ad_images img").length;
	function slideAuto(){
		slide(num);
		if(num<total-1){
			num++;
		}else{num=0;}
		a=setTimeout(slideAuto,8000);
	}
	window.onload=slideAuto;
	
	//首页热卖产品左右切换
	var img_total = $("#hot_images a.item").size();
	var roll_total=Math.floor(img_total/4);
	var hot_step = 928; //一屏即#hot_imgStage的宽度
	//var hot_width_total = img_total*hot_step;
	var now_index=0;
	$("span#prev").addClass("over");
	
	$("span#prev").click(function (){
		if(now_index>0){
			now_index--;
			hot_slide(now_index);
			if(now_index==0){
				$("span#prev").addClass("over");
			}else{
				$("span#prev").removeClass("over");
			}
			$("span#next").removeClass("over");
		}
	});
	$("span#next").click(function (){
		if(now_index<roll_total-1){
			now_index++;
			hot_slide(now_index);
			if(now_index==roll_total-1){
				$("span#next").addClass("over");
			}else{
				$("span#next").removeClass("over");
			}
			$("span#prev").removeClass("over");
		}
	});

	function hot_slide(now_index){
		$("#hot_images").animate({left:-now_index*hot_step+"px"}); 
	}
	
	//详情页商品大图切换
	var img_total2 = $("#goods_images div.item").size();
	var roll_total2=Math.floor(img_total2/1);
	var hot_step2 = 585; //一屏即#hot_imgStage的宽度
	//var hot_width_total = img_total*hot_step;
	var now_index2=0;
	$("span#goods_prev").addClass("over");
	
	$("span#goods_prev").click(function (){
		if(now_index2>0){
			now_index2--;
			hot_slide2(now_index2);
			if(now_index2==0){
				$("span#goods_prev").addClass("over");
			}else{
				$("span#goods_prev").removeClass("over");
			}
			$("span#goods_next").removeClass("over");
		}
	});
	$("span#goods_next").click(function (){
		if(now_index2<roll_total2-1){
			now_index2++;
			hot_slide2(now_index2);
			if(now_index2==roll_total2-1){
				$("span#goods_next").addClass("over");
			}else{
				$("span#goods_next").removeClass("over");
			}
			$("span#goods_prev").removeClass("over");
		}
	});

	function hot_slide2(now_index2){
		$("#goods_images").animate({left:-now_index2*hot_step2+"px"}); 
	}
	
	//商品详情评论切换
	$("a.btn_com").click(function(){
		$("div.com_box").hide();
		$("div.pages").hide();
		$("ul.go_com").show();
	})
	$("span.cancel_com").click(function(){
		$("div.com_box").show();
		$("div.pages").show();
		$("ul.go_com").hide();
	})
	
	//详情页商品细节4个tab切换
	$("ul.detail_tab li").click(function(){
		var detail_index=3-$("ul.detail_tab li").index($(this));
		for(i=0;i<4;i++){
			$("ul.detail_tab li").eq(i).removeClass("curr"+(3-i));
		}
		$(this).addClass("curr"+detail_index);
		$("div.detail").hide();
		$("div.detail"+detail_index).show();
	})
	
	//详情页视频
	if($(".video").size()!=0){
		$(".video a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_rounded'});
	}
	
	///新闻切换
	$("ul.news_tab li").click(function(){
		var news_index=$("ul.news_tab li").index($(this));
		$("ul.news_tab li").removeClass("curr");
		$(this).addClass("curr");
		$("div.news_box").hide();
		$("div.news_box").eq(news_index).show();
	})
	
})
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	


