
function removeSpaces(string) {
	return string.split(' ').join('');
	}

function createJobLink (name, description, listPosition ) {

	jobName = name;
	jobID = removeSpaces(name);
	jobItemID = "ITEM" + jobID;
	jobDescription = description;
	jobTitle="View job description"

	jobItemSegment1 = '<li class="right"> <a href="#" onclick="markJobChoice(';
	jobItemSegment2 = '); showSelectedJob (';
	jobItemSegment3 = ');" title="';
	jobItemSegment4 = '"><span ID="';
	jobItemSegment5 = '" class="job_item_off">';
	jobItemSegment6 = '</span></a></li>' ;

	jobItemLink = 
		jobItemSegment1 + "'" + jobItemID + "'" + 
		jobItemSegment2 + "'" + jobName + "','" + jobDescription + "'" + 
		jobItemSegment3 + jobTitle +
		jobItemSegment4 + jobItemID + 
		jobItemSegment5 + jobName + 
		jobItemSegment6;

	document.write(jobItemLink);

	}

function buildJobList () {
	if (window.XMLHttpRequest)
		{
			xhttp=new XMLHttpRequest();
			}
	else // Internet Explorer 5/6
		{
			xhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
	xhttp.open("GET","careers_catalog.xml",false);
	xhttp.send("");
	xmlDoc=xhttp.responseXML;
	var x=xmlDoc.getElementsByTagName("OPENING");
	for (i=0;i<x.length;i++)
		{
			jobName=x[i].getElementsByTagName("NAME")[0].childNodes[0].nodeValue;
			jobDescription=x[i].getElementsByTagName("DESCRIPTION")[0].childNodes[0].nodeValue;
			createJobLink(jobName,jobDescription,i);}
	}



function getHTTPObject() {
	var xmlhttp = false;
	/*@cc_on
	@if (@_jscript_version >= 5)
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) { xmlhttp = false; }
		}
	@end @*/

	if (!xmlhttp) {
		try {
			xmlhttp = new XMLHttpRequest();
			} catch (e) {
      	try {
			xmlhttp = window.createRequest();
			} catch (e) { xmlhttp = false; }
		}
	}
	return xmlhttp;
	}


function showSelectedJob (name, description) {

	jobID = removeSpaces(name);

	jobHeader = 
		"<h1><span class='job_name'>" +
		name +
		"</span></h1>" 
		
	document.getElementById("JOBHEADER").innerHTML=jobHeader ;
	document.getElementById("JOBHEADER").className="job_header_highlight" ;

	jobDescription = 
		"<p class='content'>" +
		description +
		"</p>" 
		
	document.getElementById("JOBDESCRIPTION").innerHTML=jobDescription ;
	document.getElementById("JOBDESCRIPTION").className="job_description_highlight" ;

	}



function markJobChoice (selectedOption) {
	for (i=0;i<document.getElementsByTagName("span").length; i++) {
		if (document.getElementsByTagName("span").item(i).className == "job_item_on"){
			document.getElementsByTagName("span").item(i).className = "job_item_off";
			document.getElementsByTagName("span").item(i).MPStatus = "notSelected";
		}
	}
	document.getElementById(selectedOption).className = "job_item_on";
	document.getElementById(selectedOption).MPStatus = "selected";
}



