<!--
//==========================================================
// This function does the HTML for the "latest jobs" table. 
// The data comes from the jobs XML files.
// Parameter CountryCode is GB or SA.  
//==========================================================
function doLatestJobsTable1(CountryCode) {
	var xmlDoc, JobsArray; 
	var JobTitles = new Array(8);
	var JobCodes = new Array(8);
	var Locations = new Array(8);
	var Files = new Array(8);
	var XMLFile = "", Country = "", JobDir = ""; 
	var Str = ""; 
	var i=0, iJobs=0; 

	//-----------------------
	// Open up jobs XML file
	//-----------------------
	if (CountryCode == "SA") 
	{
		JobDir = "SAJobs/";
		XMLFile = "SAJobs/AllSAJobs.xml";
		Country = "South African";
	}
	if (CountryCode == "GB") 
	{
		JobDir = "GBJobs/";
		XMLFile = "GBJobs/AllGBJobs.xml";
		Country = "Great Britain";
	}

	if (XMLFile == "" || Country == "" || JobDir == "") return 2;
	else
	{
		xmlDoc = XMLFileLoad(XMLFile, true, true); 
		if (xmlDoc == null) return 1;
		else
		{
			//-----------------
			// Fill jobs array
			//-----------------
			JobsArray = xmlDoc.getElementsByTagName("JOB");
			if (JobsArray.length <= 0) return 2;
			else 
			{
				//----------------------------------------------------
				// Get titles and codes of up to 8 of the latest jobs
				//----------------------------------------------------
				if (JobsArray.length < 8) iJobs = JobsArray.length;
				else iJobs = 8; 
				for (i=0; i<iJobs; i++)
				{
					JobTitles[i] = TrimString(getChildNode(JobsArray[i], "TITLE", 1, true, "?"));
					if (JobTitles[i] == "?") JobTitles[i] = "Unknown Job";
					JobCodes[i] = TrimString(getChildNode(JobsArray[i], "CODE", 1, true, "?"));
					Locations[i] = TrimString(getChildNode(JobsArray[i], "LOCATION", 1, true, "?"));
					Files[i] = TrimString(getChildNode(JobsArray[i], "FILE", 1, true, "?"));
				}
		
				//----------------------------------------------
				// HTML for the latest jobs table.
				// Create link to job page if we have the file. 
				//----------------------------------------------
				if (iJobs>1)
				{
					document.write("<td align=\"center\" nowrap=\"nowrap\">");
					for (i=0; i<iJobs; i++)
					{
						document.write("<p>");
						if (Files[i] != "?")
						{
							Str = "";
							Str = Str + "<a href=\""+ JobDir + Files[i] + ".xml\">";
							document.write(Str);
						}
						document.write(JobTitles[i]);
						if (Locations[i] != "?") document.write(", " + Locations[i]);
						if (JobCodes[i] != "?") document.write(" (" + JobCodes[i] + ")");
						if (Files[i] != "?") document.write("</a>"); 
						document.write("</p>");
					}
					document.write("</td>");
				}
				else
				{
					document.write("<td align=\"center\" nowrap=\"nowrap\">");
					document.write("<p>");
					if (Files[0] != "")
					{
						Str = "";
						Str = Str + "<a href=\""+ JobDir + Files[0] + ".xml\">";
						document.write(Str);
					}
					document.write(JobTitles[0]);
					if (Locations[0] != "?") document.write(", " + Locations[0]);
					if (JobCodes[0] != "?") document.write(" (" + JobCodes[0] + ")");
					if (Files[0] != "?") document.write("</a>"); 
					document.write("</p>");
					document.write("</td>");
				}
				return 0; 
			}
		}
	}
}// End of function doLatestJobsTable1(CountryCode)
-->
