function init_star_rating(){
	star.num=0;
	star.make();
	star.num=1;
	star.make();
};

function getXY(e,v) { 
	var o=getAgent('msie')?{'X':event.clientX+document.documentElement.scrollLeft,'Y':event.clientY+document.documentElement.scrollTop-2}:{'X':e.pageX,'Y':e.pageY}; return(v?o[v]:o); 
}

function getAgent(s) { 
var k=navigator.userAgent.toLowerCase().indexOf(s);	
 if (k<0)
  k=0;
return k; 
}

function getPosition(t) { 
res={X:0,Y:0};
 if (typeof(t)!='object')
	t=$(t);
 while(t!=null) { 
  res.X+=t.offsetLeft; 
  res.Y+=t.offsetTop; 
  t=t.offsetParent; 
 }; 
return(res); 
}

star={};
star.is_end=false;

star.mouse=function(e,o){
 if (!(star.stop || isNaN(star.stop))) 
	return;
star.stop=0;

document.onmousemove=function(e){
	if (star.is_end) return;
 var n=star.num;
 var p=getPosition($('star'+n)), x=getXY(e), oX=x.X-p.X, oY=x.Y-p.Y; star.num=o.id.substr(4);
  if(oX<1 || oX>168 || oY<5 || oY>19) 				{
	  star.stop=1; 
 	  star.make();
   }	else {
	  $('starCur'+n).style.width=oX+'px';
	  $('starUser'+n).style.color='#111';
	  $('starUser'+n).innerHTML=Math.round(oX/168*100);
   }
 };
 
};

star.update=function(e,o) { 
var n=star.num;
var v=parseInt($('starUser'+n).innerHTML);
n=o.id.substr(4); 
$('starCur'+n).title=v;
$('star1').onmousemove='';
$('star1').onmousedown='';
$('star1').style.cursor='default';
star.is_end=true;
//alert(document.forms.param_form.folder_path.value+'ajax_rating.php?title_seo='+encodeURIComponent(document.forms.param_form.title_seo.value)+'&rating='+v+'&rnd='+Math.random());
makeRequest(document.forms.param_form.folder_path.value+'ajax_rating.php?title_seo='+encodeURIComponent(document.forms.param_form.title_seo.value)+'&rating='+v+'&rnd='+Math.random(),alertContents);
};

star.make=function() { 
var n=star.num;
	v=parseInt($('starCur'+n).title);
	$('starUser'+n).style.color='#888';
	$('starCur'+n).style.width=Math.round(v*168/100)+'px';
	$('starUser'+n).innerHTML=(v>0?Math.round(v)+'':'');
	document.onmousemove='';
};

function alertContents() {
if (http_request.readyState == 4) {
    if (http_request.status == 200) {
        var procent=http_request.responseText;
    		 if (procent==-1) {                //some error here
    		  alert('Sorry, error');
    		 }  else {
    		 	$('starCur0').title=procent;
        		star.num=0;
						star.make();
        		star.num=1;
				    $S('loading_rating_result').display='none';
				  }  

    } else {
        alert('There was a problem with the request.');
    }
}
else
		$('loading_rating_result').style.display='';
}

