Drupal.locale = { 'pluralFormula': function ($n) { return Number(($n!=1)); }, 'strings': {"An AJAX HTTP error occurred.":"Tapahtui AJAX HTTP virhe.","HTTP Result Code: !status":"HTTP koodi: !status","An AJAX HTTP request terminated abnormally.":"AJAX HTTP pyynt\u00f6 keskeytyi odottamatta.","Debugging information follows.":"Seuraavassa virhetiedot.","Path: !uri":"Polku: !url","StatusText: !statusText":"Tilanneteksti: !statusText","ResponseText: !responseText":"Vastausteksti: !responseText","ReadyState: !readyState":"ReadyState: !readyState","Loading":"Lataa","(active tab)":"(aktiivinen v\u00e4lilehti)","Hide":"Piilossa","Show":"N\u00e4yt\u00e4","Re-order rows by numerical weight instead of dragging.":"Uudelleenlajittele rivit numeerisen painon mukaan ved\u00e4-pudota toiminnon sijaan.","Show row weights":"N\u00e4yt\u00e4 rivien painokertoimet","Hide row weights":"Piilota rivien painokertoimet","Drag to re-order":"J\u00e4rjestele vet\u00e4m\u00e4ll\u00e4","Changes made in this table will not be saved until the form is submitted.":"Muutokset otetaan k\u00e4ytt\u00f6\u00f6n vasta kun valitset \u003cem\u003etallenna\u003c\/em\u003e.","Enabled":"K\u00e4yt\u00f6ss\u00e4","Hide shortcuts":"Piilota oikopolut","Disabled":"Ei k\u00e4yt\u00f6ss\u00e4","Search":"Etsi","@title dialog":"@title dialogi","Configure":"M\u00e4\u00e4rittele","Show shortcuts":"N\u00e4yt\u00e4 oikopolut","Edit":"Muokkaa","Customize dashboard":"Kustomoi kojelautaa","Done":"Tehty","Select all rows in this table":"Valitse kaikki taulukon rivit","Deselect all rows in this table":"Poista kaikkien rivien valinnat","Not published":"Ei julkaistu","Please wait...":"Odota hetki...","By @name on @date":"@name p\u00e4iv\u00e4n\u00e4 @date","By @name":"@name","Not in menu":"Ei valikossa","Alias: @alias":"Alias: @alias","No alias":"Ei aliasta","New revision":"Uusi versio","The changes to these blocks will not be saved until the \u003cem\u003eSave blocks\u003c\/em\u003e button is clicked.":"Lohkojen muutoksia ei tallenneta ennen kuin klikkaat \u003cem\u003eTallenna\u003c\/em\u003e-painiketta.","This permission is inherited from the authenticated user role.":"Oikeus on periytetty k\u00e4ytt\u00e4j\u00e4roolista \"autentikoitu k\u00e4ytt\u00e4j\u00e4\".","No revision":"Ei versiota","@number comments per page":"@number kommenttia sivua kohti","Requires a title":"Vaatii otsikon","Not restricted":"Ei rajoitettu","Not customizable":"Ei mukautettavissa","Restricted to certain pages":"Rajoitettu tiettyihin sivuihin","The block cannot be placed in this region.":"Lohkoa ei voi asettaa t\u00e4h\u00e4n alueeseen.","Hide summary":"Piilota yhteenveto","Edit summary":"Muokkaa yhteenvetoa","Don't display post information":"\u00c4l\u00e4 n\u00e4yt\u00e4 l\u00e4hetyksen tietoja","The selected file %filename cannot be uploaded. Only files with the following extensions are allowed: %extensions.":"Tiedostoa %filename ei voida ladata. Sallitu tiedostop\u00e4\u00e4tteet: %extensions.","Autocomplete popup":"Automaattisen t\u00e4ydennyksen ponnahdusikkuna","Searching for matches...":"Haetaan tuloksia..."} };;
// $Id: galleryformatter.js,v 1.6.2.2 2011/01/30 19:59:58 manuelgarcia Exp $

Drupal.behaviors.galleryformatter = {
  attach: function (context) {
    (jQuery)('.galleryformatter:not(.gallery-processed)', context).each(function(){
      Drupal.galleryformatter.prepare(this);

    }).addClass('gallery-processed');
  }
};

Drupal.galleryformatter = Drupal.galleryformatter || {};

