function createRequestObject() {
	var ro; var browser = navigator.appName
	if (browser == "Microsoft Internet Explorer") {
		ro = new ActiveXObject("Microsoft.XMLHTTP")
	}
	else {
		ro = new XMLHttpRequest()
	}
	return ro
}

var ajaxHttp = createRequestObject();

function sndReq(action) {
	if (!ajaxHttp) return false
	ajaxHttp.open('get', action)
	ajaxHttp.onreadystatechange = handleResponse
	//ajaxHttp.setRequestHeader('Content-Type', 'text/html; charset=windows-1251')
	//ajaxHttp.setRequestHeader('Content-Type', 'text/html; charset=utf-8')
	ajaxHttp.send(null)
}

function handleResponse() {
	if (ajaxHttp.readyState == 4) {
		var response = ajaxHttp.responseText
		var update = new Array()
		if (response.indexOf('|' != -1)) {
			update = response.split('|')
			//alert(update[0])
			//alert(update[1])
			if (targetEl = document.getElementById(update[0])) targetEl.innerHTML = update[1]
		}
	}
}

function voteForPost(postId, vote) {
	sndReq('/aj/vote-for-post.php?doc_id='+postId+'&vote='+vote)
}

function voteForComment(commentId, vote) {
	sndReq('/aj/vote-for-comment.php?comment_id='+commentId+'&vote='+vote)
}

function voteForUser(userId, vote) {
	sndReq('/aj/vote-for-user.php?user_id='+userId+'&vote='+vote)
}

