// home_init.js
// 8-23-06
// Coded by SGB in order to set appropriate lengths
// to divs on the homepage

// sets the homepage divs to the correct height
// based on the content
function initHomeDivs()
{
	// browser detection
	this.ie  = document.all ? 1 : 0
	this.ns4 = document.layers ? 1 : 0
	this.dom = document.getElementById ? 1 : 0
	
	var divIdArray = new Array(4);
	var divObjArray = new Array(4);
	var footerTop;
	
	// div id names hard-coded
	divIdArray[0] = "leftColumn";
	divIdArray[1] = "latestDeals";
	divIdArray[2] = "newsAndEvents";
	divIdArray[3] = "footer";
	
	// populate Object array
	for (i in divIdArray)
	{
		divObjArray[i] = document.getElementById(divIdArray[i]);
	}
	
	// find the top of the footer
	footerTop = findPosY(divObjArray[3]);

	// loop through the object array and set heights accordingly
	for (i in divObjArray)
	{
		if (i != 3)
		{
			if (i == 0)
				divObjArray[i].style.height = (footerTop - findPosY(divObjArray[i]) + 1) + "px"; // fixes pixel
			else
				divObjArray[i].style.height = (footerTop - findPosY(divObjArray[i])) + "px";
		}
	}
	
	
	
}

// helper function, borrowed from cran_slideMenu.js
function findPosY(obj) {
	var curtop = 0;
	if (document.getElementById || document.all) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}else if (document.layers)
		curtop += obj.y;
	return curtop;
}