// setting up the main behaviour
Drupal.galleryformatter.prepare = function(el) {
  (function ($) {
    // var $settings = Drupal.settings.galleryformatter;
    $el = $(el);
    var $slides = $('li.gallery-slide', $el);
    var $slideContainer = $('div.gallery-slides', $el);

    var $thumbs = $('.gallery-thumbs', $el);
    var $thumbsLi = $('li', $thumbs);
    var thumbWidth = $thumbsLi.filter(':first').width() + 'px';
    var liWidth = $thumbsLi.outerWidth(); // includes padding
    var $wrapper = $('.wrapper', $el);
    var visibleWidth = $wrapper.outerWidth();

    /*
     * Only start the thumbs carrousel if needed
     */
    if (($thumbsLi.size() * liWidth) > $thumbs.width()) {
      $('ul', $thumbs).width('99999px');
      $thumbs.infiniteCarousel();
      $thumbsLi = $('li', $thumbs); // we need to reselect because infiniteCarousel inserts new empty li elements if necessary
      // we need to reselect because infiniteCarousel inserts new empty li elements if necessary
      $el = $(el);
      $thumbsLi = $('.gallery-thumbs ul li', $el);
    }

    $thumbsLi = $('li', $thumbs); // we need to reselect because infiniteCarousel inserts new empty li elements if necessary

    $thumbsLi.each(function(){
      $(this).css({
          width: thumbWidth
        });
    });
    var $thumbslinks = $('a', $thumbsLi);

    /*
     * @TODO:
     * figure out how to get this into proper functions reusing selections
     */
    $thumbslinks.click(function(e){
      $hash = $(this.hash);
      if(!$hash.is(':visible')){
        $thumbsLi.removeClass('active');
        $(this).parent().addClass('active');
        $slides.filter(':visible').fadeOut('slow');
        $hash.fadeIn('slow');
        /*
         * @FIXME
         * Need to figure out a way to update the location bar of the browser, for bookmarking etc, without making the scroll jump
         * window.location.hash = this.hash; solution below does update the location, but makes the scroll jump.
         */
        // window.location.hash = this.hash;  // not sure if this is the best way to do it.
      }
      e.preventDefault();
    });

    /*
     *  Startup behaviour (when the page first loads)
     */
    $slides.hide(); // hide all slides
    var $locationHash = window.location.hash; // if we are being deeplinked to a specific slide, capture that

    function showFirstSlide(){
       $slides.filter(':first').show(); // show the first one
       $thumbsLi.filter('.slide-0:not("cloned")').addClass('active'); // activate the first thumbnail
     }

    // if we have a hash in the url
    if ($locationHash) {
      var $slideToShow = $slides.filter($locationHash);
      // if the hash corresponds to one of our slides
      if ($slideToShow.length > 0) {
        $slideToShow.show(); //  show that slide
        $thumbsLi.not($(".cloned")).find("a[href="+$locationHash+"]").parent().addClass('active'); // activate that thumbnail
      }
      // otherwise the default
      else {
        showFirstSlide();
      }
    }
    // otherwise the default
    else {
      showFirstSlide();
    }

    /*
     * Create a public interface to move to the next and previous images
     */
    // Shows the previous slide and scrolls to the previous page if necessary
    $thumbs.bind('showPrev', function (event) {
      var currentScroll = $wrapper.get(0).scrollLeft;
      var $prevThumbLi = $thumbsLi.filter('.active').prevAll().not('.cloned, .empty, .active').filter(':first');
      // if no results we are on the first element
      if(!$prevThumbLi.size()) {
        // select the last one
        $prevThumbLi = $thumbsLi.not('.empty, .cloned').filter(':last');
      }
      var $slideToClick = $('a', $prevThumbLi);
      var $prevIsVisible = (($prevThumbLi.get(0).offsetLeft >= currentScroll) && ($prevThumbLi.get(0).offsetLeft <= (visibleWidth + currentScroll)));
      if($prevIsVisible) {
        $slideToClick.trigger('click');
      }
      else {
        $thumbs.trigger('prev');
        $slideToClick.trigger('click');
      }
    });
    // Shows the next slide and scrolls to the next page if necessary
    $thumbs.bind('showNext', function (event) {
      var currentScroll = $wrapper.get(0).scrollLeft;
      // this selector could be optimized perhaps, but
      var $nextThumbLi = $thumbsLi.filter('.active').nextAll().not('.cloned, .empty, .active').filter(':first');
      // if no results we are on the last element
      if(!$nextThumbLi.size()) {
        // select the first one
        $nextThumbLi = $thumbsLi.not('.empty, .cloned').filter(':first');
      }

      var $slideToClick = $('a', $nextThumbLi);
      var $nextIsVisible = (($nextThumbLi.get(0).offsetLeft >= currentScroll) && ($nextThumbLi.get(0).offsetLeft <= (visibleWidth + currentScroll)));
      if($nextIsVisible) {
        var $slideToClick = $('a', $nextThumbLi);
        $('a', $nextThumbLi).trigger('click');
      }
      else {
        $thumbs.trigger('next');
        $slideToClick.trigger('click');
      }
    });

    $('img', $slideContainer).click(function(){
      $thumbs.trigger('showNext');
    });

     // Setup buttons for next/prev slide
    $slideButtons = ('<a class="prev-slide slide-button" title="'+ Drupal.t('Previous image') +'">&lt;</a><a class="next-slide slide-button" title="'+ Drupal.t('Next image') +'">&gt;</a>');
    $('.gallery-slides', $el).append($slideButtons);
    // Trigger the appropiate events on click
    $('a.prev-slide', $el).click(function(){
      $thumbs.trigger('showPrev');
    });
    $('a.next-slide', $el).click(function(){
      $thumbs.trigger('showNext');
    });
  })(jQuery);
}
;
// $Id: infiniteCarousel.js,v 1.2.2.1 2011/01/30 19:59:58 manuelgarcia Exp $

