function post_item_plus_logged(say_id, index) {

	if (!post_item_vote_post(say_id, 1))
		return;

	document.getElementById("plus_img_" + index).src = "main/img/general/green_hand_done.gif";
	document.getElementById("minus_img_" + index).src = "main/img/general/red_hand_done.gif";
	post_item_deactivate(index);

	post_item_votes("+", index);

}

///////////////////////////////////////////////////////////////////////////////////

function post_item_minus_logged(say_id, index) {

	if (!post_item_vote_post(say_id, 0))
		return;

	document.getElementById("minus_img_" + index).src = "main/img/general/red_hand_done.gif";
	document.getElementById("plus_img_" + index).src = "main/img/general/green_hand_done.gif";
	post_item_deactivate(index);

	post_item_votes("-", index);
}

///////////////////////////////////////////////////////////////////////////////////

function post_item_plus_not_logged(index) {

	document.getElementById("vote_message_" + index).style.display = "block";
}

///////////////////////////////////////////////////////////////////////////////////

function post_item_minus_not_logged(index) {

	document.getElementById("vote_message_" + index).style.display = "block";
}

///////////////////////////////////////////////////////////////////////////////////

function post_item_deactivate(index) {

	document.getElementById("plus_" + index).removeAttribute("href");
	document.getElementById("minus_" + index).removeAttribute("href");
	document.getElementById("plus_" + index).onclick = null;
	document.getElementById("minus_" + index).onclick = null;
}

///////////////////////////////////////////////////////////////////////////////////

function post_item_votes(op, index) {

	var votes_obj = document.getElementById("post_item_votes_" + index);
	var s = general_getSpanValue(votes_obj);
	var sign = s.substr(0, 1);
	if (sign == "0")
		votes = 0;
	else
	if (sign == "+")
		votes = s.substr(1, s.length -1) * 1;
	else
		votes = s.substr(1, s.length -1) * -1;
	if (op == "+")
		votes = votes + 1;	
	else
		votes = votes - 1;
	if (votes > 0)
		votes = "+" + votes;
	else
	if (votes == 0)
		votes = " 0";

	general_setSpanValue(votes_obj, votes);
}

///////////////////////////////////////////////////////////////////////////////////

function post_item_vote_post(sayId, val) {
	
	var poststr = "sayId=" + encodeURI(sayId) + "&rank=" + encodeURI(val);
	ajax_makePOSTRequestSync("RankSay.jsp", poststr, null, document.getElementById("dynamic_list_vote_result"));
	var result = document.getElementById("dynamic_list_vote_result").value;
	if (result.indexOf("Err 1000") >= 0 || result.indexOf("Err 5000") >= 0)
		return false;
	return true;
}

///////////////////////////////////////////////////////////////////////////////////

function post_item_tweet(say_id) {

	var tweet_url = "http://twitter.com/home?status=http://neatlysaid.com/post.jsp?sayId=" + say_id;
	window.open(tweet_url,'_blank');
}