function UTRating(ratingElementId, maxStars, objectName, formName, ratingMessageId, componentSuffix, size, messages)
{

	this.ratingElementId = ratingElementId;
	this.maxStars = maxStars;
	this.objectName = objectName;
	this.formName = formName;
	this.ratingMessageId = ratingMessageId
	this.componentSuffix = componentSuffix
	this.messages = messages;

	this.starTimer = null;
	this.starCount = false;
		
	// pre-fetch image

	(new Image()).src = UT_RATING_IMG;
	(new Image()).src = UT_RATING_IMG_HALF;

	function showStars(starNum, currectRate, skipMessageUpdate) {
		//alert(starNum)
		this.starCount = Math.ceil(currectRate/2);
		
		this.clearStarTimer();
		
		this.greyStars();
		
		this.colorStars(starNum);
		if(!skipMessageUpdate)
			this.setMessage(starNum, messages);
	}

	function setMessage(starNum) {
//		messages = new Array("Rate this video", "Poor", "Nothing special", "Worth watching", "Pretty cool", "Awesome!");
		document.getElementById(this.ratingMessageId).innerHTML = this.messages[starNum];
	}

	function colorStars(starNum) {
		for (var i=0; i < starNum; i++) {
			document.getElementById('star_'  + this.componentSuffix + "_" + (i+1)).src = UT_RATING_IMG;
		}
	}

	function greyStars() {
		
//alert(this.maxStars);
		for (var i=0; i < this.maxStars; i++)
			if (i <= this.starCount) {
				document.getElementById('star_' + this.componentSuffix + "_"  + (i+1)).src = UT_RATING_IMG_BG;
			}
			else
			{
				document.getElementById('star_' + this.componentSuffix + "_"  + (i+1)).src = UT_RATING_IMG_BG;
			}
		
		//alert(UT_RATING_IMG_BG);
	}

	function setStars(starNum) {
	
	//	this.starCount = starNum;
		this.drawStars(starNum);
		document.forms[this.formName]['rating'].value = this.starCount;
		var ratingElementId = this.ratingElementId;
		postForm(this.formName, true, function (req) { replaceDivContents(req, ratingElementId); });
	}


	function drawStars(starNum, skipMessageUpdate) {
		//this.starCount=starNum;
		this.showStars(starNum, skipMessageUpdate);
	}

	function clearStars() {
		this.starTimer = setTimeout(this.objectName + ".resetStars()", 300);
	}

	function resetStars() {
	//alert(this.starCount)
		this.clearStarTimer();
		if (this.starCount)
			this.drawStars(this.starCount);
		else
			this.greyStars();
		this.setMessage(0);
	}

	function clearStarTimer() {
		if (this.starTimer) {
			clearTimeout(this.starTimer);
			this.starTimer = null;
		}
	}
	this.clearStars = clearStars;
	this.clearStarTimer = clearStarTimer;
	this.greyStars = greyStars;
	this.colorStars = colorStars;
	this.resetStars = resetStars;
	this.setStars = setStars;
	this.drawStars = drawStars;
	this.showStars = showStars;
	this.setMessage = setMessage;

}

//for ratig list (from Youtube)
var image_url = document.getElementById('imgurl_star').value;
var UT_RATING_IMG      = image_url+'/general/bighouse_1.gif';//+imgExt;
var UT_RATING_IMG_HALF = image_url+'/general/bighouse_1.gif';
var UT_RATING_IMG_REMOVED = image_url+'/general/bighouse_0.gif';
var UT_RATING_IMG_BG = image_url+'/general/bighouse_0.gif';


		onLoadFunctionList = new Array();
		function performOnLoadFunctions()
		{
			for (var i in onLoadFunctionList)
			{
				onLoadFunctionList[i]();
			}
		}

	messages = new Array("Rate this video", "Poor", "Nothing special", "Worth watching", "Pretty cool", "Awesome!");
	ratingComponent = new UTRating('ratingDiv', 5, 'ratingComponent', 'ratingForm', 'ratingMessage', '', 'L', messages);

	if (document.getElementById('starcount_1').value=='0') starcount_1=0;
		else starcount_1=document.getElementById('starcount_1').value;
	ratingComponent.starCount=starcount_1/2;//=document.getElementById('starcount_1').value/2;

//			onLoadFunctionList.push(function() { ratingComponent.drawStars(0, true); });
			onLoadFunctionList.push(function() { ratingComponent.drawStars(ratingComponent.starCount, true); });



if ((navigator.appVersion.indexOf('MSIE') > -1) && (typeof window.XMLHttpRequest == 'undefined')) {
imgExt = '.gif';
}
else
{
imgExt = '.png';
}




