$(document).ready(function()
{
	function a(a,b)
	{
		var c = a.parents(".helpfulrater");
		
		//var d = a.parent(".plus").children(".thecount");
		//var e = a.parent(".minus").children(".thecount");
		
		var d = $(".plus").children(".thecount");
		var e = $(".minus").children(".thecount");
				
		var f = c.find(".hlp_votes");
		unit = c.children(".unit").html();
		
		article_id = c.children(".thisid").html();
		pluses = d.html();
		minuses = e.html();
		votes = f.html();
		$.post("https://www.tip-online.at/?rah_external_output=cbe_helpful_ajax",
				{
					article_id : article_id,
					up_down : b, 
					unit : unit
				},
				function(g)
				{
					d.html(parseInt(pluses)+g.plus);
					e.html(parseInt(minuses)+g.minus);
					c.find(".value").html(g.score);
					f.html(parseInt(votes)+1);
					$(".helpfulplus, .helpfulminus").unbind();
					$(".plus, .minus").addClass("inactive_rater");
					$("#helpful_response").html("Danke für Ihre Teilnahme");
				},
				"json");
	}
	$(".helpfulplus").click(
							function()
							{
								a($(this), "up");
								return false;
							}
						);
	$(".helpfulminus").click(
							function()
							{
								a($(this), "down");
								return false;
							}
						);
	$(".inactive_rater").click(
							function()
							{
								$("#helpful_response").html("Sie haben diesen Artikel bereits bewertet");
								$("#helpful_response").addClass("pad10 mar10 redBG");
								return false;
							}
						);
});
