/*
 * open and close the top nav menus (Games and Puzzles)
 */
function closeMenu(objId){
	$("#menu" + objId).animate({ 
			marginTop: "-240px"
			}, 500 );
	
	$("#openCloseWrap" + objId).animate({ 
		marginTop: "240px"
		}, 250 );
	
	if(objId == 'Puzzles'){
		$("#menu" + objId).css({'z-index':'3'});
	}
	
	$("#openCloseIdentifier" + objId).show();
}

function openMenu(objId){
	var otherObjId = (objId=='Puzzles')?'Games':'Puzzles';
	if($("#openCloseIdentifier" + otherObjId).is(":hidden")) {
		closeMenu(otherObjId);
	}
	$("#menu" + otherObjId).css({'z-index':(otherObjId=='Puzzles')?'4':'3'});
	$("#menu" + objId).css({'z-index':'5'});
	
	// pre-populate with the first in the list
	menuUpdate(objId,0);
	
	$("#openCloseWrap" + objId).animate({ 
		marginTop: "220px"
		}, 250 );
	
	$("#menu" + objId).animate({ 
		marginTop: "0px"
		}, 500 );
	$("#openCloseIdentifier" + objId).hide();
}

/*
 * populate menu with content from js/menu_content.php
 */
function menuUpdate(objName,objKey){
	if(objName == 'Games'){
		var objContent = menuGames[objKey];
            var objFolderName = rootPath + "games/" + objContent[1];
	} else if(objName == "Puzzles"){
		var objContent = menuPuzzles[objKey];
	        var objFolderName = rootPath + "puzzles/" + objContent[1];
	}
	
	$("#menu" + objName + "ViewUrl").attr("href", objFolderName + ".html");
	if (objName == "Games") {
                $("#menu" + objName + "Logo").attr("src", objFolderName + "/" + "menu_logo.png");
	        $("#menu" + objName + "Summary").html(objContent[2]); 
        } else {
        	$("#menu" + objName + "ViewUrl").children().attr("style", "margin-right: 0px;").parent().parent().attr("style", "text-align:center;");
                $("#menu" + objName + "Logo").attr("src", rootPath + "games/boxart/" + objContent[1] + "_box.png");
                $("#menu" + objName + "Logo").attr("height", "150").attr("width", "138").attr("style", "margin-left: auto; margin-right: auto;");
                $("#menu" + objName + "Summary").hide();
        }
        if(objName == "Games") {
			if(objContent[3]){
				$("#menu" + objName + "Kindle").attr("src", rootPath + "images/kindle.png");
			} else {
				$("#menu" + objName + "Kindle").attr("src", rootPath + "images/spacer.gif");
			}
			if(objContent[4]){
				$("#menu" + objName + "MacOSX").attr("src", rootPath + "images/MacOSX.png");
			} else {
				$("#menu" + objName + "MacOSX").attr("src", rootPath + "images/spacer.gif");
			}
			if(objContent[5]){
				$("#menu" + objName + "Windows").attr("src", rootPath + "images/Windows.png");
			} else {
				$("#menu" + objName + "Windows").attr("src", rootPath + "images/spacer.gif");
			}
        }
}
