//验证是否登录
jQuery(function(){
	$.ajax({
      type:"post",
      url:basePath+'/web/validateMember.html',
      dataType:"text",
      success:function(data){
		if(data=='null')
		{
			jQuery("#unLoad").show();
			jQuery(".user .left a").attr("href",basePath+'/auth/login.do');
			jQuery(".user .right a").attr("href",basePath+'/web/register.html');
			jQuery("#hasLoad").hide();	
		}else{
			jQuery("#unLoad").hide();
			jQuery("#hasLoad").show();
				$.ajax({
        			type:"post",
       				url:basePath+"/member/getUserName.do",
        			dataType:"text",
        			success:function(data){ 
          				$("#nowUserName").text(data);
        			}
     				});	
     			$.ajax({
        			type:"post",
       				url:basePath+"/member/getUserLevel.do",
        			dataType:"text",
        			success:function(data){ 
          				$("#nowUserLevel").text(data);
        			}
     				});		
				$.ajax({
        			type:"post",
       				url:basePath+"/member/center/yearNewIntCount.do",
        			dataType:"text",
        			success:function(data){ 
          			if(data==0){
             			$("#yearNewint").css('color','#ff6600');
          			}              
        	 			$("#yearNewint").text(data);
        			}
     				});
     		}            
      }
	})
})
//产品推荐中间4块

function showtab(index) {
	for (var i = 0; i < 4; i++) {
		if ((i + 1) == index) {
			document.getElementById("slider" + index).style.display = "";
		} else {
			document.getElementById("slider" + (i + 1)).style.display = "none";
		}
	}
	if(document.getElementById("jf").className=='select select-jf'){
		document.getElementById("jf").className='select-jf';
	}
	if(index==1){
		document.getElementById("jf").className='select select-jf';
		document.getElementById("sj").className='select-sj';
		document.getElementById("rx").className='select-rx';
		document.getElementById("tj").className='select-tj';
	}else if(index==2){
		document.getElementById("jf").className='select-jf';
		document.getElementById("sj").className='select select-sj';
		document.getElementById("rx").className='select-rx';
		document.getElementById("tj").className='select-tj';
	}else if(index==3){
		document.getElementById("jf").className='select-jf';
		document.getElementById("sj").className='select-sj';
		document.getElementById("rx").className='select select-rx';
		document.getElementById("tj").className='select-tj';
	}else if(index==4){
		document.getElementById("jf").className='select-jf';
		document.getElementById("sj").className='select-sj';
		document.getElementById("rx").className='select-rx';
		document.getElementById("tj").className='select select-tj';
	}
}

//推荐排行榜
$(function () {
	//$("img").lazyload({threshold:200});
	$(".sales-right ul li").mouseover(function () {
		if ($(this).hasClass("origin")) {
		} else {			
			$(this).parent().find("li:contains('NO')").hide();
			$(this).hide();
			$(this).prev().fadeIn(300);
			$(this).parent().find("li:nth-child(even)").not($(this)).fadeIn(300);
			$(this).parent().find("li:contains('NO')").stop(true,true);
			$(this).stop(true,true);
			return false;
		}
	});
});

if (!+[1,]) { 
       (function() { 
           var tags = [ 
                 'article', 'aside', 'details', 'figcaption', 
               'figure', 'footer', 'header', 'hgroup', 
                  'menu', 'nav', 'section', 'summary', 
                  'time', 'mark', 'audio', 'section', 'video'], 
                      i = 0, len = tags.length; 
             for (; i < len; i++) document.createElement(tags[i]); 
        })(); 
      } 
      
//客服
$(function(){
  	//$(".consulting h6").html("<img border='0' src='"+basePath+"/525m/index/images/service.gif' onclick='open_pic_chat()' style='cursor: pointer;width:209px;height:56px;'/>");
	$(".consulting h6").bind("click",function(){
		open_pic_chat();
	})
})

//翻页广告js
		var NowFrame = 2;
		var theTimer;
		function showAll() {				
			for(var i=1;i<(MaxFrame+1);i++){
			if(i==NowFrame){
			$("#div"+NowFrame).hide();
			$("#div"+NowFrame).fadeIn(600);
			$("#advText"+NowFrame).css({"background":"#bf0000",'color':'#fff'});
			}else{
			$("#div"+i).hide();
			$("#advText"+NowFrame).siblings().css({"background":"#fff",'color':'#FF4000'});
			}
			}
	        if(NowFrame == MaxFrame){   //设置下一个显示的图片
				NowFrame = 1;
				}
		   	else{
				NowFrame++;
				}
			    theTimer=setTimeout('showAll()',4000);   //设置定时器，显示下一张图片
		}
		
		
		function showAdv(d1){
			NowFrame=d1;           //设当前显示图片
			for(var i=1;i<(MaxFrame+1);i++){
			if(i==NowFrame){
			$("#div"+NowFrame).fadeOut(600);
			$("#div"+NowFrame).fadeIn(600);
			
			$("#advText"+NowFrame).css({"background":"#bf0000",'color':'#fff'});
			}else{
			$("#div"+i).hide();
			$("#advText"+NowFrame).siblings().css({"background":"#fff",'color':'#FF4000'});
			}
			}
			if(NowFrame == MaxFrame){   
				NowFrame = 1;
				}
		   	else
				NowFrame++;
		}
		
		$(function(){
			$("#play_text ul li").click(function(){
				var advLength=$("#play_text ul li").size();
				var advIndex=$(this).attr("id").substring(7,advLength);
				showAdv(advIndex);
			})
		})
		
		function stopAdv(){
			clearTimeout(theTimer);  //当触动按扭时，清除计时器
		}
		
		function startAdv(){
			stopAdv();
			theTimer=setTimeout('showAll()',4000); //重启计时器
		}
		
		function initCss(){
			for(var i=1;i<(MaxFrame+1);i++){
				if(i==1){
					$("#advText"+i).css({"background":"#bf0000",'color':'#fff'});
				}else{
					$("#advText"+i).css({"background":"#fff",'color':'#FF4000'});
				}
			}
		}
	    window.onload=function(){initCss();startAdv();}
