/* 
  ------------------------------------------------
  Equal CSS Columns scripts
  ------------------------------------------------
*/

function eqColHeight()
{
	if(document.getElementById)
	{
		document.Rgeqc=new Array;
		for(i=0;i<arguments.length;i++)
		{
			document.Rgeqc[i]=document.getElementById(arguments[i]);
		}
		setInterval("eqT()",1);
	}
}

function colH()
{
	var i,oh,hh,h=0,dA=document.Rgeqc,an=document.Rgeqa;
	if(dA&&dA.length)
	{
		for(i=0;i<dA.length;i++)
		{
			dA[i].style.height='auto';
		}
		for(i=0;i<dA.length;i++)
		{
			//oh=dA[i].offsetHeight;
			oh=dA[i].offsetHeight + findPosY(dA[i]);
			h=(oh>h)?oh:h;
		}
		//window.status = 'Lowest Point: ' + h + 'px';
		for(i=0;i<dA.length;i++)
		{
			if(an)
			{
				dA[i].style.height=h-findPosY(dA[i])+'px';
				
			} else {
				eqA(dA[i].id,dA[i].offsetHeight,h);
			}
		}
		if(an){
			for(i=0;i<dA.length;i++)
			{
				hh=dA[i].offsetHeight;
				if(hh>h)
				{
					dA[i].style.height=(h-(hh-h))-findPosY(dA[i])+'px';
				}
			}
		} else {
			document.Rgeqa=1;
		}
		document.eqheight=document.body.offsetHeight;
		document.eqwidth=document.body.offsetWidth;
	}
}

function eqT()
{
	if(document.eqheight!=document.body.offsetHeight||document.eqwidth!=document.body.offsetWidth)
	{
		colH();
	}
}

function eqA(el,h,ht)
{
	var sp=10,inc=100,nh=h,g=document.getElementById(el),oh=g.offsetHeight,ch=parseInt(g.style.height);
	ch=(ch)?ch:h;
	var ad=oh-ch,adT=ht-ad;
	nh+=inc;
	nh=(nh>adT)? adT:nh;
	g.style.height=nh-findPosY(g)+'px';
	oh=g.offsetHeight;
	if(oh>ht)
	{
		nh=(ht-(oh-ht));
		g.style.height=nh-findPosY(g)+'px';
	}
	if(nh<adT){
		setTimeout("eqA('"+el+"',"+nh+","+ht+")",sp);
	}
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}