function SimpleVotingSlider(handleStr, votingObjId, scale) {
	// Fields:
	this.voted = false;
	this.currentValue = 0;
	this.id = votingObjId; // the id of the thing we're voting on
	this.handleStr = handleStr;
	this.divId = this.handleStr + "_votingBlock";
	this.scale = scale;
	this.baseImage = new Image();
	this.baseImage.src = 'images/star.gif';
	this.hotImage = new Image();
	this.hotImage.src = 'images/star-over.gif';
	this.clickImage = new Image();
	this.clickImage.src = 'images/star-down.gif';
	this.votingElsArray = new Array();
	this.onVoteString = "";
	// Methods:
	this.draw = writeSimpleVoteSlider;
	this.submitVote = doAjaxVoting;
	this.setImages = setSliderImages;
	this.addVotingEl = addVotingElement;
}
// #########################################
function setSliderImages(baseImagePath, hotImagePath, clickImagePath) {
	this.baseImage.src = baseImagePath;
	this.hotImage.src = hotImagePath;
	this.clickImage.src = clickImagePath;
}
// #########################################
function addVotingElement(domElRef) {
	var newIndx = this.votingElsArray.length;
	this.votingElsArray.length++;
	this.votingElsArray[newIndx] = domElRef;
}
// #########################################
function writeSimpleVoteSlider() {
	mainDivWidth = 10 + (this.baseImage.width * this.scale);
	document.open();
	document.write('<div style="width: ' + mainDivWidth + '; cursor: pointer; cursor: hand;" id="' + this.divId + '" class="votingBlock" onclick="' + this.handleStr + '.submitVote();">');

	for (var i=0; i<this.scale; i++) {
		var imgId = this.handleStr + "_img_" + (i + 1);

		document.write('<img onclick="doVoterOnClick(' + this.handleStr + ', this);" onmouseover="doVoterMouseEvent(' + this.handleStr + ', this, \'mouseover\');" onmouseout="doVoterMouseEvent(' + this.handleStr + ', this, \'mouseout\');" id="' + imgId + '" src="' +  this.baseImage.src + '" />');
		this.addVotingEl(document.getElementById(imgId));

	} // end for...
	document.write('</div>');
	document.close();

}
// #########################################
function doAjaxVoting() {
    var me = this;
    if (this.voted) {
        return false;
    }

    var reqUrl = 'ajax_requests/profile_vote_handler.php';
    var params = 'score=' + this.currentValue + '&subjectId=' + this.id;
    $.ajax({
        type: 'POST',
        url: reqUrl,
        data: params,
        success: function(r_text)
        {
            $('#' + me.divId).html(r_text);
        }
    });
    if (this.onVoteString != "") {
        eval(this.onVoteString);
    }
    this.voted = true;
}

// #########################################
function doVoterOnClick(voterObj, thisRef) {
	try {
		var thisIm = document.getElementById(thisRef.id);
		thisIm.src = voterObj.clickImage.src;
	} catch (e) {

	}
}

// #########################################
function doVoterMouseEvent(voterObj, el, inOrOutString) {

	if (inOrOutString == "mouseout") {
		var dir = "mouseout";
		var newSrc = voterObj.baseImage.src;
	} else {
		var dir = "mouseover"
		var newSrc = voterObj.hotImage.src;
	}



	var tmp = el.id.split("_");
	var indx = parseInt(tmp[tmp.length - 1]);
	voterObj.currentValue = indx;
	//var tstForm = eval("document.form_" + voterObj.handleStr);
	//tstForm.elements.test.value = voterObj.currentValue;


	for(var i=0; i<indx; i++) {

		try {
			voterObj.votingElsArray[i].src = newSrc;
		} catch (e) { alert(e); }
	} // for loop
} // end doVoterMouseover function
// #########################################