$(document).ready(function () {
	setMenuGEN1();
});

function setMenuGEN1() {
	if (typeof _divTopName != 'undefined') {
		_DivTopLvl = $('#' + _divTopName);
		_DivSubLvl = $('#' + _divSubName);

		$(_DivTopLvl).find('a').mouseover(function () { // ==== MOUSEOVER
			$(this).addClass('anctopSel');
			$(this).parent().addClass('divTopLvlChldOver');
			$(this).parent().prev().addClass('divDividerSel');
			return false;
		});

		$(_DivTopLvl).children('div').mouseout(function () { // ==== MOUSEOUT
			if ($(this).attr('id') != currentActive) {
				$(this).children('a').removeClass('anctopSel');
				$(this).removeClass('divTopLvlChldOver');
				$(this).prev().removeClass('divDividerSel');
			}
			return false;
		});

		$(_DivTopLvl).children().each(function (index) {
			if ($('#sub_' + $(this).attr('id')).length) {
				$(this).click(function () { // ==== CLICK
					currentActive = $(this).attr("id");
					resetAll($(this).attr("id"));
					$(this).addClass('divTopLvlChldOver');
					$(this).prev().addClass('divDividerSel');
					$(this).find('a').addClass('anctopSel');
					$('#sub_' + $(this).attr("id")).show();
					$('#divOuter').addClass('divOuterSel');
					return false;
				});
			}
		});

		resetAll(currentActive);
	}
}

function resetAll(iID) { // ==== RESET ALL
	$(_DivSubLvl).children().hide();
	$(_DivTopLvl).find('div').removeClass('divTopLvlChldOver');
	$(_DivTopLvl).find('div').removeClass('divDividerSel');
	$(_DivTopLvl).find('a').removeClass('anctopSel');

	if (currentActive != null && currentActive != '') {// ==== KEEP SELECTED/ACTIVE
		$('#' + currentActive).addClass('divTopLvlChldOver');
		$('#' + currentActive).prev().addClass('divDividerSel');
		$('#' + currentActive).find('a').addClass('anctopSel');
		if (iID == null || iID == currentActive) {
			$('#sub_' + currentActive).show(); }
		if ($('#sub_' + currentActive).length) {
			$('#divOuter').addClass('divOuterSel'); }
	}
}
