// JavaScript Document
// MOUSEOVERS
function mshow(_ele) {
	document.getElementById(_ele) ? document.getElementById(_ele).style.display = 'block' : false;
}

function mhide(_ele) {
	document.getElementById(_ele) ? document.getElementById(_ele).style.display = 'none' : false;
}

function bshow(_ele) {
		_str = document.getElementById(_ele).style.backgroundImage
		_newval = _str.replace(/off/,"on");
		//alert(_newval);
		document.getElementById(_ele).style.backgroundImage = _newval;
}

function bhide(_ele) {
		_str = document.getElementById(_ele).style.backgroundImage
		_newval = _str.replace(/on/,"off");
		//alert(_newval);
		document.getElementById(_ele).style.backgroundImage = _newval;
}

function setupDropdowns(_navdivid) { // call this function AFTER the HTML for the dropdowns - ¥

	// NAV >> WRAP >> MENU >> LINK >> ANCHOR (node nesting pattern) - ¥

	// SETUP VARS
	!_navdivid ? _nid = 'nav' : _nid = _navdivid;
	_idprefix = 'm';// MENU DIV (e.g. 'm1,' etc...)
	_bidprefix = 'b';// MAIN MENU DIV (e.g. 'b1,' etc...)
	_nav = document.getElementById('nav');// CONTAINS THE FLOATING MENUS
	_wrap_cnt = _nav.childNodes.length;// NUMBER OF MENUS IN THE NAV
	_tmp_cnt = 1;// INCREMENT COMBINED WITH _idprefix TO ACCESS MENUS BY ID

	// CHECK FOR WRAPS

	for(_cnt = 0; _cnt < _wrap_cnt; _cnt++) {
		_wrapnode = _nav.childNodes[_cnt];

	// CHECK FOR MENUS

		if(_wrapnode.hasChildNodes() && _wrapnode.nodeType == 1) {

	// SET MOUSEOVERS FOR MENUS

			_curid = _idprefix + _tmp_cnt;
			_bid = _bidprefix + _tmp_cnt;
			_wrapnode.onmouseover = new Function('this.className="m_o";mshow("' + _curid + '");bshow("' + _bid + '");');
			_wrapnode.onmouseout = new Function('this.className="m_x";mhide("' + _curid + '");bhide("' + _bid + '");');
			_tmp_cnt++;
			_menu_cnt = _wrapnode.childNodes.length;

	// CHECK FOR LINKS

			for(_cntb = 0; _cntb < _menu_cnt; _cntb++) {
				_menunode = _wrapnode.childNodes[_cntb];
				if(_menunode.nodeType == 1 && _menunode.hasChildNodes()) {
					_link_cnt = _menunode.childNodes.length;

	// SET MOUSEOVERS FOR LINKS

					for(_cntc = 0; _cntc < _link_cnt; _cntc++) {
						_linknode = _menunode.childNodes[_cntc];
						if(_linknode.nodeType == 1) {
							_linknode.onmouseover = new Function('this.className="l_o";');
							_linknode.onmouseout = new Function('this.className="l_x";');

	// GRAB ANCHOR INSIDE LINK DIV AND SET ONCLICK

							if(_linknode.hasChildNodes()) {
								_ele_cnt = _linknode.childNodes.length;
								for(_cntd = 0; _cntd < _ele_cnt; _cntd++) {
									_elenode = _linknode.childNodes[_cntd];
									if(_elenode.href) {

										if (_linknode.id) {

											_linknode.onclick = new Function('window.location="'+_elenode.href+'";urchinTracker("'+_linknode.id+'");');

										} else {

											_linknode.onclick = new Function('window.location="'+_elenode.href+'"');

										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}// end function
/* END NAVIGATION CODE */
/* google search script */
	function stype(_clicked) {
	if(_clicked == 'web') {
		document.getElementById('gsearch').innerHTML = '<a href="javascript:stype(\'marvel\');">Marvel</a>&nbsp;<span style="font-weight:normal;">&nbsp;|&nbsp;</span>&nbsp;Web';
		document.getElementById('smode').value = '';
	} else {
		document.getElementById('gsearch').innerHTML = 'Marvel&nbsp;<span style="font-weight:normal;">&nbsp;|&nbsp;</span>&nbsp;<a href="javascript:stype(\'web\');">Web</a>';
		document.getElementById('smode').value = 'marvel.com';
	}
}
