/*
Author: Robert Hashemian
http://www.hashemian.com/
 
*/

function calcageB(secs, num1, num2) {
  s = ((Math.floor(secs/num1))%num2).toString();
  if (LeadingZeroB && s.length < 2)
    s = "0" + s;
  return s;
}

function CountBackB(secs) {
  if (secs < 0) {
    document.getElementById("cntdwnB").innerHTML = FinishMessageB;
    return;
  }
  DisplayStrB = DisplayFormatB.replace(/%%D%%/g, calcageB(secs,86400,100000));
  DisplayStrB = DisplayStrB.replace(/%%H%%/g, calcageB(secs,3600,24));
  DisplayStrB = DisplayStrB.replace(/%%M%%/g, calcageB(secs,60,60));
  DisplayStrB = DisplayStrB.replace(/%%S%%/g, calcageB(secs,1,60));

  document.getElementById("cntdwnB").innerHTML = DisplayStrB;
  if (CountActiveB)
    setTimeout("CountBackB(" + (secs+CountStepperB) + ")", SetTimeOutPeriodB);
}

function putspan(backcolor, forecolor) {
 document.write("<span id='cntdwnB'></span>");
}
 
CountStepperB = Math.ceil(CountStepperB);
if (CountStepperB == 0)
  CountActiveB = false;
var SetTimeOutPeriodB = (Math.abs(CountStepperB)-1)*1000 + 990;
putspan(BackColor, ForeColor);
var dthen = new Date(TargetDateB);
var dnow = new Date();
if(CountStepperB>0)
  ddiff = new Date(dnow-dthen);
else
  ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountBackB(gsecs);
