
  // local PC vs server time difference (approx - ignores render time)
  var localNow=new Date();
  var servertimediff=serverNow.getTime()-localNow.getTime();

  var browserOK = true;
  var pics;
  pics = new Array();

  var objCount = 0; // number of (changing) images on web-page

function preload(name, first, second) {
  // preload images and place them in an array

    pics[objCount] = new Array(25);
    pics[objCount][0] = new Image();
    pics[objCount][0].src = first;
    pics[objCount][1] = new Image();
    pics[objCount][1].src = second;
    pics[objCount][2] = name;
    objCount++;
}

function on(name){
  if (browserOK) {
     for (i = 0; i < objCount; i++) {
      if (document.images[pics[i][2]] != null)
        if (name != pics[i][2]) {
          // set back all other pictures
          document.images[pics[i][2]].src = pics[i][0].src;
        } else {
           // show the second image because cursor moves across this image
           document.images[pics[i][2]].src = pics[i][1].src;
        }
    }
  }
}

function off(){
  if (browserOK) {
     for (i = 0; i < objCount; i++) {
      // set back all pictures
      if (document.images[pics[i][2]] != null)
        document.images[pics[i][2]].src = pics[i][0].src;
    }
  }
}


function countdown() {
  dateNow=new Date();
  amount = endDate.getTime()-dateNow.getTime()-servertimediff;

  // time is already past
  if(amount < 0 || amount==NaN) {
    amount = nextStart.getTime()-dateNow.getTime()-servertimediff;
    if (amount<0 || amount==NaN) {
      time="Refresh browser for next deal"; // page is too old
    }
    else {
      time="Next deal starts in ";
    }
  }
  // date is still good
  else {
	  time=" This Deal Ends In ";
  }

  if (amount>0 && amount!=NaN) {
  	amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs
    diff=amount;
	  hours=Math.floor(amount/3600);//hours
	  diff=diff % 3600;

	  mins=Math.floor(diff/60);//minutes
	  diff=diff % 60;

	  secs=Math.floor(diff);//seconds

    if (hours<0) hours=0;
    if (mins<0) mins=0;
    if (secs<0) secs=0;
	  if (hours<10) hours="0"+hours;
	  if (mins<10) mins="0"+mins;
	  if (secs<10) secs="0"+secs;

    time=time+" "+hours+":"+mins+":"+secs;
  }
  else {
    time="Refresh browser for next deal";
  }
  document.f1.t1.value=""+time;
  setTimeout("countdown()",1000);
}

var winHand,regCount;
var regValid = false;
function regular(left, top) {
    var width, height;
    width = 300 - 6;
    if (width < 0)width = 0;
    height = 350 - 25;
    if (height < 0)height = 0;
    if (!regValid) {
        try {
            winHand = window.open('', '', 'left=' + left + ',top=' + top + ',width=' + width + ',height=' + height + ',status=no,scrollbars=yes,toolbar=no,location=no,directories=no,menubar=no,resizable=no,fullscreen=no');
        }
        catch (e) {
            setTimeout('defaultPos();', 50);
            return false;
        }
        regValid = true;
        regCount = 10;
    }
    if (!regWriteContents()) {
        setTimeout('defaultPos();', 50);
        return false;
    }
    return true;
}

function defaultLeft() {
    var left;
    left = 200;
    return left;
}
function defaultTop() {
    var top;
    top = 100;
    return top;
}
function defaultPos() {
    if (!regular(defaultLeft(), defaultTop()))return;
}

warning = "Sorry, you need a microsummary-enabled browser like Firefox 2.0 to install and use microsummary generators.";

function addGenerator(url) {
    if (typeof (window.sidebar) == "object" &&
        typeof (window.sidebar.addMicrosummaryGenerator) == "function") {
      window.sidebar.addMicrosummaryGenerator(url);
      alert("Microsummary installed into your sidebar");
    }
    else
     alert(warning);
}

