aVoteWords = Array ("Poor", "Nothing special", "Worth watching", "Pretty cool", "Awesome!");
	
function voteMouseOver (ev, mid, isvoted) {
  if (isvoted == true) {
    $("currentVoteState"+mid).innerHTML = "You have already rated.";
    $("currentVoteState"+mid).focus();
    return;
  }
  $("movieLinkVote"+mid).style.background="url('images/rating02.jpg')"
  var x = ev.layerX | ev.offsetX;
//  alert (x);
  var rate = Math.ceil(x/120*5);
  x = 24*rate;
//  alert (x);
  $("movieVote"+mid).style.clip='rect(auto auto auto '+x+'px)';
  if (aVoteWords[rate-1]!=undefined) {
    $("currentVoteState"+mid).innerHTML = aVoteWords[rate-1];
  }
  $("currentVoteState"+mid).focus();
  return false;
}

function voteMouseOut (ev, mid, x, y, j) {
  $("movieVote"+mid).style.clip='rect(auto auto auto '+x+'px)';
//  $("currentVoteState"+mid).innerHTML = y;
  if (j < 10) {
    $("movieLinkVote"+mid).style.background="url('images/rating02.jpg')"
  }
  return false;
}
	
function sendVote (ev, mid) {
  if ($("movieLinkVote"+mid).onmouseout == null) {
  	return false;
  }
  $("movieLinkVote"+mid).onmouseout  = null
  $("movieLinkVote"+mid).onmousemove = null
  var x = ev.layerX | ev.offsetX;
  var rate = Math.ceil(x/120*5);
//alert (window.location.href+'?ajax=1&act=ratemovie&mid='+mid+"&v="+rate);
  new Ajax.Request(window.location.href+'?ajax=1&act=ratemovie&mid='+mid+"&v="+rate, {
  method: 'get',
  onSuccess: function(transport) {
    if (transport.responseText.match (/^ERROR/)) {
      alert (transport.responseText);
    } else {
      $("currentVoteState"+mid).voted = true;
      try {
      	eval (transport.responseText);
      } catch (e) {
        $("currentVoteState"+mid).innerHTML = transport.responseText;
      }
    }
  },
  onFailure : function (transport) {
    
  	alert ("Ooops. Could not process your request now. Please try again later.");
  }
  });
}

