// get url for rss feed
var url, maxN;

var info = document.getElementById('showTopN').innerHTML;
if (info) {
	info = info.split('|');
	url = info[1];
	maxN = info[0];
} else {
	url = 'http://www.novagraaf.nl/Rss/nl/Nieuws-Algemeen-NL';
	maxN = 3;
}

if (window.XMLHttpRequest) {
  xhttp = new XMLHttpRequest();
} else {
  xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

xhttp.open('GET', url, false);
xhttp.send("");
xmlDoc = xhttp.responseXML;

var topN = '';

for (i = 1; (i<=maxN && i<xmlDoc.getElementsByTagName('title').length); i++) {
	topN += '<li><a href="' + xmlDoc.getElementsByTagName('link')[i].childNodes[0].nodeValue + '">' + xmlDoc.getElementsByTagName('title')[i].childNodes[0].nodeValue + '</a></li>';
}

// only works for firefox
//document.getElementById('showTopNxml').innerHTML = topN;


// works for firefox AND IE
var newdiv = document.createElement('ul');
newdiv.innerHTML = topN;
var showTopNxml = document.getElementById('showTopNxml');
showTopNxml.appendChild(newdiv);