imgPath = "images/design/";

function generateMenu(idx) {
	// HTML of the menu
	var curHTML = "";
	// ID of the section image to render
	var sectId = 0;
	// Flag specifying if section image should be rendered
	var doSect = false;
	// Menu items and links
	var links = new Array(
		"index.php", "News",
		"about.php", "About Me",
		"projects.php", "My Projects",
		"/board/", "Forum",
		"nhlview.php", "NHLView",
		"pbpstudio.php", "Play-by-play Studio",
		"streamedit06.php", "NHL06 Streams Editor",
		"stredit.php", "StrEdit",
		"nhlmisc.php", "Miscellaneous",
		"nhldevtools.php", "Developer Tools",
		"gta3.php", "GTA 3",
		"gtavc.php", "GTA: Vice City",
		"gtasa.php", "GTA: San Andreas",
		"gtalc.php", "GTA: Liberty City"
	);
	// Section images
	var sects = new Array(
		"siteheader.gif",
		"nhlheader.gif",
		"gtaheader.gif"
	);
	// Menu DIV
	var obj = document.getElementById('mnuMain');
	// Loop counter
	var i;
	if (obj) {
	  // For each menu item, do the following:
		for (i = 0; i < links.length / 2; i++) {
			// Determine if section image should be rendered
			doSect = true;
			switch (i) {
				case 0:
					sectId = 0;
					break;
				case 4:
					sectId = 1;
					break;
				case 10:
					sectId = 2;
					break;
				default:
					doSect = false;
					break;
			}
			if (doSect) {
				// If section should be rendered, first close the prev. section
				if (i != 0) {
		  		curHTML = curHTML +
						"</div>";
				}
				// Then add a new section
		  	curHTML = curHTML +
					"<img src=\"" + imgPath + sects[sectId] + "\" alt=\"\" width=\"200\" height=\"65\" />" +
						"<div style=\"margin-right: 30px\" align=\"right\">";
			}
			// Render menu item
	  	curHTML = curHTML +
							"<div>";
			if (idx == i) {
				// If item should be selected, draw arrow
				curHTML = curHTML + 
								"<img src=\"images/design/arrow.gif\" alt=\"\" width=\"29\" height=\"10\" />";
			}
			curHTML = curHTML + 
								"<a class=\"menuItem\" href=\"" + links[i * 2] + "\">" + links[i * 2 + 1] + "</a>" +
							"</div>";
		}
		// Close the last section
 		curHTML = curHTML +	
						"</div>";
		// Add RHL logo
		curHTML = curHTML +
						"<br />" +
						"<a href=\"http://www.rhl-mod.ru/\"><img src=\"images/design/rhlheader.gif\" width=\"200\" height=\"65\" alt=\"\" border=\"0\" /></a>";
		// Display menu
		obj.innerHTML = curHTML;
	}
}
