// JavaScript Document

$(window).load(function(){
	
	//宝贝列表导航
	$("#dhSite p").each(function() {
        $(this).click(function(){
			$("#dhSite em").hide();
			$(this).addClass("active");
			$(this).children("em").show();
			$(this).siblings().removeClass("active");
		});
    });
	$('#dhSiteTG p').each(function(){
        $(this).hover(function(){
            $(this).addClass("active");
            $(this).siblings().removeClass("active");
        });
        });
				
	/*商品鼠标点击跟着变化背景图*/
	$("#nav_activeTG ul li").click(function(){
		$(this).addClass('active').siblings().removeClass('active');	
	})

	/*品牌团中品牌图片换动效果的鼠标划过效果*/
	$(".imgstr_pp,.p-list").mouseover(function(){		
		$(this).children("p,span").show();
	});
	$(".imgstr_pp,.p-list").mouseout(function(){
		$(".imgstr_pp,.p-list").children("p,span").hide();
	});
});

window.onscroll=function(){
	
	//滚动条达到一定地方的时候顶部导航出现
	var h = $(window).height();	
	var t = $(document).scrollTop();
	if(t>225)
	{		
		$("#nav_active").css("top","0").fadeIn("slow");		
	}
	else
	{
		$("#nav_active").css("top","-45px").fadeOut("slow");
	}
	if(t>385)
	{		
		$("#nav_activeTG").css("top","0").fadeIn("slow");
		
	}
	else
	{
		$("#nav_activeTG").css("top","-45px").fadeOut("slow");
	}
	if(t>=550)
	{
		$('#navigation').fadeIn("slow");
	}
	else
	{
		$('#navigation').fadeOut("slow");
	}
		
	if(t > h){
		$('#back_id').show();		
	}else{
		$('#back_id').hide();		
	}
	
}
var timer=null;
function startmove(iTarget)
{
	var odiv=document.getElementById("navigation");
	clearInterval(timer);
	timer=setInterval(function(){
		var iSpeed=(iTarget-odiv.offsetTop)/2;
		iSpeed=iSpeed>0?Math.ceil(iSpeed):Math.floor(iSpeed);
		if(odiv.offsetTop==iTarget)
		{
			clearInterval(timer);
		}
		else
		{
			odiv.style.top=odiv.offsetTop+iSpeed+"px";
		}
	},10);	
}


function CountDown (cfg, fn) {
    if (!cfg.startTime || !cfg.expireTime) {
        return false;
    }
    var startTime = parseInt(cfg.startTime),expireTime = parseInt(cfg.expireTime);
    var timer = setInterval(_CountDown, 1000);
    
    _CountDown();
    
    function _CountDown () {
        // 当前时间毫秒
        var nowTime = (new Date()).getTime(),
            // 剩余时间
            surplus = expireTime - Math.floor(nowTime/1000), day=hour=minutes=0;
        if (surplus<=0) {
            surplus = 0;
            clearInterval(timer);
        } else {    
            // 天
            day = Math.floor(surplus/86400),
            surplus = surplus - day*86400,
            // 时
            hour = Math.floor(surplus/3600),
            surplus = surplus - hour*3600,
            // 分
            minutes = Math.floor(surplus/60),
            surplus = surplus - minutes*60;
            
            day = day<10?'0'+day:day;
            hour = hour<10?'0'+hour:hour;
            minutes = minutes<10?'0'+minutes:minutes;
            surplus = surplus<10?'0'+surplus:surplus;
        }
        fn(cfg.el, day, hour, minutes, surplus);
    }
}

function check_load(zhi)
{        
    //禁用滚动条
    var temp_h1 = document.body.clientHeight;
    var temp_h2 = document.documentElement.clientHeight;
    var isXhtml = (temp_h2<=temp_h1&&temp_h2!=0)?true:false;
    var htmlbody = isXhtml?document.documentElement:document.body;
    if(zhi==0)
    {
       document.getElementById('phoneload').style.display='none';
       document.getElementById('loadinfo').style.display='none'; 
       htmlbody.style.overflow = "";      
    }
    else
    {  
       document.getElementById('phoneload').style.display='block';
       if(zhi==1)
       {
               document.getElementById('loadinfo').style.display='block';    
       }     
       htmlbody.style.overflow = "hidden";       
    }        
}


