var matty_ajax_handle = null;

function mattySendAjax(url, responsefunc) {
	matty_ajax_handle = new XMLHttpRequest();
	matty_ajax_handle.onreadystatechange = mattyReceiveAjax;
	matty_ajax_handle.open('get',url,true);
	matty_ajax_handle.send(null);
	matty_ajax_handle.responsefunc = responsefunc;
}

function mattyReceiveAjax() {
	if (matty_ajax_handle.readyState == 4) {
		if (matty_ajax_handle.status == 200) {
			response = matty_ajax_handle.responseXML.documentElement;
			matty_ajax_handle.responsefunc(response);
		}
	}
}

function mattyVoteUp(topic,member) {
	mattySendAjax("matty/newsvote.ajax.php?dir=up&topic_id=" + topic + "&member=" + member, mattyVoteResult);
}
function mattyVoteDown(topic,member) {
	mattySendAjax("matty/newsvote.ajax.php?dir=down&topic_id=" + topic + "&member=" + member, mattyVoteResult);
}
function mattyVoteResult(response)
{
	var topic = response.getElementsByTagName('topic')[0].firstChild.data;
	var result = response.getElementsByTagName('result')[0].firstChild.data;
	var score = response.getElementsByTagName('score')[0].firstChild.data;
	var up = document.getElementById("newsvote" + topic + "up");
	var down = document.getElementById("newsvote" + topic + "down");
	var number = document.getElementById("newsvote" + topic + "score");
	up.setAttribute("disabled", true);
	up.setAttribute("href", "javascript:void(0);");
	up.style.background = 'none';
	up.style.cursor = 'cursor';
	up.style.opacity = 0.2;
	up.firstChild.style.filter = 'alpha(opacity=20)';
	down.setAttribute("disabled", true);
	down.setAttribute("href", "javascript:void(0);");
	down.style.background = 'none';
	down.style.cursor = 'cursor';
	down.style.opacity = 0.2;
	down.firstChild.style.filter = 'alpha(opacity=20)';
	number.innerHTML = score;
}