var vote_connection = '';
function saveRating(rating, item_id) {
	ran = Math.round(Math.random()*100000); 
	url = "/functions/vote/save.php?ItemId="+item_id+"&Rating="+rating;

	if (window.XMLHttpRequest) {
		vote_connection = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		vote_connection = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (vote_connection) {
		vote_connection.open("GET",url,true);
		vote_connection.send(null);
		vote_connection.onreadystatechange=saveRatingEval
	}
}

function removeRating(item_id) {
	ran = Math.round(Math.random()*100000); 
	url = "/functions/vote/remove.php?ItemId="+item_id;

	if (window.XMLHttpRequest) {
		vote_connection = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		vote_connection = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (vote_connection) {
		vote_connection.open("GET",url,true);
		vote_connection.send(null);
		vote_connection.onreadystatechange=saveRatingEval
	}
}

function saveRatingEval() {
	if (vote_connection.readyState==4) {
		if (vote_connection.status==200){
			eval(vote_connection.responseText);
		}
	}
}

function saveReviewRating(rating) {
	document.getElementById('review_vote_visual').style.width = (rating*20)+'px';
	document.getElementById('review_vote').value = rating;
	document.getElementById('review_vote_text').innerHTML = rating+'/5 | <a href="javascript:removeReviewRating();">'+remove_rating+'</a>';
}

function removeReviewRating(rating, no_rating_text) {
	document.getElementById('review_vote_visual').style.width = '0px';
	document.getElementById('review_vote').value = '';
	document.getElementById('review_vote_text').innerHTML = no_rating;
}