/**
 * This file contains functions related to the menu items in the header of the page and the footer. 
 */


/**
 * Parses data and spits out top menu recieved from database
 */
function topMenuCallback ( jsonData )
{
		
	var myData;
	var myList;
	var myHTML;
	
	myData = eval ( "(" + jsonData + ")" );

	myList = "";
				
	for ( var i = 0; i < myData.length; i++ ) // not for each in case we need to skip one
	{
		// @todo fix exception: skip Share page
		if (myData[i].myKey.toLowerCase() == "share")
		{
			i++;
		}
				
		// handle where the | should go
		if (i == 0)
		{
			myList += "<a id=\"hp-" + i + "\" onclick=\"clickHandler(this); return false;\" class=\"topMenu\" href=\"#hp=" + myData[i].myKey + "&commandToggleDrawer\">" + myData[i].myTitle + " |</a>";
		} else if 	(i == 1) 
		{	
			myList += "<a id=\"hp-" + i + "\" onclick=\"clickHandler(this); return false;\" class=\"topMenu\" href=\"#hp=" + myData[i].myKey + "&commandToggleDrawer\">" + myData[i].myTitle + "</a>";
		} else if 	(i >  1) 
		{
			myList += "<a id=\"hp-" + i + "\" onclick=\"clickHandler(this); return false;\" class=\"topMenu\" href=\"#hp=" + myData[i].myKey + "&commandToggleDrawer\">| " + myData[i].myTitle + "</a>";
		}		
	
	}
	
	// RSS Link
	myList += "|<a href=\"index.php?q=rss\"><img src=\"img/rss.gif\" class=\"rssLink\"/></a>";
	
	// put them all together
	myHTML = "<span class=\"top\">" + myList + "</span>";
	
	// draw
	$("#topMenu").append(myHTML);
	
	
} // END of topMenuCallback