// File: XMLmenu.js

// Start function when DOM has completely loaded 
$(document).ready(function(){ 

	// Open the students.xml file
	$.get('/Modules/FrontPage/DropdownMenus/MenuXml.aspx?fid=63', function(xml){
      	
		// Build an HTML string
		myHTMLOutput = '';
		myHTMLOutput = '<ul class="topnav">';
		$(xml).find('item').each(function(i) {
		// Run the function for top level menu item
			var $menu = $(this);
			var lbl = $menu.attr("name");
			var url = $menu.attr("variables");
			// Build row HTML header and store in string
			mydata = BuildMenuHTML(lbl,url);
			myHTMLOutput = myHTMLOutput + mydata;
		});
		myHTMLOutput += '</ul>';
		// Update the DIV called Content Area with the HTML string
		$("#top_menu").append(myHTMLOutput);
	});
	
});
 
 function BuildMenuHTML(lbl,url){	
	// Build HTML for heading and return
	output = '';
	output += '<li class="'+ lbl +'"><a href="'+ url + '" target="_self">'+ lbl +'</a></li>';
	return output;
}