/* */
var xmlDoc;

function createXMLDocument(filename)
{
	var xmlhttp = null;
	if (window.XMLHttpRequest) { // code for all new browsers
		xmlhttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // code for IE5 and IE6
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}

	xmlhttp.open("GET", filename, false);
	xmlhttp.send(null);

	// Assert that response was ok (not sure if its needed with synchronous reading)
	if (xmlhttp.status != 200) {
		// hide alert
		//alert("Problem retrieving XML data. HTTP status returned " + xmlhttp.status);
		return;
	}

	// Read the xml stream to the DOM
	xmlDoc = xmlhttp.responseXML;
}

function WriteMenu(xmlPath)
{
	createXMLDocument(xmlPath);
	var x = xmlDoc.getElementsByTagName('item');

	document.write("<UL class=programs-list>");
	for(var i=0;i<x.length;i++)
	{
			y=x[i].getElementsByTagName('subitem');
			page_link=x[i].getAttribute("url");
			if(page_link=="" || page_link==null)
				page_link="#";
				
			if(y.length>=1)
			{
				document.write("<li><a href='"+page_link+"'>"+x[i].getAttribute("name")+"</a></li></ul>");
				document.write("<UL class='name'>");
				for(var j=0;j<y.length;j++)
				{
						subpage_link=y[j].getAttribute("url");
						if(subpage_link=="" || subpage_link==null)
							subpage_link="#";

						document.write("<li><a href='"+subpage_link+"'>"+y[j].getAttribute("name")+"</a></li>");
				}
				document.write("</UL><UL class=programs-list>");
			}
			else
			{
				document.write("<li><a href='"+page_link+"'>"+x[i].getAttribute("name")+"</a></li>");
			}
	}
	document.write("</UL>");
}

function WriteQuickJumpList(xmlPath)
{
	createXMLDocument(xmlPath);
	//xmlDoc.load(xmlPath);
	var x = xmlDoc.getElementsByTagName('item');

	for(var i=0;i<x.length;i++)
	{
			y=x[i].getElementsByTagName('subitem');
			page_link=x[i].getAttribute("url");
			if(page_link=="" || page_link==null)
				page_link="#";
				
			if(y.length>=1)
			{
				$('#quickjump').append("<option value='"+page_link+"' style='background-color: #0096B8; color: white;'>&nbsp;&nbsp;"+x[i].getAttribute("name")+"</option>");
				for(var j=0;j<y.length;j++)
				{
						subpage_link=y[j].getAttribute("url");
						if(subpage_link=="" || subpage_link==null) { subpage_link="#"; }
						$('#quickjump').append("<option value='"+subpage_link+"'>&nbsp;&nbsp;&nbsp;&nbsp;"+y[j].getAttribute("name")+"</option>");
				}
			}
			else
			{
				$('#quickjump').append("<option value='"+page_link+"'>&nbsp;&nbsp;"+x[i].getAttribute("name")+"</option>");
			}
	}
}

function WriteQuickJump()
{
	$('#quickjump').append("<option value=''>Quick Jump</option>");
	$('#quickjump').append("<option value='highereducation.aspx' style='background-color: #1B0069; color: white;'>Higher Education</option>");
	WriteQuickJumpList('QuickJumpList.aspx?t=edu');
	$('#quickjump').append("<option value='professional.aspx' style='background-color: #1B0069; color: white;'>Professional Qualification</option>");
	WriteQuickJumpList('QuickJumpList.aspx?t=prof');
	$('#quickjump').append("<option value='financial.aspx' style='background-color: #1B0069; color: white;'>Financial Training</option>");
	WriteQuickJumpList('QuickJumpList.aspx?t=fin');
	$('#quickjump').append("<option value='corporate.aspx' style='background-color: #1B0069; color: white;'>Corporate Training</option>");
	WriteQuickJumpList('QuickJumpList.aspx?t=corp');
	$('#quickjump').append("<option value='language.aspx' style='background-color: #1B0069; color: white;'>Language School</option>");
	WriteQuickJumpList('QuickJumpList.aspx?t=lang');
	$('#quickjump option:first').attr('selected', 'selected');
}

function CreateBookmarkLink()
{
	title = document.title;
	url = window.location.href;
	
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
}
