function RatingController()
{
	var self=this;
	this.ref_err=null;
	this.ref_img=null;
	this.profilerate=function(profile_id,rate)
	{
		this.ref=profile_id;
		this.ref_err=document.getElementById('mesaj_err_vote');
		this.ref_img=document.getElementById('vote_place');
		this.ref_img.innerHTML='<img src="'+URL+'images/ajax-loader.gif" width="30" height="8">';
		data = new Object();
		data.profile_id = profile_id;
		data.vote = rate;
		$.post(URL+'index.php?page=utilizator&action=vote',data,function(data){
			RatingController.getInstance().profilerateresponse(data);
		},
		"json");		
	}
	
	this.profilerateresponse=function(data)
	{
		result=eval(data);
		
		this.ref_err.innerHTML=result[0]['value'];
		this.ref_img.innerHTML='';
		if(result.length==3)
		{
			document.getElementById('cur_rating').style.width=(result[2]['value']*22)+'px';
			document.getElementById('rate_votes').innerHTML=result[1]['value'];
			this.ref_err.innerHTML=result[0]['value'];
			return true;
		}
		else
		{
			this.ref_err.innerHTML=result[0]['value'];
			return false;
		}
				
		return true;					
	}
	this.picturerate=function(poza_id,rate)
	{
		this.ref=poza_id;
		this.ref_err=document.getElementById('mesaj_err_vote_poza');
		data = new Object();
		data.poza_id = poza_id;
		data.vote = rate;
		$.post(URL+'index.php?page=poza&action=vote',data,function(data){
			RatingController.getInstance().picturerateresponse(data);
		},
		"json");		
	}
	
	this.picturerateresponse=function(data)
	{
		result=eval(data);
		
		this.ref_err.innerHTML=result[0]['value'];
		if(result.length==3)
		{
			document.getElementById('cur_rating_poza').style.width=(result[2]['value']*22)+'px';
			document.getElementById('rate_votes_poza').innerHTML=result[1]['value'];
			this.ref_err.innerHTML=result[0]['value'];
			$('#mesaj_err_vote_poza').slideDown('slow',function(){$('#mesaj_err_vote_poza').slideUp(4000)});
			return true;
		}
		else
		{
			this.ref_err.innerHTML=result[0]['value'];
			$('#mesaj_err_vote_poza').slideDown('slow',function(){$('#mesaj_err_vote_poza').slideUp(4000)});
			return false;
		}
				
		return true;					
	}
}

RatingController.__instance__=null;
RatingController.getInstance=function()
{
	if(RatingController.__instance__==null)
	{
		RatingController.__instance__=new RatingController();
	}
	return RatingController.__instance__;
}