/* 	Realtime Countdown v1.1
 *	(C) 2006 Nathan Bolender
 *	www.nathanbolender.com
*/

/*	**********************************************************	*/
/*	**********************************************************	*/
/*	**************** DO NOT EDIT BELOW THIS LINE**************	*/
/*	**********************************************************	*/
/*	**********************************************************	*/

/*************THIS SCRIPT HAS BEEN EDITED BY PIDGEY.BE**********************/

var version = '1.1';
		
function countdown(elementString, dateString, mode, name) { // UNIX TIMESTAMP*1000! -> Changed by Pidgey
/////////////////////////////////////////
//	usage:
//	countdown(str element, str date [, int mode [, str name]])
//	element is the element that will contain the countdown
//	date is the countdown (or countup) date in this standard form:
//		------ UNIX TIMESTAMP!
//VOORBEELD;
//<span id="1"></span>
//<script language="javascript" type="text/javascript">countdown('1', 1279854522000,1);
/////
//	Modes:
//niks/3 = voluit
//1 = kort
if (mode == null) mode = 3;
if (name == null) name = '0';
	var clock = document.getElementById(elementString);
	var eventdate = new Date(dateString); // in format "January 1, 2005 00:00:00 GMT"
	now = new Date();
	nowtime = now.getTime(); // now in milliseconds
	eventtime = eventdate.getTime(); // event in milliseconds
		
		var eventhour = eventdate.getHours();
		var eventminute = eventdate.getMinutes();
		var eventsecond = eventdate.getSeconds();
		var eventmonth = eventdate.getMonth()+1;
		var eventday = eventdate.getDate();
		var eventyear = eventdate.getFullYear();

	timeleft = Math.round((eventtime-nowtime) / 1000); // timeleft in seconds
	
	var passed = 0;
	if (timeleft < 0) { // if event has passed
		timeleft = Math.abs(timeleft);
		passed = 1;
	}
	
	if (timeleft != 0) {
		// Let's get a whole bunch of values
		years = Math.floor(timeleft/31556926);
		months = Math.floor((timeleft%31556926)/2629744);
		days = Math.floor(((timeleft%31556926)%2629744)/86400);
		hours = Math.floor((((timeleft%31556926)%2629744)%86400)/3600);
		minutes = Math.floor(((((timeleft%31556926)%2629744)%86400)%3600)/60);
		seconds = Math.floor(((((timeleft%31556926)%2629744)%86400)%3600)%60);
	}
	
	// Now lets build a response to print
	var togo = ''; // set up our variable
	
	
	if(passed==1 || timeleft==0)
	{
		todo='Afgelopen';
		}
	else {
		
	if(mode==3)
	{
	if (timeleft != 0) {
		if (years > 0) {
			togo += years + ' jaar';
			if (years > 1) togo += 'en';
			if (months > 0) togo += ',';
			if ((minutes!=0)||(seconds!=0)||(hours!=0)||(days!=0)||(months!=0)) togo += ' ';
		}
		
		if (months > 0) {
			togo += months + ' maand';
			if (months > 1) togo += 'en';
			if (days > 0) togo += ',';
			if ((minutes!=0)||(seconds!=0)||(hours!=0)||(days!=0)) togo += ' ';
		}
		
		if (days > 0) {
			togo += days + ' dag';
			if (days > 1) togo += 'en';
			if ((minutes!=0)||(seconds!=0)||(hours!=0)) togo += ' ';
		}
		
		if (hours > 0) {
			togo += hours + 'u';
			
			if ((minutes!=0)||(seconds!=0)) togo += ' ';
		}
		
		if (minutes > 0) {
			togo += minutes + 'm ';
			
		}
		
		
			togo += seconds + 's';
		
		
			todo=togo;
	}
	}//mode =3
	
	
	
	
	
	
	if(mode==1)
	{
	if (timeleft != 0) {
		if (years > 0) {
			togo += years + 'j';
			if ((minutes!=0)||(seconds!=0)||(hours!=0)||(days!=0)||(months!=0)) togo += ' ';
		}
		
		if (months > 0) {
			togo += months + 'm';
			if ((minutes!=0)||(seconds!=0)||(hours!=0)||(days!=0)) togo += ' ';
		}
		
		if (days > 0) {
			togo += days + 'd';
			if ((minutes!=0)||(seconds!=0)||(hours!=0)) togo += ' ';
		}
		
		if (hours > 0) {
			togo += hours + 'u ';
			}
			else togo += '00u ';
		
		if (minutes > 0) {
			togo += minutes + 'm ';
			}else togo += '00m ';
		
		
			togo += seconds+'s';
		
		
			todo=togo;
	}
	}//mode =1
	
	
	
	
	
	
	
	
	
	
	}
	
	// Now lets print it
	clock.innerHTML = todo;
	if(passed!=1)
	setTimeout('countdown(\'' + elementString + '\', ' + dateString + ', ' + mode + ', "' + name + '");', 1000); // re-execute the function in 1 second
}
