var before="";
var current="";
var set = 0;

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

function countdown(yr,m,d,before){
	var header='<P style="LINE-HEIGHT: 12pt; LETTER-SPACING: normal"><SPAN style="FONT-SIZE: 12pt; COLOR: red"><B>'
	var footer='</B></SPAN></P>'
	var today=new Date()
	var todayy=today.getYear()
	if (todayy < 1000)
		todayy+=1900
	
	var todaym=today.getMonth()
	var todayd=today.getDate()
	
	var todaystring=montharray[todaym]+" "+todayd+", "+todayy
	var futurestring=montharray[m-1]+" "+d+", "+yr
	
	var difference=(Math.round((Date.parse(futurestring)-Date.parse(todaystring))/(24*60*60*1000))*1)
	if (difference==0)
		document.write(current)
	else if (difference>0) {
		if (set == 0) {
			document.write('<P style="LINE-HEIGHT: 8pt; LETTER-SPACING: normal"><SPAN style="FONT-SIZE: 24pt"><FONT face="Monotype Corsiva, Lucida Handwriting, Apple Chancery, Brush Script MT, Cursive"><STRONG>Countdown</STRONG></FONT></SPAN></P>');			
			set = 1;
		}
		if (difference==1) {
			document.write(header)
			document.write("Kun "+difference+" dag til "+before)
			document.write(footer)
		} else {
			document.write(header)
			document.write("Kun "+difference+" dage til "+before)
			document.write(footer)
		}
	}
}

function multipleDates(dates) {
	var today = new Date();
	for (i in dates) {
		args = dates[i].split("-");
		if (today.getTime() < new Date(args[0],args[1]-1,args[2]).getTime()) {
			countdown(args[0],args[1],args[2],args[3]);
			break;
		}
	}
}

multipleDates([
	"1990-01-01-test"
]);

countdown(2012,5,30,"den nęste koncert i Danmark!");

countdown(2009,8,29,"den store koncert i de fantastiske rammer ved Scone Palace i Perthshire!")
