document.documentElement.className += " nojs";

$(document).ready(function(){
  //hide NOJS warning
  //document.documentElement.className += " nojs";
  //$('#jswarning').remove();

  // fix NOJS links in header
  $('body').find('a[href$=-bez-js]').each(function(){
    saveText = this.title;
    newLink = this.href.replace('-bez-js','');
    this.href = newLink;
    if (saveText != '') {
      $(this).text(saveText);
    }
  });

  // prepare rating form
  $('#ohodnot label').hide();
  $('#ohodnot .submit').hide();
  $("#jsenabled").val("true");
  $('#item-rating').stars({
    cancelShow: false,
    captionEl: $('#stars-cap'),
    oneVoteOnly: true,
    callback: function(ui, type, value)
    {
      $('#ohodnot').ajaxSubmit({ 
          dataType: 'json', 
          success: function(data)
          {
            if (data.message == undefined) {
              //$("#fake-stars-on").width(Math.round( $("#fake-stars-off").width() / ui.options.items * parseFloat(data.avg) ));
              $("#item-rating").stars("select", Math.round(data.avg));
              $("#fake-stars-cap").text(data.avg + " (" + data.votes + "x)");
            } else {
              //$("#fake-stars-cap").text(data.message);
              alert(data.message);
            }
          }
      });
    }
  });
});;;