
		$(function(){
			$("#avg").children().not(":input").hide();
			$("#rat").children().not("select, #messages").hide();
			var idk= $("#id").val();
			var source= $("#source").val();
			var userID= $("#userID").val();
		
			$("#avg").stars();
			
	
			$("#rat").stars({
				inputType: "select",
				cancelShow: false,
				captionEl: $("#caption"),
				callback: function(ui, type, value)
				{
				
					ui.disable();

				
					$("#messages").text("Zapisywanie...").stop().css("opacity", 1).fadeIn(30);
					
					
					$.post("/ajaxRating.php", {rate: value,id: idk, source: source, userID: userID}, function(db)
					{

							$("#avg").stars("select", Math.round(db.avg));
							
							
							$("#all_votes").text(db.votes);
							$("#all_avg").text(db.avg);
							
						
							$("#messages").text("Dziekujemy za glos").stop().css("opacity", 1).fadeIn(30);
							
					
							setTimeout(function(){
								$("#messages").fadeOut(1000)
							}, 2000);
					}, "json");
				$("#tit").text("Twoja ocena");
				$("#caption").text("");
				}
			});

	
			$("#rat").stars("selectID", -1);
			
	
			$('<div id="messages"/>').appendTo("#rat");
		});
