﻿// category list pop menu
var Categorylist={
	$:function(id){return document.getElementById(id);},
	setListstyle:function(eleID,chpan,cssName,defaultcssName)
	{
		var arrayli = this.$(eleID).getElementsByTagName(chpan); //获取菜单数组
		for(i=0;i<arrayli.length;i++){
			arrayli[i].onmouseover = function(){
				this.className = cssName;
			}
			arrayli[i].onmouseout = function(){
				this.className = defaultcssName;
			}		
	}
	}
}

// tab animate flash
var TabMV={
	$:function(id){return document.getElementById(id);},
	getEleID:function(obj){return (typeof obj=='object'?obj:this.$(obj));},
	animate:function(obj,topClass,topCpan,bodyClass,bodyCpan,bodyCClass,defaultCss,initCss)
	{
		var topPan=getElementByClassName(topClass,this.getEleID(obj),"div");
		var bodyPan=getElementByClassName(bodyClass,this.getEleID(obj),"div");
		
		var tempTpan=topPan[0].getElementsByTagName(topCpan);
		var tempBTpan=getElementByClassName(bodyCClass,bodyPan[0],"div");

		for(var i=0;i<tempTpan.length;i++)
		{	
			tempTpan[i]._index=i;
			tempTpan[i].onclick=function()
			{
				for(var j=0;j<tempTpan.length;j++)
				{
					tempTpan[j].className=tempTpan[j].className.replace(initCss,"");
				}
				
				for(var j=0;j<tempBTpan.length;j++)
				{
					tempBTpan[j].style.display="none";
				}

				tempBTpan[this._index].style.display="block";
				this.className=this.className+initCss;
			};
		}
		tempTpan[0].className=tempTpan[0].className+initCss;		
		
	}
}

function GetRTime(EleID,Time){    
    if(Time>=0){       
        var nD=Math.floor((Time/3600)/24)
		var nH=Math.floor((Time-nD*24*3600)/3600);
		var nM=Math.floor((Time-nD*24*3600-nH*3600)/60);
		var nS=(Time-nH*3600)%60;
		

        var spant="";
        var spanu="";
        var tempTxt=" ";

        if(nD>= 0){
            tempTxt=spant+nD+spanu+"D"+spant+nH+spanu+"H";
            if(nM>=10)
                {
                tempTxt+=spant+nM+spanu+"M";
                }
            else
                {
                tempTxt+=spant+"0"+nM+spanu+"M";
                }

            if(nS>=10)
                {
                tempTxt+=spant+nS+spanu+"S";
                }
            else
                {
                tempTxt+=spant+"0"+nS+spanu+"S";
                }
            }
        else {}

        EleID.innerHTML= tempTxt;
        setTimeout(function(){GetRTime(EleID,Time-1)},1000);
    }else{
        EleID.innerHTML= "Expired";        
    }
}

//dom ready
function oninit(){
    if($ID("categorylist"))
	    Categorylist.setListstyle("categorylist","li","this","");
	    
	if($ID("quictCategoryPan"))
	    Categorylist.setListstyle("quictCategoryPan","li","this","");
	
	if($ID("tab_pan"))
	    TabMV.animate("tab_pan","top","div","body","div","tab_countent1","fl"," setcss");
	
	window.onscroll=getMypac;
	//document.body.onscroll=getMypac;
	
	if($ID("Quick_Main"))
	    {
	        document.onclick=function(){
	        if($ID("Quick_Main").className !="bei_scontent ofh hiddendiv" && popFlag==false)
	        {
	            $ID("Quick_Main").className = "bei_scontent ofh hiddendiv";
	            $ID("listsearchbody").innerHTML="";
	        }
	        
	        if($ID("Quick_SkuMain").className !="bei_scontent ofh hiddendiv" && popFlag==false)
	        {
	            $ID("Quick_SkuMain").className = "bei_scontent ofh hiddendiv";
	        }
	            }
	    }
	    
	if($ID("scrollpan"))
	{
	     document.onclick=function(){

	        if($ID("scrollpan").className =="scrollpan")
	        {
	            DealJs.JS.UI.Switchanimation($ID("luckpan"),'right',15,false);
                DealJs.JS.PE.SetCss("scrollpan","hiddendiv");
                isleft=true;
	        }

	     }
	    
	}
}


