// JScript 文件

var pushName=new Array();
var pushSrc=new Array();
var pushLink=new Array();
var pushShow="";
var rollId;
var mainPushNum;
function $(id)
{
  return document.getElementById(id);
} 
function ShowIndexSildAd()
{             
     var IndexPicWindowObj=document.getElementById("IndexPicWindow");

     for(var i=0;i<IndexPicWindowObj.childNodes.length;i++)
     {
          if(IndexPicWindowObj.childNodes[i].hasChildNodes())
          {                   
            pushLink.push(IndexPicWindowObj.childNodes[i].getAttribute("href"));
            pushSrc.push(IndexPicWindowObj.childNodes[i].childNodes[0].getAttribute("src"));
            pushName.push(IndexPicWindowObj.childNodes[i].childNodes[1].nodeValue);
          }
     }             
    
    //初始化
    for(i=0;i<5;i++){
        pushShow+='<a href="'+pushLink[i]+'" onmouseover="showPushLink('+i+');clearInterval(rollId)" id="linkPush'+i+'" target="_blank">'+pushName[i]+'</a>';
    }
    document.getElementById("linkPush").innerHTML=pushShow;
    mainPushNum=rand(5);
    document.getElementById("linkPush"+mainPushNum).className="linkPushHere";
    document.getElementById("mainPush").innerHTML='<a href="'+pushLink[mainPushNum]+'" target="_blank" id="pushImgLink" onmouseover="clearInterval(rollId)" onmouseout="showAtTime()"><img src="'+pushSrc[mainPushNum]+'" name="pushImg" width="293" height="280" id="pushImg" alt="'+pushName[mainPushNum]+'" /></a>';
    rollId=setInterval("showPushLink()",5000);
} 

function nextSale(order){
	if(order=="up")	saleNum++;
	else saleNum--;
	if(saleNum>2)	saleNum=0
	else if(saleNum<0) saleNum=2;
	for(i=0;i<2;i++)
		document.getElementById("saleList"+i).style.display="none";
	document.getElementById("saleList"+saleNum).style.display="";
}
function showLink(name,order){
	for(i=0;i<2;i++){
		document.getElementById(name+"Push"+i).style.display="none";
		document.getElementById(name+"Link"+i).className=""
	}
	document.getElementById(name+"Push"+order).style.display="";
	document.getElementById(name+"Link"+order).className=name+"LinkHere";
}
function showPushLink(num){
	if(!num&&num!=0){
		mainPushNum++;
		if(mainPushNum>4) mainPushNum=0;
		num=mainPushNum;
	}
	for(i=0;i<5;i++){
		document.getElementById("linkPush"+i).className="";
	}
	document.getElementById("linkPush"+num).className="linkPushHere";
	document.getElementById("pushImg").src=pushSrc[num];
	document.getElementById("pushImgLink").href=pushLink[num];
	document.getElementById("pushImg").alt=pushName[num];
}
function showAtTime(){
	showPushLink();
	rollId=setInterval("showPushLink()",5000);
}
 function cleanWhiteSpace(element){
     for(var i=0;i<element.childNodes.lenght;i++){
        var node=element.childNodes[i];
        if(node.nodeType==3&&!/\S/.test(node.nodeValue))
        node.parentNode.removeChild(node);
     }
  
}
rnd.today=new Date(); 
rnd.seed=rnd.today.getTime(); 
function rnd(){ 
   rnd.seed = (rnd.seed*9301+49297) % 233280; 
  return rnd.seed/(233280.0); 
}

function rand(number){ 
   return Math.ceil(rnd()*number)-1; 
}  


function CheckLoginStatus() 
{  
    var LoginUserName=getCookie("Howave_UnicodeUserName");
    var LoginPassword=getCookie("Howave_UserPassword");   
    
    
    if(LoginUserName!="" && LoginUserName!=null && LoginPassword!=null && LoginPassword!="")
    {  
     
        var url="/Shop/WebService/ShopService.ashx?Action=CheckLogin&UserName="+LoginUserName+"&Password="+LoginPassword+"&Rnd="+Math.random();
        var _ajax_=new HttpAjax();    
	    _xmlReq_ = _ajax_.create(url,callbackHandler,onErrorHandler); 
	    
	    function callbackHandler(rValue) {      
            var result = rValue.responseText;        
            if(result=="0")
            {
               ShowTopLoginUserName(LoginUserName);
            }
            else if(result=="1")
            {
               ShowTopLoginSuccess(LoginUserName);              
              
            }       
        }
        function onErrorHandler()
        {
          return "Server Unvaliable";
        } 
           
               
    }
    else
    {      
       ShowLogin();
    }
    
   
   

}  
function getCookie(cookieName)
{
    var cookieString = document.cookie
    var first ,last
    first=cookieString.indexOf(cookieName)
    if(first!=-1)
    {
       first+=(cookieName.length+1)
       last=cookieString.indexOf(';',first)
       return unescape(cookieString.substring(first,last));
    }
    return null;
    
} 
function ShowTopLoginUserName(UserName)
{
 
  var welcomeObj=$("IndexTop1_welcome");
  if(welcomeObj!=null)
  {
     welcomeObj.innerHTML="<font color='#000'>您好，欢迎&nbsp;</font><span style='color:red'>"+UserName+"</span>！&nbsp;&nbsp;";
     
  }  
}  
function ShowTopLoginSuccess()
{
  var UserName=getCookie("Howave_UnicodeUserName");
  var welcomeObj=$("IndexTop1_welcome");
  if(welcomeObj!=null)
  {
     welcomeObj.innerHTML="<font color='#000'>您好，欢迎&nbsp;</font><span style='color:red'>"+UserName+"</span>！&nbsp;&nbsp;";
     
  }  
  var msgObj=$("IndexTop1_SiteMessage");
  if(msgObj)
  {
     GetUnReadMessage(escape(UserName),"UnReadMsgCount")
    
     
  }
  var msgIcon=$("MsgIcon");
  if(msgIcon!=null)
  {
    msgIcon.style.display="";
  }
  var LoginStatusObj=$("IndexTop1_login_status");
  var RegStatusObj=$("IndexTop1_regLink");
  var LoginUrl=LoginStatusObj.getAttribute("href");
  var LogoutUrl=LoginUrl.replace("Login","Logout");
  if(LoginStatusObj!=null)
  {
     LoginStatusObj.setAttribute("href",LogoutUrl);
     LoginStatusObj.innerHTML="[退出]";
    
  }  
  if(RegStatusObj!=null)
  {
       RegStatusObj.style.display="none";
  } 
   setTimeout("CheckLoginStatus()",60000);  //60秒更新一次顶部  
  
}

function ShowLogin()
{
  //$("IndexTop1_welcome").innerHTML="<font color='#000'>您好，欢迎！</font>&nbsp;&nbsp;";
  var LoginStatusObj=$("IndexTop1_login_status");
  var LoginUrl=LoginStatusObj.getAttribute("href");
  var LogoutUrl=LoginUrl.replace("Logout","Login");
  LoginStatusObj.setAttribute("href",LogoutUrl);
  LoginStatusObj.innerHTML="[登录]";
}  

         