addLoadEvent(getKerstTeller);

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

function daysTo(mo, da) {
	var today = new Date();
	mo = mo - 1; // correctie, 0 = january, 11 = december
	var futureDate = new Date(today.getFullYear(), mo, da);

	if (futureDate < today) {
		futureDate.setYear(today.getFullYear() + 1);
	}
	
	var one_day = 1000 * 60 * 60 * 24;
	var days = Math.ceil((futureDate.getTime() - today.getTime()) / (one_day));
	return days;
}

function getKerstTeller() {

	if (!document.getElementById) {
		return;
	}

	if (!document.getElementById("customjs")) {
		return;
	}

	var daysToKerst = daysTo(12, 25);
	daysToKerst = daysToKerst + '';

	var content = "<div class='balkbg'>Dagen tot kerstmis...</div>\n";
	content += "<div class='customcounter'>\n<br />\n";
	content += "<img src=\"rw_common/themes/fotokaartensite/imagesjs/links.jpg\" alt=\"{\" />";
	for (var i = 0; i < daysToKerst.length; i++) {
		content += "<img src=\"rw_common/themes/fotokaartensite/imagesjs/"+ daysToKerst[i] +".jpg\" alt=\""+ daysToKerst[i] +"\" />";
	}
	content += "<img src=\"rw_common/themes/fotokaartensite/imagesjs/rechts.jpg\" alt=\"}\" />";
	content += "<br />\n<br />\n";

	/* content += "<div class='customcounter'>\n<br />\n~ <span style='color: #000;'>"+ daysToKerst +"</span> ~<br />\n<br />\n"; */
	content += "</div>\n";
	
	var customjs = document.getElementById("customjs");
	customjs.style.display = 'block';
	customjs.innerHTML = content;
}
