﻿
var dd=24*60*60*1000;var hh=60*60*1000;var mm=60*1000;var ss=1000;function ComputeBalance(time)
{var d=time/dd;if(d>0)
{d=parseInt(d);}
else
{d=0;}
time=time-d*dd;var h=time/hh;if(h>0)
{h=parseInt(h);}
else
{h=0;}
time=time-h*hh;var m=time/mm;if(m>0)
{m=parseInt(m);}
else
{m=0;}
time=time-m*mm;var s=time/ss;if(s>0)
{s=parseInt(s);}
else
{s=0;}
if(s>0)
{m=m+1;}
var temp=new Array();temp["d"]=d;temp["h"]=h;temp["m"]=m;temp["s"]=s;return temp;}
var first=true;var barEndLen=0;var barCurLen=0;var timerH;function AutoUpdateBalance()
{if(first==false)
{totalTime=totalTime-interval;}
var temp=ComputeBalance(totalTime);first=false;try
{if(temp["d"]==0&&temp["h"]==0&&temp["m"]==0)
{$("balance_pgbar").style.display="none";$("lbBalance").innerHTML="帐户：您的帐户已于"+$("balance_dt").innerHTML+"过期，点击"+"<a href='"+appPathNav+"Account/Pay.aspx'>这里</a>"+"为帐户充值。";}
else
{$("balance_day").innerHTML=temp["d"];$("balance_hour").innerHTML=temp["h"];$("balance_minute").innerHTML=temp["m"];var len=pgBarLen*(1-(totalTime/allTime));if(barEndLen==0)
{barEndLen=len;barCurLen=0;setTimeout("Animation()",50);}
else if(barCurLen>=barEndLen)
{len=parseInt(len);$("balance_pgbar").style.width=len+"px";if((1-(totalTime/allTime))>0.8)
{$("balance_pgbar").style.backgroundColor="#e5fffe";}}}}
catch(e)
{}
if(totalTime>0)
{if(timerH)
{clearTimeout(timerH);}
timerH=setTimeout("AutoUpdateBalance()",interval);}}
function Animation()
{if(barCurLen<barEndLen)
{$("balance_pgbar").style.width=barCurLen+"px";barCurLen+=10;setTimeout("Animation()",50);}}
if(totalTime>0)
{first=true;timerH=setTimeout("AutoUpdateBalance()",50);}