/**
 * Plugin written by the great jqueryfordesigners.com
 * http://jqueryfordesigners.com/jquery-infinite-carousel/
 *
 * Slightly addapted for our use case
 */
(function ($) {
  $.fn.infiniteCarousel = function () {

      function repeat(str, num) {
          return new Array( num + 1 ).join( str );
      }

      return this.each(function () {

          var $wrapper = $('> div', this).css('overflow', 'hidden'),
              $slider = $wrapper.find('> ul'),
              $items = $slider.find('> li'),
              $single = $items.filter(':first'),

              singleWidth = $single.outerWidth(),
              visible = Math.ceil($wrapper.innerWidth() / singleWidth), // note: doesn't include padding or border
              currentPage = 1,
              pages = Math.ceil($items.length / visible);


          // 1. Pad so that 'visible' number will always be seen, otherwise create empty items
          if (($items.length % visible) != 0) {
              $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
              $items = $slider.find('> li');
          }

          // 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
          $items.filter(':first').before($items.slice(- visible).clone().addClass('cloned'));
          $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
          $items = $slider.find('> li'); // reselect

          // 3. Set the left position to the first 'real' item
          $wrapper.scrollLeft(singleWidth * visible);

          // 4. paging function
          function gotoPage(page) {
              var dir = page < currentPage ? -1 : 1,
                  n = Math.abs(currentPage - page),
                  left = singleWidth * dir * visible * n;

              $wrapper.filter(':not(:animated)').animate({
                  scrollLeft : '+=' + left
              }, 500, function () {
                  if (page == 0) {
                      $wrapper.scrollLeft(singleWidth * visible * pages);
                      page = pages;
                  } else if (page > pages) {
                      $wrapper.scrollLeft(singleWidth * visible);
                      // reset back to start position
                      page = 1;
                  }

                  currentPage = page;
              });

              return false;
          }

          $wrapper.after('<a class="arrow back" title="'+ Drupal.t('Previous page') +'">&lt;</a><a class="arrow forward" title="'+ Drupal.t('Next page') +'">&gt;</a>');

          // 5. Bind to the forward and back buttons
          $('a.back', this).click(function () {
              return gotoPage(currentPage - 1);
          });

          $('a.forward', this).click(function () {
              return gotoPage(currentPage + 1);
          });

          // create a public interface to move to a specific page
          $(this).bind('goto', function (event, page) {
              gotoPage(page);
          });

          // custom events to trigger next and prev pages
          $(this).bind('next', function () {
            gotoPage(currentPage + 1);
          });
          $(this).bind('prev', function () {
            gotoPage(currentPage - 1);
          })
      });
  };
})(jQuery);
;

