function updates(){
	if (!document.getElementsByTagName){ return; }
	var anchors = document.getElementsByTagName('div');	
	var counter = 0;
	for(var i=0; i<anchors.length; i++){
		var anchor = anchors[i];
		var idAttribute = String(anchor.getAttribute('id'));
		if (idAttribute.match('date')){
			counter++;
			var date = idAttribute.substring(5,13);
			var cookie = "cookie_" + counter;
			if(date > readCookie(cookie)){
				anchor.childNodes[0].onclick = function () {update_cookie(this);};
				var update = document.createElement('div');
				update.className = 'new';
				var text = document.createTextNode('*nieuw*');
				update.appendChild(text);
				anchor.parentNode.appendChild(update);
			}
		}
	}
	return true;
}
function update_cookie(link){
	var anchors = document.getElementsByTagName('div');
	var counter = 0;
	for(var i=0; i<anchors.length; i++){
		var anchor = anchors[i];
		var idAttribute = String(anchor.getAttribute('id'));
		if(idAttribute.match('date')){
			counter++;
			var cookie = "cookie_" + counter;
			var child = anchor.childNodes[0].getAttribute('href');
			var div_link = '';
			if (child.charAt(0) == '.'){
				div_link = child.substring(2);
			}
			else{
				div_link = child;
			}
			if(String(link).match(div_link)){
				var date = anchor.getAttribute('id').substring(5,13);
				createCookie(cookie,date);
			}
		}
	}
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return '0';
}
function createCookie(name,value) {
	var date = new Date();
	date.setTime(date.getTime()+(365*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = name+"="+value+expires+"; path=/";
}
function eraseCookies() {
	for(var i=0; i<10; i++){
			var cookie = "cookie_" + i;
			createCookie(cookie,"",-1);
	}
}
function initialize() {
	update_cookie(document.URL);
	updates();
}
window.onload = initialize;
