$(function() {
  // Ajax chart voting
  var voting = new Voting();

  // Ajax photocontest voting
  var pvoting = new PVoting();

  $(".pcontest-gallery").each(function() {
    $("a", this).lightBox({ overlayOpacity: .75,
                            overlayCOlor: "#000",
                            txtImage: "Фото",
                            txtOf: "из",
                            txtClose: "Закрыть",
                            imageBtnPrev: '/i/lightbox/btn-prev.gif',
                            imageBtnNext: '/i/lightbox/btn-next.gif',
                            imageBtnClose: '/i/lightbox/btn-close.gif',
                            imageLoading: '/i/lightbox/ico-loading.gif',
                            fixedNavigation: false });
  });

  // Bookmarks
  $(".bookmarks .bookmarks-menu a").click(function() {
    var that = this;
    var $item = $(".bookmarks .bookmarks-content .bookmarks-content-item:visible");
    if ($item.attr("id") != that.rel) {
      $(".bookmarks .bookmarks-menu a.active").removeClass("active");
      $(that).addClass("active");
      $item.hide();
      $(".bookmarks .bookmarks-content #"+that.rel).show();
    }
    return false;
  });

  // Personal cab's file deleting features
  $(".file-del, .file-undel").click(function() {
    var $del = $(".file-del", this.parentNode);
    var $undel = $(".file-undel", this.parentNode);
    var $upload = $(this.parentNode);
    var $small = $("small", $upload);
    var $input = $("input", $upload);
    if ($input.attr("value") == 0) {
      $input.attr("value", 1);
      $small.css({visibility: "hidden"});
      $del.hide();
      $undel.show();
    } else {
      $input.attr("value", 0);
      $small.css({visibility: "visible"});
      $undel.hide();
      $del.show();
    }
    return false;
  });
  $(".del-warning").click(function() { if (!confirm("Вы уверены?")) return false; });
});
