(function($) {
  $.fn.equalizeHeight = function() {
    var max_height = 0;
    // find of a max height
    this.each(function() {
      var height = $(this).height();
      if(height > max_height)
        max_height = height;
    });
    // set the max height to all nodes
    this.each(function() {
      var ww = $(this).width();
      var ss = $(this).attr('src');
      $(this).attr('src', '/contents/templates/default/img/dot.gif');
      $(this).css('background', 'url('+ss+') bottom no-repeat');
      $(this).width(ww);
      $(this).height(max_height);
    });
    return this;
  }
})(jQuery);

$(function(){
	/*** search checkboxes **/
    $('#modules_all').click(function(){
        $('.search-modules input').attr('checked',$('#modules_all').attr('checked'));
    });
    
    $('.search-modules input').click(function(){
        if ($(this).attr('id') != 'modules_all')
        {
            if ($(this).attr('checked') == false)
            {
                $('#modules_all').attr('checked',false);
            }
        } 
    });
});

function scanPics()
{
    for (var i = 0; $('.pic-line-'+i).length > 0; i++)
        $('.pic-line-'+i).equalizeHeight();
}

function scanPics2()
{
    for (var i = 1000; $('.pic-line-'+i).length > 0; i++)
        $('.pic-line-'+i).equalizeHeight();
}

$(window).load(function() {
    scanPics();
});

$(function(){
    $('.stick0').click(function(){
        $('.stick1').addClass('stick');
        $('.stick1').removeClass('stick-active');
        $('.stick2').addClass('stick');
        $('.stick2').removeClass('stick-active');

        $('.tab1').hide();
        $('.tab2').hide();

        $(this).addClass('stick-active');
        $(this).removeClass('stick');
        $('.tab0').show();
    });
    
    $('.stick1').click(function(){
        $('.stick0').addClass('stick');
        $('.stick0').removeClass('stick-active');
        $('.stick2').addClass('stick');
        $('.stick2').removeClass('stick-active');

        $('.tab0').hide();
        $('.tab2').hide();

        $(this).addClass('stick-active');
        $(this).removeClass('stick');
        $('.tab1').show();
    });

    $('.stick2').click(function(){
        $('.stick1').addClass('stick');
        $('.stick1').removeClass('stick-active');
        $('.stick0').addClass('stick');
        $('.stick0').removeClass('stick-active');

        $('.tab1').hide();
        $('.tab0').hide();

        $(this).addClass('stick-active');
        $(this).removeClass('stick');
        $('.tab2').show();
    });
});

