var timerID;
var timerRunning = false;
var today = new Date();
var enday = new Date();
var secPerDay = 0;
var minPerDay = 0;
var hourPerDay = 0;
var secsLeft = 0;
var secsRound = 0;
var secsRemain = 0;
var minLeft = 0;
var minRound = 0;
var minRemain = 0;
var timeRemain = 0;
var decremain = 0;
var decround = 0;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function startclock () {
stopclock();
showtime();
}
function showtime () {
today = new Date();
enday = new Date("November 24, 2006 20:00");
enday.setYear("2006");
secsPerDay = 1000 ;
minPerDay = 60 * 1000 ;
hoursPerDay = 60 * 60 * 1000;
PerDay = 24 * 60 * 60 * 1000;
/*Seconds*/
secsLeft = (enday.getTime() - today.getTime()) / minPerDay;
decremain = (enday.getTime() - today.getTime()) / secsPerDay;
decround = Math.round(decremain);
decremain = decround + " seconds";
secsRound = Math.round(secsLeft);
secsRemain = secsLeft - secsRound;
secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft) * 60) : secsRemain = (secsLeft - secsRound) * 60;
secsRemain = Math.round(secsRemain);
/*Minutes*/
minLeft = ((enday.getTime() - today.getTime()) / hoursPerDay);
minRound = Math.round(minLeft);
minRemain = minLeft - minRound;
minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft)  * 60) : minRemain = ((minLeft - minRound) * 60);
minRemain = Math.round(minRemain - 0.495);
/*Hours*/
hoursLeft = ((enday.getTime() - today.getTime()) / PerDay);
hoursRound = Math.round(hoursLeft);
hoursRemain = hoursLeft - hoursRound;
hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound - hoursLeft)  * 24) : hoursRemain = ((hoursLeft - hoursRound) * 24);
hoursRemain = Math.round(hoursRemain - 0.5);
/*Days*/
daysLeft = ((enday.getTime() - today.getTime()) / PerDay);
daysLeft = (daysLeft - 0.5);
daysRound = Math.round(daysLeft);
daysRemain = daysRound;
/*Time*/
timeRemain = daysRemain + " days, " + hoursRemain + " hours, <br>" + minRemain + " mins, " + secsRemain + " secs";
timeRemain2 = daysRemain + " days, " + hoursRemain + " hours, " + minRemain + " mins, " + secsRemain + " secs";
// document.clock.face.value = timeRemain;

if(document.layers) {
 // Nav 4.x code fork...
    with (document.tcounter.document) {
      open();
      write(timeRemain);
      close();
    }
    with (document.t2counter.document) {
      open();
      write(timeRemain2);
      close();
    }    
}
if(document.all) {
 // IE 4/5 code fork...
 document.all.tcounter.innerHTML = timeRemain;
  document.all.t2counter.innerHTML = timeRemain2;

}


timerID = setTimeout("showtime()",1000);
timerRunning = true;

if ((daysRemain < 0) && (daysRemain >= -10)) {
if(document.layers) {
 	 // Nav 4.x code fork...
    with (document.tcounter.document) {
      open();
      write("<a href='http://cgi6.ebay.co.uk/ws/eBayISAPI.dll?ViewSellersOtherItems&include=0&userid=StarCards4GOSH+&sort=2&rows=25&since=-1&rd=1'>Auction Started</a>");
      close();
    }
    with (document.t2counter.document) {
      open();
      write("<a href='http://cgi6.ebay.co.uk/ws/eBayISAPI.dll?ViewSellersOtherItems&include=0&userid=StarCards4GOSH+&sort=2&rows=25&since=-1&rd=1'>Auction Started</a>");
      close();
    }    
}
if(document.all) {
 // IE 4/5 code fork...
 document.all.tcounter.innerHTML = "<a href='http://cgi6.ebay.co.uk/ws/eBayISAPI.dll?ViewSellersOtherItems&include=0&userid=StarCards4GOSH+&sort=2&rows=25&since=-1&rd=1'>Auction Started</a>";
  document.all.t2counter.innerHTML = "<a href='http://cgi6.ebay.co.uk/ws/eBayISAPI.dll?ViewSellersOtherItems&include=0&userid=StarCards4GOSH+&sort=2&rows=25&since=-1&rd=1'>Auction Started</a>";
}
}

if (daysRemain < -10) {
clearTimeout(timerID);
timerRunning = false;
if(document.layers) {
 	 // Nav 4.x code fork...
    with (document.tcounter.document) {
      open();
      write("Coming Soon");
      close();
    }
    with (document.t2counter.document) {
      open();
      write("Coming Soon");
      close();
    }    
}
if(document.all) {
 // IE 4/5 code fork...
 document.all.tcounter.innerHTML = "Coming Soon";
  document.all.t2counter.innerHTML = "Coming Soon";
}
// document.clock.face.value = "No Auction Scheduled";
}
}