/**
 * @author tobias
 */

function starVoting(settings,wrap) {
	//$((wrap+" > div").addClass("starsEmpty");
	$(wrap+" > div").mouseover(function(){
		//alert(wrap);
		if ($(this).is(".starsEmpty")) {
			$(this).removeClass("starsEmpty");
			$(this).addClass("starsHover");
			$(this).prevAll().removeClass("starsEmpty");
			$(this).prevAll().addClass("starsHover");
			$(this).click(function(){
				//Klassen löschen begin
				$(this).removeClass("starsHover");
				$(this).removeClass("starsActive");
				$(this).removeClass("starsEmpty");
				
				$(this).prevAll().removeClass("starsHover");
				$(this).prevAll().removeClass("starsActive");
				$(this).prevAll().removeClass("starsEmpty");
				
				$(this).addClass("starsActive");
				$(this).prevAll().removeClass("starsHover");
				$(this).prevAll().addClass("starsActive");
				//$(this).nextAll().addClass("starsEmpty");
				//alert($(this).attr("title") + " / " + settings.page_uid);
				submitVoting(settings.page_uid, settings.type, settings.content_uid, $(this).attr("title"), wrap);
			});
		}
		else {
		}
	}).mouseout(function(){
		if ($(this).find("stars-wrapper1:first-child").is(".starsActive")) {
		
		}
		else {
			$(this).removeClass("starsHover");
			$(this).addClass("starsEmpty");
			$(this).prevAll().removeClass("starsHover");
			$(this).prevAll().addClass("starsEmpty");
		}
	});
};

function submitVoting(page_uid, type, content_uid, rating_result, wrap)
{
	$(wrap).fadeOut("slow", function ()
	{
		$.ajax({
			type: "POST",
			data: "tx_modernboard_pi1[action]=voting&tx_modernboard_pi1[voting][type]="+type+"&tx_modernboard_pi1[voting][content_uid]="+content_uid+"&tx_modernboard_pi1[voting][rating]="+rating_result,
			url: "index.php?id="+page_uid+"&type=73&view=VOTING",
			success: function(msg)
			{
            	$(wrap).html(msg);
            	$(wrap).fadeIn("slow");
			}
		});
	});
}