/*
*	File Name : 			departmentcampaign.js
*	Author : 				Domenic Polsoni - (FabulousSavings.com)
*	
*	Date Created :			June 3, 2009
*	Date Modified :			
*												
*     
*	Functions designed to control elements within the department campaigns
*/

/**
	Vertically centers element
	@param elem, element to be centered
	@param maxH, Max height of the containing cell that will dictate the height to conform to
*/
function verticalCenter(elemId, maxH)
{
	var MAXHEIGHT = maxH;
	var elem = document.getElementById(elemId);			// The actual element passed
	var elemHeight = 0;									// The element's height
	var centeredValue = 0;								// The calculated vertical center value of the element
	
	// Vertically center the element through padding
	for (var i = 0; i < elem.childNodes.length; i++)
	{
		if (elem.childNodes[i].tagName == "IMG")
		{	
			// Reset any padding that may exist
			elem.childNodes[i].style.paddingTop = '0px';
			
			elemHeight = elem.childNodes[i].offsetHeight;
			centeredValue = (MAXHEIGHT - elemHeight) / 2;
			elem.childNodes[i].style.paddingTop = centeredValue + 'px';
		}
		else if (elem.childNodes[i] != "undefined" && elem.childNodes[i] != "IMG")
		{
			// Reset any padding that may exist
			elem.style.paddingTop = '0px';
			
			elemHeight = elem.offsetHeight;
			centeredValue = (MAXHEIGHT - elemHeight) / 2;
			elem.style.paddingTop = centeredValue + 'px';
		}
	}
}

window.onload = function()
{
	verticalCenter('topRightDepartment', 100);
	verticalCenter('topRightDepartmentLogo', 100);
}
 


