//Navigation
$(document).ready(function () {
		//整站导航		
		$(".nav").superfish({pathClass : 'current',speed:'fast',delay:0});
		$("ul", $(".nav")).bgIframe({ opacity: false });//遮挡select;
		
		//左侧导航
		$(".sortNav p").mouseover(function(){
			$(this).addClass("sortNavTOn").next("ol").slideDown("slow").siblings("ol").slideUp("slow");		
        	$(this).siblings("p").removeClass("sortNavTOn");
		});
		
		//鼠标滑动
		$("#indTabM0 li").hover(function(){
			$(this).addClass("indTabMOn1");},
			function(){
				var c=$(this).attr('class');
				if(c=='indTabMOn1'){
				$(this).removeClass("indTabMOn1");
				}
		});
		$("#skuM li").hover(function(){
			$(this).addClass("proCur1");},
			function(){
				var c=$(this).attr('class');
				if(c=='proCur1'){
				$(this).removeClass("proCur1");
				}
		});
				
		//列表样式最后一行的下边框去除
		$("dl.proExp:last,#cartHavePro ul.lineDotH3:last,ul.expSecBrand li:last").css("background","none");
	
		//图片自适应宽度
		$(".skuTopLogo img").each(function(i){
			var WskuLogo=260;
			if($(this).attr("width")*1>WskuLogo) {
				$(this).width(WskuLogo);
				}							   
		});
		$(".brandInfoL img").each(function(i){
			var WbrandInfoL=246;
			if($(this).attr("width")*1>WbrandInfoL) {
				$(this).width(WbrandInfoL);
				}							   
		});
		$(".proInfoTopL img").each(function(i){
			var WbrandInfoL=250;
			if($(this).attr("width")*1>WbrandInfoL) {
				$(this).width(WbrandInfoL);
				}							   
		});	
		
});

//首页右侧广告
(function($) {
	$.fn.marquee = function(o) {
		//获取滚动内容内各元素相关信息
		o = $.extend({
			speed:		parseInt($(this).attr('speed')) || 30, // 滚动速度
			step:		parseInt($(this).attr('step')) || 1, // 滚动步长
			direction:	$(this).attr('direction') || 'up', // 滚动方向
			pause:		parseInt($(this).attr('pause')) || 1000 // 停顿时长
		}, o || {});
		var dIndex = jQuery.inArray(o.direction, ['right', 'down']);
		if (dIndex > -1) {
			o.direction = ['left', 'up'][dIndex];
			o.step = -o.step;
		}
		var mid;
		var div 		= $(this); // 容器对象
		var divWidth 	= div.innerWidth(); // 容器宽
		var divHeight 	= div.innerHeight(); // 容器高
		var ul 			= $("ul", div);
		var li 			= $("li", ul);
		var liSize 		= li.size(); // 初始元素个数
		var liWidth 	= li.width(); // 元素宽
		var liHeight 	= li.height(); // 元素高
		var width 		= liWidth * liSize;
		var height 		= liHeight * liSize;
		if ((o.direction == 'left' && width > divWidth) || 
			(o.direction == 'up' && height > divHeight)) {
			// 元素超出可显示范围才滚动
			if (o.direction == 'left') {
				ul.width(2 * liSize * liWidth);
				if (o.step < 0) div.scrollLeft(width);
			} else {
				ul.height(1 * liSize * liHeight);
				if (o.step < 0) div.scrollTop(height);
			}
			ul.append(li.clone()); // 复制元素
			mid = setInterval(_marquee, o.speed);
			div.hover(
				function(){clearInterval(mid);},
				function(){mid = setInterval(_marquee, o.speed);}
			);
		}
		function _marquee() {
			// 滚动
			if (o.direction == 'left') {
				var l = div.scrollLeft();
				if (o.step < 0) {
					div.scrollLeft((l <= 0 ? width : l) + o.step);
				} else {
					div.scrollLeft((l >= width ? 0 : l) + o.step);
				}
				if (l % liWidth == 0) _pause();
			} else {
				var t = div.scrollTop();
				if (o.step < 0) {
					div.scrollTop((t <= 0 ? height : t) + o.step);
				} else {
					div.scrollTop((t >= height ? 0 : t) + o.step);
				}
				if (t % liHeight == 0) _pause();
			}
		}
		function _pause() {
			// 停顿
			if (o.pause > 0) {
				var tempStep = o.step;
				o.step = 0;
				setTimeout(function() {
					o.step = tempStep;
				}, o.pause);
			}
		}
	};
})(jQuery);
//调用
$(document).ready(function(){  
$("#banRight").marquee({  
	direction: "down",  
	step: 1, 
	speed:1, 
	pause: 1000
	});  
}); 

