/*rating*/
$(function(){
	$("div.panel ul.bttns_bg a").bind("click",function(){return false});
});
var c_rating=0;
function rating(id){
	var rate=$("span.percent"+id+"").attr("title");
	if(c_rating==0){$("span.rating span.graphic"+id+"").css({width:""+rate*150/100+"px"});}
	if(c_rating==1){$("span.rating span.graphic"+id+"").animate({width:""+rate*150/100+"px"},1700);c_rating=0;}
	if((rate>=0) && (rate<30)){$("span.rating span.graphic"+id+"").css({background:"#ff9696"});}
	if((rate>=30) && (rate<60)){$("span.rating span.graphic"+id+"").css({background:"#ffff96"});}
	if((rate>=60) && (rate<=100)){$("span.rating span.graphic"+id+"").css({background:"#96ff96"});}
}
function rated(id){
	$("div.panel ul.bttns_bg a:lt("+id+")").addClass('selected');
	if(id==0){rate_bttns();}
}
function rate_bttns(id){
	$("div.panel ul.bttns_bg a").bind("mouseover",function(){
		var c_rate_btn=$(this).attr("title");
		$("div.panel ul.bttns_bg a:lt("+c_rate_btn+")").addClass('selected');
		$("div.panel ul.bttns_bg a:gt("+c_rate_btn+")").removeClass('selected');
	})
	.bind("mouseout",function(){
		$("div.panel ul.bttns_bg a").removeClass('selected');
	})
	.bind("click",function(){
		$("div.panel ul.bttns_bg a").unbind().bind("click",function(){return false});		   
		var c_rate_btn=$(this).attr("title");
		$.ajax({type:"POST",url:"contents/user_rating.php",data:"rate="+c_rate_btn+"&otelid=45",success:function(msg){
			$("span.percent1").html(""+msg+"").attr("title",""+msg+"");
			$("div.panel ul.bttns_bg a:lt("+c_rate_btn+")").addClass('selected');
			$("span.rating span.graphic1").css({width:"1px"});
			c_rating=1;rating(1);
		}});
		return false
	});
}
