function positiongradeDiv(obj) {
if(document.getElementById("thevideograde").style.display=="none")
  document.getElementById("thevideograde").style.display="";
}
var UT_RATING_IMGS = '/images/fullstar.gif';
var UT_RATING_IMG_HOVERS = '/images/fullstar.gif';
var UT_RATING_IMG_HALFS = '/images/halfstar.gif';
var UT_RATING_IMG_BGS = '/images/blankstar.gif';
var UT_RATING_IMG_REMOVEDS = '/images/blankstar.gif';
var currentCommentDivWraper=null;
	
function UTRatings(ratingElementId, maxStars, objectName, formName, ratingMessageId, componentSuffix, size)
{
	this.ratingElementId = ratingElementId;
	this.maxStars = maxStars;
	this.objectName = objectName;
	this.formName = formName;
	this.ratingMessageId = ratingMessageId
	this.componentSuffix = componentSuffix

	this.starTimer = null;
	this.starCount = 0;

	if(size=='S') {
		UT_RATING_IMGS      = '';
		UT_RATING_IMG_HALFS = '';
		UT_RATING_IMG_BGS   = '';
	}
	
	// pre-fetch image
	(new Image()).src = UT_RATING_IMGS;
	(new Image()).src = UT_RATING_IMG_HALFS;
	
	function showStar(starNum, skipMessageUpdate) {
	 	
	 	if (currentCommentDivWraper==null) 
	 	currentCommentDivWraper=document.getElementById("div_rate")
		
		this.clearStarTimer();
		this.greyStar();
		this.colorStar(starNum);
		if(!skipMessageUpdate)
			this.setMessage(starNum);
	}

	function setMessage(starNum) {
		messages = new Array("  还行  ", "  还行  ", "  一般  ", "  好   ", "  很好  ", "  非常好 ");
		currentCommentDivWraper.getElementsByTagName("span")[0].innerHTML = messages[starNum];
		currentCommentDivWraper.getElementsByTagName("span")[2].innerHTML = starNum+".0";
		
	}

	function colorStar(starNum) {
	 	
		var i = 0;
		for (i=0; i <= starNum-1; i++)
			currentCommentDivWraper.getElementsByTagName("img")[i].src = UT_RATING_IMGS;
			
		if (i < starNum) {
			currentCommentDivWraper.getElementsByTagName("img")[i].src = UT_RATING_IMG_HALFS;
				
		}
	}

	function greyStar() {
		for (var i=0; i < this.maxStars; i++)
			if (i <= this.starCount)
				currentCommentDivWraper.getElementsByTagName("img")[i].src = UT_RATING_IMG_BGS; // UT_RATING_IMG_REMOVED;
			
			else
				currentCommentDivWraper.getElementsByTagName("img")[i].src = UT_RATING_IMG_BGS;
				
	}

	function setStar(starNum) {
		this.starCount = starNum;
		this.drawStar(starNum);
	
		document.forms[this.formName]['rating'].value = this.starCount;
		var ratingElementId = this.ratingElementId;
	}


	function drawStar(starNum, skipMessageUpdate) {
		this.starCount=starNum;
		this.showStar(starNum, skipMessageUpdate);
	}

	function clearStar() {

			if (currentCommentDivWraper==null) 
	 	currentCommentDivWraper=document.getElementById("commentWrapperDiv_0")
		
		this.starTimer = setTimeout(this.objectName + ".resetStar()", 300);
	}

	function resetStar() {
		this.clearStarTimer();
		if (this.starCount)
			this.drawStar(this.starCount);
		else
			this.greyStar();
		this.setMessage(1);
	}

	function clearStarTimer() {
		if (this.starTimer) {
			clearTimeout(this.starTimer);
			this.starTimer = null;
		}
	}

	this.clearStar = clearStar;
	this.clearStarTimer = clearStarTimer;
	this.greyStar = greyStar;
	this.colorStar = colorStar;
	this.resetStar = resetStar;
	this.setStar = setStar;
	this.drawStar = drawStar;
	this.showStar = showStar;
	this.setMessage = setMessage;

}



function vote(id, score) {
	currentCommentDivWraper.getElementsByTagName("span")[1].innerHTML = "正在打分，请等候...";
	currentCommentDivWraper.getElementsByTagName("span")[0].innerHTML = "操作结果：";
	setTimeout("sb_vote("+id+","+score+")",1000);
}

function sb_vote(id, score){
	var url = "/set_commend.asp";
	var pars = '?action=vote&id=' + id + '&score=' + score;	
	update_innerHTML('votebody',url+pars,false);
}


ratingComponents = new UTRatings('ratingDiv', 5, 'ratingComponents', '', 'ratingMessages', '', '');
ratingComponents.starCount= 1;
						
					
				

