//
//
// Similar Height Class
//
// 
// ===== usage =====
// var sh = new SimilarHeight();
// sh.similarById("foo","bar",...);
//
SimilarHeight = function()
{
	this.ids = [];
	this.els = [];
	this.minHeight = 0;
}
//
SimilarHeight.prototype.similarById = function()
{
	for(var i=0,len=arguments.length; i<len; i++)
	{
		var a = arguments[i];
		if(typeof(a)=="string") this.ids.push(a);
	}
	this.setOnLoad(this, "findById");
}
SimilarHeight.prototype.similarByClassName = function(_class)
{
	this.classname = _class;
	this.setOnLoad(this, "findByClassName");
}
SimilarHeight.prototype.minimumHeight = function(_height)
{
	this.minHeight = _height;
}
//
// private function
//
SimilarHeight.prototype.setOnLoad = function(scope, func)
{
	if(window.addEventListener)
	{
		window.addEventListener('load', function(){ scope[func](); }, false);
	} else {
		window.attachEvent('onload', function(){ scope[func](); });
	}
}
SimilarHeight.prototype.findById = function()
{
	for(var i=0,len=this.ids.length; i<len; i++)
	{
		var el = document.getElementById(this.ids[i]);
		this.els.push(el);
	}
	this.reply();
}
SimilarHeight.prototype.findByClassName = function()
{
	var c = this.getElementsByClassName(this.classname);
	//
	for(var i=0,len=c.length; i<len; i++)
	{
		this.els.push(c[i]);
	}
	this.reply();
}
SimilarHeight.prototype.reply = function()
{
	var h = this.getMaxHeight();
	//
	for(var i=0,len=this.els.length; i<len; i++)
	{
		var el = this.els[i];
		el.style.height = h+"px";
	}
}
SimilarHeight.prototype.getMaxHeight = function()
{
	var h = 0;
	//
	for(var i=0,len=this.els.length; i<len; i++)
	{
		var el = this.els[i];
		if(h<el.offsetHeight) h=el.offsetHeight;
	}
	if(h<this.minHeight) h=this.minHeight;
	return h;
}
SimilarHeight.prototype.getElementsByClassName = function(_class)
{
	var e = [];
	var a = document.getElementsByTagName("*");
	for(var i=0,len=a.length; i<len; i++ )
	{
		if(a[i].className)
		{
			var c = a[i].className.split(" ");
			for(var j in c)
			{
				if(c[j]==_class) e.push(a[i]);
			}
		}
	}
	return e;
}