//Tabs , Horizontal
function indTab(m,n){
 var tli=document.getElementById("indTabM"+m).getElementsByTagName("li");
 var mli=document.getElementById("indTabCont"+m).getElementsByTagName("div");
 for(i=0;i<tli.length;i++){
  tli[i].className=i==n?"indTabMOn":"";
  mli[i].style.display=i==n?"block":"none";
 }
}

//SKU,Tab
function SKU(m,n){
 var tli=document.getElementById("skuM").getElementsByTagName("li");
 var mli=document.getElementById("skuC").getElementsByTagName("div");
 for(i=0;i<tli.length;i++){
  tli[i].className=i==m?"proCur":"";
  mli[i].style.display=i==n?"block":"none";
 }
}

function show(){
document.getElementById("skuC4").style.display="block";
document.getElementById("skuProInfo").style.display="block";
}
function hide(){
document.getElementById("skuProInfo").style.display="none";
}
function proComment(){
document.getElementById("").style.display="block";
document.getElementById("").style.display="none";
}

//Tabs,Pay
function payTab(m,n){
 var tli=document.getElementById("payMenu"+m).getElementsByTagName("li");
 var mli=document.getElementById("payCont"+m).getElementsByTagName("ul");
 for(i=0;i<tli.length;i++){
  tli[i].className=i==n?"payCur":"";
  mli[i].style.display=i==n?"block":"none";
  if(n==2) {
	  tli[2].style.color="";
	  }
	  else {tli[2].style.color="#eb008d";}
 }
}

//My Account,Tab
function acc(m,n){
 var tli=document.getElementById("accTabM"+m).getElementsByTagName("li");
 var mli=document.getElementById("accCont"+m).getElementsByTagName("div");
 for(i=0;i<tli.length;i++){
  tli[i].className=i==n?"accCur":"";
  mli[i].style.display=i==n?"block":"none";
 }
}

//CMS Tab
function cmsNew(m,n){
 var tli=document.getElementById("cmsNewM"+m).getElementsByTagName("li");
 var mli=document.getElementById("cmsNewC"+m).getElementsByTagName("ul");
 for(i=0;i<tli.length;i++){
  tli[i].className=i==n?"cmsNewCur":"";
  mli[i].style.display=i==n?"block":"none";  
 }
}

//Express Tab
function expRec(m,n){
 var tli=document.getElementById("expRecM"+m).getElementsByTagName("li");
 var mli=document.getElementById("expRecC"+m).getElementsByTagName("ul");
 for(i=0;i<tli.length;i++){
  tli[i].className=i==n?"expRecCur":"";
  mli[i].style.display=i==n?"block":"none";  
 }
}

//Express Solution Menu
function setTab(m,n){
 var tli=document.getElementById("expSecRMenu").getElementsByTagName("dt");
 var mli=document.getElementById("expSecRMenu").getElementsByTagName("dd");
 for(i=0;i<tli.length;i++){
  tli[i].className=i==n?"current":"";
  mli[i].style.display=i==n?"block":"none";
 }
}

//Express hp,图片无缝滚动
$(document).ready(function(){
	    
	  //滚动小图 start
	  var $content = $("#expSolshow");
	  var i = 5;  //已知显示的li的个数
	  var m = 5;  //用于计算的变量
	  var count = $content.find("li").length;
	  var ulWidth=count*73;
	  if( count<=m)
	  {
		    $(".expBtnnext").css("background-image","url(/html/imagesNew/express/btn_expPreNone.gif)");
		    $(".expBtnprev").css("background-image","url(/html/imagesNew/express/btn_expNextNone.gif)");
	        
	  }
	  $("#expSolshow").width(ulWidth);
	  $("#expnext").click(function(){
			if( !$content.is(":animated")){
				if(m<count){    
					m++;
					$content.animate({left: "-=73px"}, 500);
					$(".expBtnprev").css("background-image","url(/html/imagesNew/express/btn_expPre.gif)");
					if(m==count)
					{
					    $(".expBtnnext").css("background-image","url(/html/imagesNew/express/btn_expNextNone.gif)");
					}
				}
			}
	  });
	  $("#expprev").click(function(){
			if( !$content.is(":animated")){
				if(m>i){
					m--;
					$content.animate({left: "+=73px"}, 500);
					$(".expBtnnext").css("background-image","url(/html/imagesNew/express/btn_expNext.gif)");
					if(m==i)
					{
					    $(".expBtnprev").css("background-image","url(/html/imagesNew/express/btn_expPreNone.gif)");
					}
				}	
			}
	  });  
	  
});

//HTML open Window
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//交换图片
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




