$(document).ready(function()
  {
    // detail filmu
    $(".info-full").hide();

    $('p.info-toggle').click(function() {
      $(this).next(".info-full").slideToggle(200);
      $(this).children("a").text($(this).text() == 'Podrobné info' ? 'Skryť podrobné info' : 'Podrobné info');
      $(this).children("a").toggleClass("open");
      return false;
    });
    // vyradit stary JS partneri
    $(".obsah h3").attr("onclick", "");
    $("#partneri").attr("style", "");

    // lightbox
    $(".film-plakat-orig").lightBox();
    $("#fotogalerie .img-in a").lightBox();
    $("#download-box a.img").lightBox();

    // fotogalerie
    $("#ostatni-fotky").hide();
    $("p.vsechny-fotky a").click(function () {
      if ($(this).hasClass("hide")) {
        $("#ostatni-fotky").hide();
        $(this).removeClass("hide");
        $(this).text("Zobraziť všetky fotografie");
      }
      else
      {
        $("#ostatni-fotky").show();
        $(this).addClass("hide");
        $(this).text("Skryť ostatné fotografie");
      }
    })

    // prihlaseni press zone
    $("#pn-user").click(function () {
      $(this).attr("value", "");
    })
    $("#pn-psw").click(function () {
      $(this).attr("value", "");
    })

    // vyhledani
    var $textik = "Vyhľadanie..."
  
    $("#sb-text").attr("value", $textik);

    $("#sb-text").blur(function () {
      if (!$(this).attr("value")) {
        $(this).attr("value", $textik);
      }
    })
    $("#sb-text").focus(function () {
      if ($(this).attr("value") == $textik) {
        $(this).attr("value", "");
      }
    })

    $("#sb-submit").click(function () {
      if ($("#sb-text").attr("value").length < 2 || $("#sb-text").attr("value") == $textik) {
        alert("Minimálna dĺžka hľadaného výrazu je 2 znaky!");
        return false;
      }
    })

    //externi odkazy a popup
    $("a").filter(function() {
      return this.hostname && this.hostname !== location.hostname;
    }).addClass("external");

    $("a.external, a.popup").click(function() {

      if ($(this).hasClass('facebook')) {
        //t = document.title;
        t = $(this).attr('alt');
        u = $(this).attr('rel');
        
        window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=600,height=400');
      }
      else {
        window.open(this.href);
      }
      
      return false;
    });
    
    //flash podklad
    if ($("#div-flash").length>0) {
      var margin_left = ($("body").width() - $("#background-flash").width()) / 2 - 1;
      $("#background-flash").css('margin-left', margin_left + 'px');
    //alert($("body").width() + ' - ' + $("#background-flash").width());
    }

  });

