var starGo='';

function $1(v) {
  return(document.getElementById(v));
}

function agent(v) {
  return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0));
}

function xy(e,v) {
 return(v?(agent('msie')?event.clientY+document.body.scrollTop:e.pageY):(agent('msie')?event.clientX+document.body.scrollTop:e.pageX));
}

function starUpdate(e) {

  var v=parseInt($1('starUser').innerHTML);
   $1('starCurr').title=v;

   document.getElementById('starUser').style.display='none';

   url = 'magazin_virtual/ajax_star.php?vote='+v
   //alert(url)
   xmlHttp=GetXmlHttpObject()
   xmlHttp.onreadystatechange = stateChanged_star
   xmlHttp.open('GET',url, true);
   xmlHttp.send(null);
}

function starRevert() {
  var v=parseInt($1('starCurr').title);
  $1('starCurr').style.width=Math.round(v*84/100)+'px';
  $1('starUser').innerHTML=(v>0?Math.round(v)+'%':'');
  $1('starUser').style.color='#888';
  document.onmousemove='';
}

function starCurr(e) {

  function starMove(e) {

    var eX=xy(e)-$1('star').offsetLeft,eY=xy(e,1)-$1('star').offsetTop;

    if(eX<1 || eX>84 || eY<0 || eY>19) {
      starGo='';
      starRevert();
    }
    else {
      $1('starCurr').style.width=eX+'px';
      $1('starUser').style.color='#111';
      $1('starUser').innerHTML=Math.round(eX/84*100)+'%';
    }

  }

  if(!starGo) { starGo=1; document.onmousemove=starMove; }

}

function stateChanged_star()
{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{

document.getElementById("starUser_ajax").innerHTML=xmlHttp.responseText
}
}

function GetXmlHttpObject()
{
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}


