/**
 *
 * jQuery for collections/index view
 *
 */

  var ms_show_cat = 300;  // ms = miliseconds
  var ms_hide_cat = 200;

  var ms_show_title = 300;
  var ms_hide_title = 1500;

  $(window).bind('load', function () {

    // hover collection buttons
    $('img.coll_img').hover(
      function () {
        var $$ = $(this);
        // ENTER
        $$.data("left", "nee");
        $$.stop().animate({ opacity: 0 }, ms_show_title, false,
          function () {
            if ($$.data("left") == "ja") {
              $$.animate({ opacity: 1 }, ms_hide_title);
              $$.data("left", "nee");
            }
          }
        );
      },
      function () {
        var $$ = $(this);
        // LEAVE
        if ($$.is(":animated")) {
          $$.data("left", "ja");
        } else {
          $$.animate({ opacity: 1 }, ms_hide_title);
        }
      }
    );

    // submenu switching
    $('#submenu a').click( function() {
      this.blur();
      // remove current class
      $("#submenu a").removeClass();
      // fadeout current + fadein linked
      var new_cat_id = this.name;
      var link = this;
      $('div.coll_tab:visible').fadeOut(ms_hide_cat, function() {
        link.className = "current";
        $(new_cat_id).fadeIn(ms_show_cat);
      });
      return false;
    });

    // fade after click button
    $('a').click( function () {
      this.blur();
//        $('div.collcat:visible').fadeOut(ms_hide_cat);
    } );

  });