
/*
	(1)
	Delete the following code at the beginning of the "styled dropdowns"
	commented block in main.js:

// Global event handler
function cnnMouseDown(e) {
	cnnDD.mouseDownBody(e);
	return true;
}
*/




/*
	(2)
	Add the following commented block to main.js, immediately before
	the "styled dropdowns" commented block:
*/


/* styled overlay menus
=========================================================================== */
// Global event handler
function cnnMouseDown(e) {
	cnnOverlay_mouseDownBody(e);
	cnnDD.mouseDownBody(e);
	return true;
}

var cnnOvlClickedId = "";

function cnnInitOverlay() {
	document.body.onmousedown = cnnMouseDown;

	array = document.getElementsByClassName("cnnOverlayLnk");
	for (var i = 0; i < array.length; i++) {

		btnElem = array[i];
		btnElem.onmousedown = cnnOverlay_mouseDownBtn;

		var href = btnElem.href;
		var menuId = href.substring(href.indexOf("'") + 1, href.lastIndexOf("'"));
		if ($(menuId)) {
			$(menuId).onmousedown = cnnOverlay_mouseDownMenu;
		}

		// Mac Safari image-rollover bug
		if ((navigator.userAgent.indexOf("Safari") != -1)
		 && (navigator.userAgent.indexOf("Mac") != -1)) {
			// If cnnImgSwap() is called by the onmouseout event
			if (btnElem.onmouseout.toString().indexOf("cnnImgSwap") != -1) {
				// Make onclick call the onmouseout event handler
				btnElem.onclick = function onclick() { this.onmouseout(); return true; };
			}
		}
	}
}


function cnnShowOverlay(menuId) {
	if ($(menuId)) {
		// If the menu is already open
		if ($(menuId).style.display == "block") {
			// Close it
			$(menuId).style.display = "none";
		}
		else {
			$(menuId).style.display = "block";
		}
	}
}


function cnnHideOverlay(menuId) {
	if ($(menuId)) {
		$(menuId).style.display = "none";
	}
}


function cnnOverlay_mouseDownBtn(e) {
	var href = this.href;
	var menuId = href.substring(href.indexOf("'") + 1, href.lastIndexOf("'"));
	cnnOvlClickedId = menuId;
	return true;
}


function cnnOverlay_mouseDownMenu(e) {
	cnnOvlClickedId = this.id;
	return true;
}


function cnnOverlay_mouseDownBody(e) {
	// Close all "cnnOverlayLnk" menus, unless the mouse is inside an open menu
	// or the button of an open menu.
	array = document.getElementsByClassName("cnnOverlayLnk");

	for (var i = 0; i < array.length; i++) {
		var href = array[i].href;
		var menuId = href.substring(href.indexOf("'") + 1, href.lastIndexOf("'"));
		if (menuId != cnnOvlClickedId) {
			cnnHideOverlay(menuId);
		}
	}
	cnnOvlClickedId = "";
	return true;
}
/* end styled overlay menus
=========================================================================== */
