﻿function fh_launcher( selector, rownum, selectors ){
  fh(selector, rownum);
  jQuery.each(selectors, function (sel, title) {
    $("" + sel + "").click(function(){
      fh_reflating(selector, rownum);
    });
  });
}

function fh( selector, rownum ){

  /* selectorのdiv要素をrownumつずつの組に分ける */
  var sets = [], temp = [];
  $("" + selector + "").each(function(i) {
    temp.push(this);
    if (i % rownum == (rownum - 1)) {
      sets.push(temp);
      temp = [];
    }
  });
  if (temp.length) sets.push(temp);

  /* 各組ごとに高さ揃え */
  $.each(sets, function() {
    $(this).flatHeights();
  });

}
function fh_reflating( selector, rownum ){

  /* selectorのdiv要素をrownumつずつの組に分ける */
  var sets = [], temp = [];
  $("" + selector + "").each(function(i) {
    temp.push(this);
    if (i % rownum == (rownum - 1)) {
      sets.push(temp);
      temp = [];
    }
  });
  if (temp.length) sets.push(temp);

  /* 各組ごとに高さ揃え */
  $.each(sets, function() {
    $(this).height('auto');
    $(this).flatHeights();
  });

}

