var $starWidth;	//当前星星长度

//取得学校评分
function getScore() {
	$.getJSON("?namespace=school&controller=score&action=find&id="+$("#school_id").html(), function($result){
		if(!$result.school_id) {	//没有评分
			$result.score = 0;
			$result.total = 0;
		} else {
			$result.score = parseInt($result.score);
		}

		$("#score_star").width($result.score + "%");
		$("#score_score").html($result.score).css("float", "none");
		$("#score_total").html($result.total).css("float", "none");
		$starWidth = $result.score + "%";

		$("#frame_score").show();
	})
}

//显示软文
function showStory() {
	$("#story").css("height", "auto");
	$("#storyMore").remove()
}

$(document).ready(function(){
	getScore();	//查询评分

	$("#score_star_black").mousemove(function(event){	//鼠标移动
		var $offset = $(this).offset();
		var $width = event.screenX - $offset.left;

		if($width <= $(this).width()) {
			$("#score_star").width(event.screenX - $offset.left);
		}
		
	}).mouseout(function(){								//鼠标移出
		$("#score_star").width($starWidth);
	}).click(function(event){							//点击事件
		//计算分数
		var $offset = $(this).offset();
		var $score = parseInt((event.screenX - $offset.left) / $("#score_star_black").width() * 100);

		$.getJSON("?namespace=school&controller=score&action=update&id="+$("#school_id").html()+"&score="+$score, function($result){
			if($result.success) {
				$.hint("恭喜您！评分成功！");
				getScore();
			} else {
				$.hint($result.info);
			}
		})
	});

	$("#import_categoryset tr:odd").addClass("rank_trbg02");

	//热门院校去掉最后的线
	$("#hot_school tr:last td").addClass("nobot");

	//专业，双色表格
	$(".trbg2 table tr:odd").addClass("trbg");
	$(".trbg2 table tr:even").addClass("trbg02");
});

