$(document).ready(function() {

    // breadcrumbs effect
    $(".flip").flipv();

    // toggle effect
    //
     $(".jcarousel-skin-tango").slice(1).each(function(){
        $(this).parent().find("h3.view:eq(0)").addClass("minus");
        $(this).parent().find("h3.view:eq(1)").addClass("plus");
        //$("h3.view",this).addClass("plus");
        $(this).hide();
     });
     
    $("h3.view").click(function(){
        //$(this).parent().next().slideToggle("slow");
        //$(this).toggleClass("minus").parent().next().find("ul").slideToggle();
        $(this).removeClass("plus");    
        $(this).toggleClass("minus").next().slideToggle("slow");
        //$(this).next().slideToggle("slow");
      return false;
     });

    // funkcia pre vysunutie info o obrazku
    jQuery.fn.masque = function(classe) {    
        $(this).hover(function(){
        $(this).find(classe).stop().animate({height:"55px",opacity: "0.9"},400);
    },function () { 
        $(this).find(classe).stop().animate({height:"20px",opacity: "0"}, 400);
    });
    }
    
    // aplikacia funkcie
    $(".portfolio li").masque(".legend");
    $(".gallery li").masque(".legend");


    // jquery image loader - lazyload
    $(".gallery img").lazyload({ 
        threshold : 10,
        placeholder : "/img/loadingAnimation.gif",
        /*event : "click" ,*/
        effect : "fadeIn",
        failurelimit : 10 
    });
    $(".detail img").lazyload({ 
        threshold : 10,
        placeholder : "/img/loadingAnimation.gif",
        /*event : "click" ,*/
        effect : "fadeIn",
        failurelimit : 10 
    });

    // scrollTop
    $('#scrollTop').click(function() {
        $('html, body').animate({scrollTop: '0px'}, 1000,'easeOutQuart');
        return false;
    });
  
    // tipTip Tooltip bubles plugin
    $("abbr, #nav a, .detailegend a, #compass a, .gallery a").tipTip({defaultPosition: "top", maxWidth: "auto", edgeOffset: 5});
  
  
    $('#leftThumbs a img').tooltip({ 
        delay: 0, 
        showURL: false,
        fade: 500,
        top: 30,
        left: -120,
        showURL: false, 
        showBody: " - ",
        extraClass: "leftTbumsBox",
        bodyHandler: function() { 
            var title = $(this).parent().attr("title");
            //$(this).parent().removeAttr("title");
            var toolContent =  $("<img/>").attr("src", this.src);
            var imgLink = $(this).attr("src");
            // console.log("alt ", title );
            return $('<img src="'+ imgLink + '"/><span>' + title + '</span>').appendTo(this);
        } 
    });

    // slider
    $('#slider1').anythingSlider({
        width           : 620,
        height          : 220,
        buildArrows     : false,
        theme           : /*'default',*/ 'metallic',
        autoPlayLocked  : true,  // If true, user changing slides will not stop the slideshow
        resumeDelay     : 100 // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
    });
    $('.caption-top').hide();
   $('#slider1').hover(
      function () {
        $(this).find(".caption-top").fadeIn("slow");
      }, 
      function () {
        $(this).find(".caption-top").fadeOut("slow");
      }
    );


});

