function $(id) {
	return document.getElementById(id);
}

var vote_sizes = {standard: [21, 105], mini: [11, 55]};

function votes_init(v, mini) {
	votes = {
		content: document.voteform.content,
		estetic: document.voteform.estetic,
		feeling: document.voteform.feeling
	};

	votes.content.value = v[0];
	votes.estetic.value = v[1];
	votes.feeling.value = v[2];

	var s = mini ? vote_sizes['mini'] : vote_sizes['standard'];

	for (var t in votes) $('votes_'+t).style.backgroundPosition = (parseInt(votes[t].value) * s[0] - s[1])+'px 0';
}

function votes_read(obj, ev, s) {
	ev = ev || window.event;

	var x = ev.layerX || ev.offsetX;
	// var y = ev.layerY || ev.offsetY;

	return Math.floor(x / s[0]) + 1;
}

function votes_onmove(obj, ev, mini) {
	var s = mini ? vote_sizes['mini'] : vote_sizes['standard'];
	var vote = votes_read(obj, ev, s);

	obj.style.backgroundPosition = (vote * s[0] - s[1])+'px 0';
}

function votes_onout(obj, ev, mini) {
	var t = obj.id.substr(obj.id.indexOf('_')+1);

	var s = mini ? vote_sizes['mini'] : vote_sizes['standard'];
	obj.style.backgroundPosition = (parseInt(votes[t].value) * s[0] - s[1])+'px 0';
}

function votes_click(obj, ev, mini) {
	var t = obj.id.substr(obj.id.indexOf('_')+1);
	var s = mini ? vote_sizes['mini'] : vote_sizes['standard'];

	votes[t].value = votes_read(obj, ev, s);
}
