function Voter(inputId, containerId) {
	this.starImages = new Array();
	this.inputId = inputId;
	this.containerId = containerId;
	YAHOO.util.Event.addListener(window, 'load', this.initialize, this, true);
}

Voter.prototype = {
	
	inputId : null,
	
	starImages : null,
	
	containerId : null,
	
	maxScore : 10,
	
	onImage : 'images/starFull.gif',
	
	offImage : 'images/starEmpty.gif',
	
	initialize : function() {
		this.buildStars();
	},
	
	buildStars : function() {
		for(var i=1;i<11;i++) {
			var star = document.createElement('img');
			this.starImages[i] = star;
			star.id = 'starVoter_' + i;
			if(i <= document.getElementById(this.inputId).value) {
				star.src = this.onImage;
			}else {
				star.src = this.offImage;
			}
			YAHOO.util.Event.addListener(star, 'click', this.selectStar, this, true);
			YAHOO.util.Event.addListener(star, 'mouseover', this.hover, this, true);
			YAHOO.util.Event.addListener(star, 'mouseout', this.fillStars, this, true);
			document.getElementById(this.containerId).appendChild(star);
		}
	},
	
	fillStars : function() {
		for(var i=1;i<11;i++) {
			if(i <= document.getElementById(this.inputId).value) {
				this.starImages[i].src = this.onImage;
			}else {
				this.starImages[i].src = this.offImage;
			}
		}
	},
	
	selectStar : function() {
		document.getElementById(this.inputId).value = getDomByEvent(arguments[0]).id.substring(10);
		this.fillStars();
	},
	
	hover : function() {
		for(var i=1;i<11;i++) {
			this.starImages[i].style.cursor = 'pointer';
			if(i <= getDomByEvent(arguments[0]).id.substring(10)) {
				this.starImages[i].src = this.onImage;
			}else {
				this.starImages[i].src = this.offImage;
			}	
		}
	}
	
}