
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("GET","http://www.watchco.com/v/vspfiles/bk/dotd/dotd_feeder.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML; 

var date=new Date();
var curr_date = date.getDate();
var curr_month = date.getMonth();
curr_month = curr_month + 1;
var curr_year = date.getFullYear();
today= 'DEAL' + curr_year + curr_month + curr_date;
countdowntoday = curr_month + '/' + curr_date + '/' + curr_year + ' 11:59 PM';


var x=xmlDoc.getElementsByTagName(today);
for (i=0;i<x.length;i++)
  { 

document.write("<div style='line-height: normal; width: 185px; height: 330px; background: url(http://www.watchco.com/v/vspfiles/bk/dotd/widgetbg.jpg) no-repeat top left; align: center;'><div align='center' style='padding-top: 8px;'><a href='http://www.watchco.com/ProductDetails.asp?ProductCode=");
document.write(x[i].getElementsByTagName("SKU")[0].childNodes[0].nodeValue);			   
document.write("'><img border='0' src='http://www.watchco.com/v/vspfiles/bk/dotd/header.jpg'></a></div><br><div align='center' style='margin-top: -10px;'><a href='http://www.watchco.com/ProductDetails.asp?ProductCode=");
document.write(x[i].getElementsByTagName("SKU")[0].childNodes[0].nodeValue);			   
document.write("'><img border='0' height='150' src='http://www.watchco.com/v/vspfiles/photos/");
document.write(x[i].getElementsByTagName("SKU")[0].childNodes[0].nodeValue);
document.write("-2T.jpg'></div><br><b><div align='center' style='margin-top: -8px; color:#543018; Font-family:Tahoma, Geneva, sans-serif; font-size:10px;'><a href='http://www.watchco.com/ProductDetails.asp?ProductCode=");
document.write(x[i].getElementsByTagName("SKU")[0].childNodes[0].nodeValue);			   		   
document.write("'>");
document.write(x[i].getElementsByTagName("BRAND")[0].childNodes[0].nodeValue); 
document.write("&nbsp;");
document.write(x[i].getElementsByTagName("SKU")[0].childNodes[0].nodeValue);
document.write("</a></div></b><br><div align='center' style='margin-top: -8px; color:#000000; font-family:Tahoma, Geneva, sans-serif; font-size:10px;'><s>MSRP: $");
document.write(x[i].getElementsByTagName("REGPRICE")[0].childNodes[0].nodeValue);			   
document.write("</div></s><br><div align='center' style='margin-top: -8px; color:#8b1c04; font-family:Tahoma, Geneva, sans-serif; font-size:18px;'><b><a href='http://www.watchco.com/ProductDetails.asp?ProductCode=");
document.write(x[i].getElementsByTagName("SKU")[0].childNodes[0].nodeValue);			   
document.write("'>$");
document.write(x[i].getElementsByTagName("DEALPRICE")[0].childNodes[0].nodeValue);
document.write("</a></div></b><br><b><div align='center' style='margin-top: -8px; color:#8b1c04; font-family:Tahoma, Geneva, sans-serif; font-size:12px;'>");
var dealprice = x[i].getElementsByTagName("DEALPRICE")[0].childNodes[0].nodeValue;
var regprice = x[i].getElementsByTagName("REGPRICE")[0].childNodes[0].nodeValue;
document.write("$");
document.write(Math.round((regprice-dealprice)*100)/100);
document.write(" off retail!</div></b><br><div align='center' style='margin-top: -8px;'><a href='http://www.watchco.com/ShoppingCart.asp?ProductCode=");
document.write(x[i].getElementsByTagName("SKU")[0].childNodes[0].nodeValue);
document.write("&Qty.ABC=1'><img border='0' src='http://www.watchco.com/v/vspfiles/bk/dotd/buynow.jpg'></a></div><br><div align='center' style='margin-top: -8px; color:#8b1c04; font-family:Tahoma, Geneva, sans-serif; font-size:10px;'>");

var TargetDate = countdowntoday;
var ForeColor = "#8b1c04";
var BackColor = "#ffffff";
var CountActive = true;
var CountStepper = -1;
var LeadingZero = true;
var DisplayFormat = "%%H%% Hrs., %%M%% Min., %%S%% Sec.";
var FinishMessage = "The deal is done!!";

function calcage(secs, num1, num2) {
  s = ((Math.floor(secs/num1))%num2).toString();
  if (LeadingZero && s.length < 2)
    s = "0" + s;
  return "<b>" + s + "</b>";
}

function CountBack(secs) {
  if (secs < 0) {
    document.getElementById("cntdwn").innerHTML = FinishMessage;
    return;
  }
  DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
  DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
  DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
  DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));

  document.getElementById("cntdwn").innerHTML = DisplayStr;
  if (CountActive)
    setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}

function putspan(backcolor, forecolor) {
 document.write("<span id='cntdwn' style='background-color:" + backcolor + 
                "; color:" + forecolor + "'></span>");
}

if (typeof(BackColor)=="undefined")
  BackColor = "white";
if (typeof(ForeColor)=="undefined")
  ForeColor= "black";
if (typeof(TargetDate)=="undefined")
  TargetDate = "12/31/2020 5:00 AM";
if (typeof(DisplayFormat)=="undefined")
  DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(CountActive)=="undefined")
  CountActive = true;
if (typeof(FinishMessage)=="undefined")
  FinishMessage = "";
if (typeof(CountStepper)!="number")
  CountStepper = -1;
if (typeof(LeadingZero)=="undefined")
  LeadingZero = true;


CountStepper = Math.ceil(CountStepper);
if (CountStepper == 0)
  CountActive = false;
var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
putspan(BackColor, ForeColor);
var dthen = new Date(TargetDate);
var dnow = new Date();
if(CountStepper>0)
  ddiff = new Date(dnow-dthen);
else
  ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountBack(gsecs);

document.write("</div></div>");


}


