﻿var activeClass = 'allGamesNavOn';
var activeHitListClass = 'gameHitListTabOn';

// Show the game content and hitlist content
Event.observe(window, 'load', function () {
	// attach click to menu li>a
	$$('#allGamesNav li a').each(
		function (el) {
			el.observe('click', function () {
				clearNav();
				el.addClassName(activeClass);
				clearContent();
				var id = el.identify();
				$(id.substring(0,(id.length-3))).show();
			});
		}
	);
				
	// clear the nav
	function clearNav() {
		$$('#allGamesNav li a').each(
			function (el) {
				el.removeClassName(activeClass);
			}
		);
	}
	
	// clear (hide) all content
	function clearContent() {
		$$('div.allGamesListContent > div').each(
			function (el) {
				el.hide();
			}
		);
	}
	
	// Hit list tab click
	$$('#gameHitListNav a').each(
		function (el) {
			el.observe('click', function () {
				clearHitListTabs();
				el.addClassName(activeHitListClass);
				clearHitlist();
				var id = el.identify();
				$(id.substring(0,(id.length-3))).show();
			});
		}
	);
	
	// clear the nav
	function clearHitListTabs() {
		$$('#gameHitListNav a').each(
			function (el) {
				el.removeClassName(activeHitListClass);
			}
		);
	}
	
	// hide Hit list content
	function clearHitlist() {
		$$('#gameHitListContent > div').each(
			function (el) {
				el.hide();
			}
		);
	}

	$('gameHitListNew').show();
	$('allGamesArcade').show();
});
