eMenu = ['mrod', 'mviv'];
function js_onload () {
	eMenu.forEach (function (mA) {
		$(mA).esAct = false;
		$(mA).eOpacidad = $(mA).effect ('opacity', {duration: 500});
		$(mA).onmouseover = function () { js_menu (this.id); }
		$(mA).onmouseout = function () { if ($(this).esAct) {
			$(this).esAct = false;
			$(this).eOpacidad.stop ();
			$(this).eOpacidad.start (0.01, 1);
		}}
	});
	if ($('viv')) js_galeria ();
}

function js_menu (oId) {
	$('mnu').act = oId;
	eMenu.forEach (function (mA) {
		if ($('mnu').act != mA) {
			if ($(mA).esAct) {
				$(mA).esAct = false;
				$(mA).eOpacidad.stop ();
				$(mA).eOpacidad.start (0.01, 1);
			}
		} else {
			if (!$(mA).esAct) {
				$(mA).esAct = true;
				$(mA).eOpacidad.stop ();
				$(mA).eOpacidad.start (1, 0.01);
			}
		}
	});
}

function js_galeria () {
	$('imggrande').eOpacidad = $('imggrande').effect ('opacity', {duration: 300});
	oBody = $('viv');
	oBody.galPreload = false;
	oBody.galUrls = new Array ();

	$$('.gal a').forEach (function (galA, galIndex) {
		$('viv').galUrls.push (galA.href);
		galA.onmouseover = function () {
			if ($('viv').galPreload) {
				$('imggrande').eOpacidad.stop;
				$('imggrande').eOpacidad.start (1, 0).chain (function () {
					$($('imggrande').firstChild).replaceWith ($('viv').galImgs [galIndex]);
					$('imggrande').eOpacidad.start (0, 1);
				});
			}
		}
		galA.onclick = function () { return false; }
	});
	
	oBody.galImgs = new Asset.images (oBody.galUrls, { onComplete: function () {
		$('viv').galPreload = true;
	}});
}

window.onload = js_onload;