var uPowers = function() {
	return {
		LikeComment : function(s_Id) {
			$.get("/logic/action/like-comment/" + s_Id + ".aspx");
		},
		DislikeComment : function(s_Id, s_comment) {
			$.post("/logic/action/dislike-comment/" + s_Id + ".aspx", {comment: s_comment} );
		},
		LikeQuestion : function(s_Id) {
			$.post("/logic/action/like-question/" + s_Id + ".aspx");
		},
		LikeGirl : function(s_Id) {
			$.post("/logic/action/like-girl/" + s_Id + ".aspx");
		}
	};
}();

function updateScore(point, className, text, obj){
	var p = obj;
	jQuery('a', p).hide();
	var score = jQuery('span.itemindent', p);
	score.text(parseInt(score.text()) + point).show();
	//var voteword = jQuery('span.vote-word', p);
	//voteword.text(text).show();
	score.append("<span class='vote-word'><span style='width:40px; font-size:14px; padding:2px 0 2px 0; margin-bottom:4px; color:#fff; background-color:#090; text-align:center; display:block; font-family:Tahoma;'>OK!</span></span>");
	//p.effect('highlight');
}

function updateGScore(point, className, text, obj){
	var p = obj;
	jQuery('a.LikeGirl', p).hide();
	var score = jQuery('span.votesq', p);
	score.text(parseInt(score.text()) + point).show();
	//var voteword = jQuery('span.vote-word', p);
	//voteword.text(text).show();
	p.append("<span style='чwidth:40px; font-size:14px; padding:2px 0 2px 0; margin-bottom:4px; margin-top:12px; color:#fff; background-color:#090; text-align:center; display:inline-block; font-family:Tahoma;'>Дякую що проголосував за мене!</span>");
	//p.effect('highlight');
}

jQuery(document).ready(function(){
	
	jQuery("a.LikeComment").click(function(){
		uPowers.LikeComment(jQuery(this).attr("rel"));
		updateScore(1, 'like', 'Like', jQuery(this).parent());
		return false;
	});

	jQuery("a.DisLikeComment").click(function(){
		CreateModal(jQuery(this), "Constructive criticism", "Please add a short comment so the author knows why you do not like this comment", uPowers. DislikeComment
		, function(obj){ updateScore(-1, 'dislike', "Don't like", obj ) });
		
		return false;
	});

	jQuery("a.vote").click(function(){
		uPowers.LikeQuestion(jQuery(this).attr("rel"));
		updateScore(1, 'like', 'Дякуєм', jQuery(this).parent().parent());
		return false;
	});
	
	jQuery("a.LikeGirl").click(function(){
		uPowers.LikeGirl(jQuery(this).attr("rel"));
		updateGScore(1, 'like', 'Дякуєм', jQuery(this).parent());
		return false;
	});

});
