var lastHomeBoxID = "with-attune";
var isAnimInProgress = false;
var animTime = 0.3;

function switchHomeBoxContent(newID)
{
	if (isAnimInProgress || newID == lastHomeBoxID)
	{
		return;
	}
	isAnimInProgress = true;
	
	// change current element dot to the new selection
	document.getElementById(newID).parentNode.className = "current";
	document.getElementById(lastHomeBoxID).parentNode.className = "";
	
	var region = YAHOO.util.Dom.getRegion(lastHomeBoxID + "-content");
	var height = region.bottom - region.top;
	
	var anim = new YAHOO.util.Anim(
			lastHomeBoxID + "-content",
			{
				// animation type
				height:
				{
					by: -height
				}
			},
			animTime);
	anim.onComplete.subscribe(revealHomeBoxContent);
	
	lastClickedID = lastHomeBoxID;
	lastHomeBoxID = newID;
	
	anim.animate();
}

function revealHomeBoxContent()
{
	// hide the last clicked item
	document.getElementById(lastClickedID + "-content").style.display = "none";
	
	// measure the object off-screen
	var obj = document.getElementById(lastHomeBoxID + "-content");
	
	obj.style.display = "block";
	obj.style.height = "";
	
	var region = YAHOO.util.Dom.getRegion(obj);
	var height = region.bottom - region.top - 20;
	
	obj.style.height = "0px";
	obj.style.position = "";
	
	var anim = new YAHOO.util.Anim(
			lastHomeBoxID + "-content",
			{
				// animation type
				height:
				{
					by: height
				}
			},
			animTime);
	anim.onComplete.subscribe
	(
	 	function()
		{
			document.getElementById(lastHomeBoxID).style.height = "";
			isAnimInProgress = false;
		}
	);
	
	anim.animate();
}