function render_rating(block_id, rating) {
	var stars = document.getElementById(block_id).childNodes;
	if(!rating) rating = Math.round(document.getElementById(block_id).title);
	for(var i in stars) {
		if(stars[i].tagName && stars[i].tagName.match(/img/i)) {
			if(i < rating)
				stars[i].src = '/images/star.png';
			else
				stars[i].src = '/images/star-off.png';
		}//end if
	}//end for
}//end function

function save_rating(work_link, block_id, rating) {
	render_rating(block_id, 0);
	setTimeout(function(){ render_rating(block_id,1);  }, 400);
	setTimeout(function(){ render_rating(block_id,2);  }, 400*2);
	setTimeout(function(){ render_rating(block_id,3);  }, 400*3);
	setTimeout(function(){ render_rating(block_id,4);  }, 400*4);
	setTimeout(function(){ render_rating(block_id,5);  }, 400*5);
	setTimeout(function(){ render_rating(block_id,rating);  }, 400*6);
	new Ajax.Request(work_link, {
		method: 'post',
		contentType: 'application/hreview+xml',
		postBody: '<div class="hreview"><span class="rating">'+rating+'</span></div>',
		onSuccess: function(transport) {
		}
	});
	document.getElementById(block_id).title = rating;
	render_rating(block_id);	
}//end function
