var speed = 1000;
var len = 40;
var tid = 0;
var num = 0;
var clockA = null;
var timeA = null;
var formatA = null;
var dd = new Date();
var d, x;

function doDate(x) {
	var dt = new Date();

	if (timeA != 0) {
		v1 = Math.round((timeA - dt ) / 1000);
		if (v1 < 0) clockA.innerHTML = "BANG!";

		if (formatA == 1) {
			clockA.innerHTML = v1;
		} else if (formatA == 2) {
			sec = v1 % 60;
			v1 = Math.floor(v1 / 60);
			min = v1 % 60;
			hour = Math.floor(v1 / 60);
			month = Math.floor(hour / 24);
			hour2 = hour - (month*24);
			if (sec < 10) sec = "0" + sec;
			if (min < 10) min = "0" + min;
			clockA.innerHTML = month + "/"+hour2 + "/" + min + "/" + sec;
		} else if (formatA == 3) {
			sec = v1 % 60;
			v1 = Math.floor(v1 / 60);
			min = v1 % 60;
			v1 = Math.floor(v1 / 60);
			hour = v1 % 24;
			day = Math.floor(v1 / 24);
			if (sec < 10) sec = "0" + sec;
			if (min < 10) min = "0" + min;
			if (hour < 10) hour = "0" + hour;
			clockA.innerHTML = month + "/"+hour2 + "/" + min + "/" + sec;
		} else if (formatA == 4) {
			sec = v1 % 60;
			v1 = Math.floor(v1 / 60);
			min = v1 % 60;
			v1 = Math.floor(v1 / 60);
			hour = v1 % 24;
			day = Math.floor(v1 / 24);
			clockA.innerHTML = month + "/"+hour2 + "/" + min + "/" + sec;
		} else
			clockA.innerHTML = "<font color=red>Invalid Format spec</font>";
	} else {
		clockA.innerHTML = "Countdown till when?";
	}

	tid = window.setTimeout("doDate()", speed);
}

function start(d, x, format) {
	clockA = x;
	timeA = new Date(d);
	formatA = format;
	tid = window.setTimeout("doDate()", speed);
}

function CountdownLong(t, format, container) {
	start(t, container, format);
}

