function star(itemID, ratingPoint, who, where){

      var tmp = '';
      var $was = false;
      var span = document.getElementById(itemID);
      for (q=0; q < span.childNodes.length ; q++)
      {
        var obj = span.childNodes[q];
        if(obj.href!= null)
        {
          tmp += obj.innerHTML;
          //obj.href = null;
        }else{
          if (q > 1 && !$was)
          {
            tmp += " <strong>Wait...</strong>";
            $was = true;
          }
        }
      }
      document.getElementById(itemID).innerHTML = tmp;

  var opt = {
      method: 'post',
      postBody: 'itemID='+ itemID + '&ratingPoint='+ ratingPoint + '&cardItemID='+ itemID + '&gallaryImagesID='+ itemID + '&who=' + who,
      onSuccess: function(t) {
      if (t.responseText != 'null;')
      {
        eval(t.responseText);
        code='';
          for (var x=1; x<=5; x++){
            if (x <= stars['count']){
              if (stars['ishref']=='true'){
                if (where == 'main'){
                  code += "<a href='javascript:star("+itemID+","+x+","+who+")' title='"+x+"'><img src='/images/stars/star1.gif' width='18' height='18' alt='"+x+"' border='0' align='absmiddle'></a>"
                }
                else{
                  code += "<a href='javascript:star("+itemID+","+x+","+who+")' title='"+x+"'><img src='/images/stars/star1_.gif' width='18' height='18' alt='"+x+"' border='0' align='absmiddle'></a>"
                }
              }
              else{
                if (where == 'main'){
                  code += "<img src='/images/stars/star1.gif' width='18' height='18' alt='"+x+"' border='0' align='absmiddle'>"
                }
                else{
                  code += "<img src='/images/stars/star1_.gif' width='18' height='18' alt='"+x+"' border='0' align='absmiddle'>"
                }
              }
            }
            else{
              if (stars['ishref']=='true'){
                if (where == 'main'){
                  code += "<a href='javascript:star("+itemID+","+x+","+who+")' title='"+x+"'><img src='/images/stars/star2.gif' width='18' height='18' alt='"+x+"' border='0' align='absmiddle'></a>"
                }
                else{
                  code += "<a href='javascript:star("+itemID+","+x+","+who+")' title='"+x+"'><img src='/images/stars/star2_.gif' width='18' height='18' alt='"+x+"' border='0' align='absmiddle'></a>"
                }
              }
              else{
                if (where == 'main'){
                  code += "<img src='/images/stars/star2.gif' width='18' height='18' alt='"+x+"' border='0' align='absmiddle'>"
                }
                else{
                  code += "<img src='/images/stars/star2_.gif' width='18' height='18' alt='"+x+"' border='0' align='absmiddle'>"
                }
              }
            }
          }
          code += " <strong>(" +  stars['amount'] + ") Votes</srong>";

          document.getElementById(itemID).innerHTML = code;
      }
      },
      on404: function(t) {
        alert('Error 404: location "' + t.statusText + '" was not found.');
      },
      onFailure: function(t) {
        alert('Error ' + t.status + ' -- ' + t.statusText);
      }
    }
  new Ajax.Request('/stars.php', opt);
}

function write_stars()
{
  $txt = "";
  for ($q = 0; $q < 5; $q++)
  {
    $txt += "<img src='/images/stars/star2.gif' width='18' height='18' alt='' border='0' align='absmiddle'>";
  }
  return $txt;
}