$(function() {

    var source_first = $("#galerija-1 img:first-child").attr("src");
    var alt_first = $("#galerija-1 img:first-child").attr("alt");
    $("#fade-1").text(function() { 
      return alt_first;
    });
    $("img#velika-slika-1").attr("src", function() {
    return source_first;
    });
    
    var source_first = $("#galerija-2 img:first-child").attr("src");
    var alt_first = $("#galerija-2 img:first-child").attr("alt");
    $("#fade-2").text(function() { 
      return alt_first;
    });
    $("img#velika-slika-2").attr("src", function() {
    return source_first;
    });
    
    var source_first = $("#galerija-3 img:first-child").attr("src");
    var alt_first = $("#galerija-3 img:first-child").attr("alt");
    $("#fade-3").text(function() { 
      return alt_first;
    });
    $("img#velika-slika-3").attr("src", function() {
    return source_first;
    });

    $("#galerija-1 img").each(function() {
      var source = $(this).attr("src");
      var alt_text = $(this).attr("alt");
      $(this).attr("name", function() { 
        return alt_text;
      });
      $(this).attr("alt", function() { 
        return source;
      });
      $(this).attr("src", "http://www.goolets.com/wp-content/themes/goolets/images/change-image-grey.png");
    });
    
    $("#galerija-1 img:first-child").attr("src", "http://www.goolets.com/wp-content/themes/goolets/images/change-image-blue.png");
    
    $("#galerija-2 img").each(function() {
      var source = $(this).attr("src");
      var alt_text = $(this).attr("alt");
      $(this).attr("name", function() { 
        return alt_text;
      });
      $(this).attr("alt", function() { 
        return source;
      });
      $(this).attr("src", "http://www.goolets.com/wp-content/themes/goolets/images/change-image-grey.png");
    });
    
    $("#galerija-2 img:first-child").attr("src", "http://www.goolets.com/wp-content/themes/goolets/images/change-image-blue.png");
    
    $("#galerija-3 img").each(function() {
      var source = $(this).attr("src");
      var alt_text = $(this).attr("alt");
      $(this).attr("name", function() { 
        return alt_text;
      });
      $(this).attr("alt", function() { 
        return source;
      });
      $(this).attr("src", "http://www.goolets.com/wp-content/themes/goolets/images/change-image-grey.png");
    });
    
    $("#galerija-3 img:first-child").attr("src", "http://www.goolets.com/wp-content/themes/goolets/images/change-image-blue.png");

    $("#galerija-1 img").click(function() {
      var source = $(this).attr("alt");
      var name_text = $(this).attr("name");
      $("#galerija-1 img").each(function()  {
        $(this).attr("src", "http://www.goolets.com/wp-content/themes/goolets/images/change-image-grey.png");
      });
      $(this).attr("src", "http://www.goolets.com/wp-content/themes/goolets/images/change-image-blue.png");
      $("img#velika-slika-1").attr("src", function() {
        return source; 
    });
      $("#fade-1").text(function() {
        return name_text; 
    });
    });
    
    $("#galerija-2 img").click(function() {
      var source = $(this).attr("alt");
      var name_text = $(this).attr("name");
      $("#galerija-2 img").each(function()  {
        $(this).attr("src", "http://www.goolets.com/wp-content/themes/goolets/images/change-image-grey.png");
      });
      $(this).attr("src", "http://www.goolets.com/wp-content/themes/goolets/images/change-image-blue.png");
      $("img#velika-slika-2").attr("src", function() { 
        return source; 
    });
      $("#fade-2").text(function() {
        return name_text; 
    });
    });
    
    $("#galerija-3 img").click(function() {
      var source = $(this).attr("alt");
      var name_text = $(this).attr("name");
      $("#galerija-3 img").each(function()  {
        $(this).attr("src", "http://www.goolets.com/wp-content/themes/goolets/images/change-image-grey.png");
      });
      $(this).attr("src", "http://www.goolets.com/wp-content/themes/goolets/images/change-image-blue.png");
      $("img#velika-slika-3").attr("src", function() { 
        return source; 
    });
      $("#fade-3").text(function() {
        return name_text; 
    });
    });

});
