var NUM_OF_STARS = 5;
var ie4=document.all
var ns6=document.getElementById&&!document.all

/* Crea le stelline con il rating dei voti
*/
function votomedio(rate) {
   var len = parseInt(rate*20);

   for (i=1; i<=NUM_OF_STARS; i++) {
      var wid = Math.max(Math.min(20,len),0);
      document.write('<div class="floatL h10 bgstar" style="cursor:pointer;" ');
      document.write(' onclick="starclick('+i+')" onmouseover="starover('+i);
      document.write(')" onmouseout="starout('+rate+')">');
      document.write('<a href="'+document.location+'&vote='+i+'">');
      document.write('<span class="floatL bgstarY" '+'id="star'+i+'" style="width:' + wid + 'px;">&#160;</span>');
      document.write('</a></div>');
//      document.write('<span class="floatL bgstarY" '+'id="star'+i+'" style="width:' + wid + 'px;">&#160;</span></div>');
      len = len-20;
   }
}

/* Si posiziona su una stella per votare
 * Evidenzia le stelle fino a quella selezionata
 */
function starover(pos) {
   for (i=1; i<=NUM_OF_STARS; i++) {
      var star = document.getElementById('star' + i);
      if (i<=pos) {
         if (! ie4) {
            star.setAttribute('style','width:20px;');
         }
         else {
            star.style.width='20';
         }
      }
      else {
          if (! ie4)
             star.setAttribute('style','width:0px;');
          else
             star.style.width='0';
      }
   }
}

/* Esce dalla stella.
 * Ridisegna il rating dei voti
 */
function starout(rate) {
   var len = parseInt(rate*20);
//document.write("RATE:"+rate+"   LEN:"+len);
   for (i=1; i<=NUM_OF_STARS; i++) {
      var star = document.getElementById('star' + i);
      var wid = Math.max(Math.min(20,len),0);

      if (! ie4) {
         star.setAttribute('style','width:' + wid + 'px;');
      }
      else {
         star.style.width = wid;
      }
      len = len-20;
   }
}
