/*function equalHeight(group) {
    tallest = 0;
    group.each(function(c) {
	    thisHeight = c.offsetHeight;
        //thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight+"px";
        }
    });
	//alert(tallest);
    group.height(tallest);
}

//$(document).ready(function() {
$(window).load(function() {
    //equalHeight($(".height-container",".height-container2"));
	//equalHeight($(".height-container"));
    //equalHeight($(".height-container2"));
});*/



(function ($) {
    // Create a namespace if it does not exist
	$.nrj = $.nrj ? $.nrj : {};
	$.nrj.matchHeights = function (options) {
		// Extend the default options with those provided.
		var opts = $.extend({}, $.nrj.matchHeights.defaults, options);
		// Return for chaining
		return this.each(function () {
			// Extend with meta plugin if it is included
			opts = $.meta ? $.extend({}, opts, $(this).data()) : opts;

			// Put elements into an array
			var els = opts.elements.split(',');
			if (els.length < 1) return false;

			var tallest = 0;
			var topHeight = 0;
			var newEls = [];

			// iterate over each element, adding its total height to an array,
			// setting the tallest element in the list
			$.each(els, function (i, val) {
				tempTop = $(val).offset().top;
				tempHeight = tempTop + $(val).height();
				newEls[i] = tempHeight;
				if (tempHeight > topHeight) {
					tallest = i;
					topHeight = tempHeight;
				}
			});

			// iterate over each element, matching the height of shorter els
			$.each(els, function (i, val) {
				if (i == tallest) return;
				temp = $(els[i]).height();
				
				$(els[i]).height(topHeight - newEls[i] + $(els[i]).height());
			});
		});
	}

	$.nrj.matchHeights.defaults = {
		elements: ""
	}

	$.fn.matchHeights = $.nrj.matchHeights;

})(jQuery);
/*
$(document).ready(function () {
    $().matchHeights({
        "elements": ".height-container, .height-container2"
    });
});*/

/*
function equalHeight(group) {
	tallest = 0;
	group.each(function(c) {
	thisHeight = c.offsetHeight;
	if(thisHeight > tallest) {
	tallest = thisHeight;
}

});
group.invoke("setStyle", {height: tallest + "px"})
}
//Event.observe(window, "load", function()
$(window).load(function()
{
equalHeight($(".height-container", ".height-container2"));
});*/


/*
function matchHeight(){
	equalHeight($(".height-container"));
    equalHeight($(".height-container2"));
}*/


/*matchHeight=function(){
	 var divs,contDivs,maxHeight,divHeight,d;
	 // get all <div> elements in the document
	 divs=document.getElementsByTagName('div');
	 contDivs=[];

	 // initialize maximum height value
	 maxHeight=0;
	 // iterate over all <div> elements in the document
	 for(var i=0;i<divs.length;i++){
		  // make collection with <div> elements with class attribute 'container'
		  if(/\bheight-container\b/.test(divs[i].className)){
				d=divs[i];
				contDivs[contDivs.length]=d;
				// determine height for <div> element
				if(d.offsetHeight){
					 divHeight=d.offsetHeight;
				}
				else if(d.style.pixelHeight){
					 divHeight=d.style.pixelHeight;
				}
				// calculate maximum height
				maxHeight=Math.max(maxHeight,divHeight);
		  }
	 }
	 //alert(maxHeight);
	 /*if(maxHeight < 611){
		maxHeight = 611; 
	 } *
	 // assign maximum height value to all of container <div> elements
	 for(var i=0;i<contDivs.length;i++){
		  contDivs[i].style.height=maxHeight + "px";
	 }
}*/