var otherNewsCategories = ["Algemeen", "Economie", "Sport", "Boulevard", "Opmerkelijk"];
var otherNewsLinks = ["algemeen", "economie", "sport", "achterklap", "opmerkelijk"];

function loadNews(index) {
	var postData = "cat=" + otherNewsLinks[index];

	var url = "ajax/nieuws.php";
	
	var handleSuccess = function(o) {
		if (o.responseText !== undefined) {
			document.getElementById("newsLinks").innerHTML = o.responseText;
		}

		var root = document.getElementById("otherNewsList");
		while (root.hasChildNodes()) {
			root.removeChild(root.childNodes[0]);
		}

		var first = true;
		for (var i = 0; i < otherNewsCategories.length; i++) {
			if (i != index) {
				var li = document.createElement("li");
				if (first) {
					li.className = "first";
					first = false;
				}
				var a = document.createElement("a");
				a.href = "javascript:loadNews(" + i + ")";
				a.appendChild(document.createTextNode(otherNewsCategories[i]));
				li.appendChild(a);
				root.appendChild(li);
			}
		}
	}
	
	var handleFailure = function(o) {
	}

	var callback = {
		success: handleSuccess,
		failure: handleFailure
	};

	var request = YAHOO.util.Connect.asyncRequest('POST', url, callback, postData);
}
