// Media Overlay JavaScript Document

function moManager(id) {
	theItem = $('moItem' + id);
	showMOwrap(id);
	openMO(theItem);
}
/**
 * Either show or create the Media Overlay Wrapper Div.
 */
function showMOwrap() {
		
	if(!$('moWrap')) {
	  var moWrap = document.createElement('DIV');
	
	  moWrap.id = 'moWrap';
	  moWrap.className = 'moWrap';

	  document.body.appendChild(moWrap);
	  Event.observe(moWrap, 'click', closeMO, false);
	}
	else {
		$('moWrap').style.display= 'block';	
	}
}
	
	
/**
 * Hides the MO Wrapper Div
 */
function hideMOwrap() {
	$('moWrap').style.display= 'none';
}
	
/**
 * Close the MO by hiding it in the DOM.
 */
function closeMO() {
	hideMOwrap();
//	$('moItem' + id).style.display = 'none';
	theItem.style.display = 'none';
}	

/**
 * Opens the MO 
 */
function openMO(theItem) {
	theItem.style.display = 'block';
}
