/**
 *
 * Copyright (c) 2007 Tom Deater (http://www.tomdeater.com)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */

(function($) {
	/**
	 * equalizes the heights of all elements in a jQuery collection
	 * thanks to John Resig for optimizing this!
	 * usage: $("#col1, #col2, #col3").equalizeCols();
	 */

	 $.fn.equalizeCols = function(children, set_height, contract_by){
    var child = Array(0);
    if (children) child = children.split(",");
    var maxH = 0;
    reset = $.browser.msie ? "1%" : "auto";
    reset = set_height ? reset : "auto"


    this.each(
      function(i)
      {
        if (this.offsetHeight>maxH) maxH = this.offsetHeight;
      }
    ).css("height", reset).each(
      function(i)
      {
        var gap = maxH-this.offsetHeight;
        if (gap > 0)
        {

          if(set_height){
            $(this).css("height", (maxH-contract_by)+'px')
          }
          else{
            t = document.createElement('div');
            $(t).attr("class","fill").css("height",gap+"px");
            if (child.length > i)
            {
              $(this).find(child[i]).children(':last-child').after(t);
            }
            else
            {
              $(this).children(':last-child').after(t);
            }
          }
        }
      }
    );
   }
})(jQuery);

// Ovo se mora izvesti prije PNG fixa
$('.same_height').each(function(i,g){
  $(g).find('.subfeatured .column').equalizeCols()
})

