var initialHiddenModules = new Array();
	
function addModuleToHideInitially(moduleName) {
  initialHiddenModules[initialHiddenModules.length] = moduleName; 
}

function hideModulesOnLoad() {
	if(initialHiddenModules.length > 0) {
		for(i = 0; i  < initialHiddenModules.length; i++) {
			if (initialHiddenModules[i].length > 0) {
				hideModule(initialHiddenModules[i]);
			}
		}
	}
}

function hideModule(layerName) {
	if (document.layers) {
		if (document.layers[layerName]!=null) {
			document.layers[layerName].style.display = 'none';
		}
	}
	else if (document.all) {
		if (document.all[layerName]!=null) {
			document.all[layerName].style.display = 'none';
		}
	}
	else if (document.getElementById) {	
		if (document.getElementById(layerName)!=null) {
			document.getElementById(layerName).style.display = 'none';
		}
	}
}

function updateExpansionImages(postive,negative) {
	if (document.images[negative].style.display) {
		show = (document.images[postive].style.display == 'none') ? 'inline' : 'none';
		document.images[postive].style.display = show;
		show = (document.images[postive].style.display == 'none') ? 'inline' : 'none';
		document.images[negative].style.display = show;
	}
}

function moduleExpand(which) {
	var posID = (which + "Pos");
	var negID = (which + "Neg");
	var blockID = (which + "Content");	
	updateExpansionImages(posID,negID);

	if (document.layers) {
		current = (document.blockID.style.display == 'none') ? 'block' : 'none';
		document.blockID.style.display = current;
	} 
	else if (document.all) {
		current = (document.all[blockID].style.display == 'none') ? 'block' : 'none';
		document.all[blockID].style.display = current;
	}
	else if (document.getElementById) {	
		vista = (document.getElementById(blockID).style.display == 'none') ? 'block' : 'none';
		document.getElementById(blockID).style.display = vista;
	}
	
	var moduleHeight = document.getElementById(blockID).offsetHeight;

	m2ColumnHeightAdapter(moduleHeight)
}

function centerContentExpand(which) {
	var posID = ("positive" + which);
	var negID = ("negative" + which);
	var blockID = ("m2_expandable_content" + which);	
	updateExpansionImages(posID,negID);
				
	if (document.layers) {
		current = (document.blockID.style.display == 'none') ? 'block' : 'none';
		document.blockID.style.display = current;
	} 
	else if (document.all) {
		current = (document.all[blockID].style.display == 'none') ? 'block' : 'none';
		document.all[blockID].style.display = current;
	}
	else if (document.getElementById) {	
		vista = (document.getElementById(blockID).style.display == 'none') ? 'block' : 'none';
		document.getElementById(blockID).style.display = vista;
	}
	/* Adjsuting Right and Left columns to match the height when a module increases the center area*/
	m2coladjust();
}

/**
 * Opens the e-meetings calendar during the RFP process.
 */
function openCalendar(theField, theYear, theMonth, theDate,brand, region, locale, secure)
{
	var theForm = document.contactEventForm;
	var cMonth = theMonth.value;
	var cDate = theDate.value;
	var cYear = theYear.value;
	var field = theField;
	var url = '/h/d/' + brand + '/' + region + '/' + locale + '/emcalendar?field=' + field + '&month=' + cMonth + '&date=' + cDate + '&year=' + cYear + '&secure=' + secure;
	if(navigator.userAgent.indexOf("AOL 6.0") != -1 || navigator.userAgent.indexOf("AOL 5.0") != -1) {
		newWin = window.open(url,'HI','DEPENDANT=YES,WIDTH=210,HEIGHT=230,TITLEBAR=YES,STATUS=YES,MENUBAR=NO,SCROLLBARS=NO,TOP=0,LEFT=0');
	} else {
		var topPos = (screen.availHeight/2)-115;
		var leftPos = (screen.availWidth/2)-105;
		newWin = window.open(url,'cal','top=' + topPos + ',left=' + leftPos + ',dependent=yes,width=210,height=230,screenX=' + leftPos + ',screenY=' + topPos + ',titlebar=yes,status=yes');
	}
	newWin.focus();
	return false;
}

/**
 * m2columnheight:
 * Used to make the right and left columns match the height of the center content when any page gets hit the first time.
 */

function m2columnheight(heightAdd) {

	var centerHeight = (document.getElementById('center').offsetHeight);
	var leftColumnHeight = (document.getElementById('left').offsetHeight);
	var rightColumnHeight = (document.getElementById('right').offsetHeight);
	if ( leftColumnHeight < centerHeight )
	{
		document.getElementById('left').style.height = centerHeight;
		/*Using a "rightFiller" div so that pages in HD2 with a CP Meetings wrapper render the right column correctly*/
		document.getElementById('rightFiller').style.height = centerHeight - rightColumnHeight + 18;
	}
	if ( centerHeight < leftColumnHeight )
	{
		document.getElementById('right').style.height = leftColumnHeight;
		document.getElementById('center').style.height = leftColumnHeight;
	}
}

/**
 * m2coladjsut:
 * This function makes the right and left nav colored backgrounds extend to the height of the main content when modules 
 * get expanded only. Used only in centerContentExpand
 * This function only extends heights it doesn't decrease the height of the center container if modules are collapsed
 */
function m2coladjust() {
	
	var centerHeight = (document.getElementById('center').offsetHeight);
	var leftColumnHeight = (document.getElementById('left').offsetHeight);

	if ( leftColumnHeight < centerHeight )
	{
		document.getElementById('left').style.height = centerHeight;
		document.getElementById('right').style.height = centerHeight;
		/* The following line basically hides the "rightFiller" div since it is not needed*/
		document.getElementById('rightFiller').style.height = 0;

	}
	else {
		document.getElementById('right').style.height = (document.getElementById('left').offsetHeight);
		}
	
}

function m2ColumnHeightAdapter(deltaHeight) {
	var heighten = deltaHeight;	
	var centerHeight = (document.getElementById('center').offsetHeight);
	var leftColumnHeight = (document.getElementById('left').offsetHeight);
	if (heighten != 0) {

			document.getElementById('left').style.height = leftColumnHeight + heighten;
			document.getElementById('right').style.height = leftColumnHeight + heighten;

	}
}
