function resetPage(PREFIX) {

	var bioBlock = document.getElementById('bio');

	// Show the strings
	var strings = document.getElementById('strings');
	strings.style.visibility = 'visible';

	// Show the Map
	var gmap = document.getElementById('gmap');
	gmap.style.visibility = 'hidden';

	// Switch out the pic
	var plaqueimage = document.getElementById('plaqueimage');
	plaqueimage.src = '/'+PREFIX+'images/meet_elements/default.png';
	plaqueimage.onmouseover = null;
	plaqueimage.onmouseout = null;

	// get rid of the current bio
	emptyBlock(bioBlock);

	var para = document.createElement("p");
	para.appendChild(document.createTextNode("More than 50,000 missionaries are currently serving missions for The Church of Jesus Christ of Latter-Day Saints. Most are young people under the age of 25, serving in nearly 350 missions throughout the world. All Missionaries pay their own expenses, and after two years of work, they return to their countries and their ordinary lives."));
	bioBlock.appendChild(para);

	var para = document.createElement("p");
	para.appendChild(document.createTextNode("They can continue to preach the Gospel as laymen without getting paid as there are no paid missionaries in the Mormon Church. During their mission, they are required to dedicate all their time to missionary work and are not allowed to read the newspaper, surf the Internet and watch television or movies. Besides these dont's, all Mormons are forbidden to drink alcohol, coffee or tea; to smoke cigarettes and to have premarital sex or commit adultery."));
	bioBlock.appendChild(para);
}

function showMissionary(missionary, PREFIX) {

	var bioBlock = document.getElementById('bio');

	// Innitalize our request object
	var ajax = getAjax();

	// Set our URL to retrieve our XML doc
	var url='/'+PREFIX+'xml/'+missionary+'.xml';

	// Make sure that we handle the XML once it comes back
	ajax.onreadystatechange = function() {
		switch (ajax.readyState) {
			case 0:
//				var newButton = document.createTextNode('-- initilizing --');
//				statusSpan.replaceChild(newButton, statusSpan.childNodes[1]);
			break;
			case 1:
//				var newButton = document.createTextNode('-- requesting --');
//				statusSpan.replaceChild(newButton, statusSpan.childNodes[1]);
			break;
			case 2:
//				var newButton = document.createTextNode('----- sent -----');
//				statusSpan.replaceChild(newButton, statusSpan.childNodes[1]);
			break;
			case 3:
//				var newButton = document.createTextNode('-- processing --');
//				statusSpan.replaceChild(newButton, statusSpan.childNodes[1]);
			break;
			case 4:
			if (ajax.status == 200) {
				if (!ajax.responseXML) {
					alert(ajax.responseText);
					return false;
				}
				var xmlDoc = ajax.responseXML.documentElement;
	
				// Hide the strings
				var strings = document.getElementById('strings');
				strings.style.visibility = 'hidden';
			
				// Show the Map
				var gmap = document.getElementById('gmap');
				gmap.style.visibility = 'visible';

				// Switch out the pic
				var shirt = new Image(266, 181);
				shirt.src = '/'+PREFIX+'images/meet_elements/'+missionary+'_m.png';

				var plaqueimage = document.getElementById('plaqueimage');
				plaqueimage.src = '/'+PREFIX+'images/meet_elements/'+missionary+'_m.png';
				plaqueimage.onmouseover = function() {
					this.src = '/'+PREFIX+'images/meet_elements/'+missionary+'_i.png';
					return true;
				}
				plaqueimage.onmouseout = function() {
					this.src = '/'+PREFIX+'images/meet_elements/'+missionary+'_m.png';
					return true;
				}

				var skin = new Image(266, 181);
				skin.src = '/'+PREFIX+'images/meet_elements/'+missionary+'_i.png';

				var missionInfo = xmlDoc.getElementsByTagName('missionary');
				if (missionInfo.length > 0) {
					missionInfo = missionInfo[0];
					
					// get rid of the current bio
					emptyBlock(bioBlock);
					
					// find our bio and MySpace Address
					var bios = missionInfo.getElementsByTagName('bio');
					var myspace = missionInfo.getElementsByTagName('myspace');
					var facebook = missionInfo.getElementsByTagName('facebook');
					var hometown = missionInfo.getElementsByTagName('hometown');
					var mission = missionInfo.getElementsByTagName('mission');
					var month = missionInfo.getElementsByTagName('month')[0].childNodes[0].nodeValue;
					var missionaryName = missionInfo.getElementsByTagName('name')[0].childNodes[0].nodeValue;

					var titleDiv = document.createElement("div");
					titleDiv.className = "title";

					if (myspace.length > 0 && myspace[0].hasChildNodes()) {
						var myspaceLink = document.createElement("a");
						myspaceLink.target = "_blank";
						myspaceLink.href = myspace[0].childNodes[0].nodeValue;
//						myspaceLink.appendChild(document.createTextNode("MySpace"));

						var myspaceImg = document.createElement("img");
						myspaceImg.src = '/'+PREFIX+'images/meet_elements/myspace.png';

						myspaceLink.appendChild(myspaceImg);
						titleDiv.appendChild(myspaceLink);
					}

					if (facebook.length > 0 && facebook[0].hasChildNodes()) {
						var facebookLink = document.createElement("a");
						facebookLink.target = "_blank";
						facebookLink.href = facebook[0].childNodes[0].nodeValue;
//						facebookLink.appendChild(document.createTextNode("facebook"));

						var facebookImg = document.createElement("img");
						facebookImg.src = '/'+PREFIX+'images/meet_elements/facebook.png';

						facebookLink.appendChild(facebookImg);
						titleDiv.appendChild(facebookLink);
					}

					var monthSpan = document.createElement("span");
					monthSpan.className = "month";
					monthSpan.appendChild(document.createTextNode('"'+month+'"'));

					titleDiv.appendChild(document.createTextNode(missionaryName+' '));
					titleDiv.appendChild(monthSpan);

					if (hometown.length > 0 && hometown[0].hasChildNodes()) {
						var hometownB = document.createElement("b");
						hometownB.appendChild(document.createTextNode("Hometown: "));

						var hometownSpan = document.createElement("span");
						hometownSpan.appendChild(hometownB);
						hometownSpan.appendChild(document.createTextNode(hometown[0].childNodes[0].nodeValue));

						titleDiv.appendChild(document.createElement("br"));
						titleDiv.appendChild(hometownSpan);
					}

					bioBlock.appendChild(titleDiv);

					if (bios.length > 0) for (var i=0; i < bios.length ;++i) {
						var para = document.createElement("p");
						para.appendChild(document.createTextNode(bios[i].childNodes[0].nodeValue));
						bioBlock.appendChild(para);
					}

					// Re-center our map
//					alert(missionInfo.getElementsByTagName('glat')[0].childNodes[0].nodeValue+','+missionInfo.getElementsByTagName('glon')[0].childNodes[0].nodeValue+','+missionInfo.getElementsByTagName('gzoom')[0].childNodes[0].nodeValue);
					if (mission.length > 0 && mission[0].hasChildNodes()) {
						var missionB = document.createElement("b");
						missionB.appendChild(document.createTextNode(missionaryName+":"));
						missionB.appendChild(document.createElement("br"));

						var missionDiv = document.createElement("div");
						missionDiv.className = "mapInfo";
						missionDiv.appendChild(missionB);
						missionDiv.appendChild(document.createTextNode(mission[0].childNodes[0].nodeValue));

						var newCenter = new GLatLng((parseFloat(missionInfo.getElementsByTagName('glat')[0].childNodes[0].nodeValue) + (4 * (1 / parseFloat(missionInfo.getElementsByTagName('gzoom')[0].childNodes[0].nodeValue)))), missionInfo.getElementsByTagName('glon')[0].childNodes[0].nodeValue);
						var newInfo = new GLatLng(missionInfo.getElementsByTagName('glat')[0].childNodes[0].nodeValue, missionInfo.getElementsByTagName('glon')[0].childNodes[0].nodeValue);
						map.setCenter(newCenter, parseInt(missionInfo.getElementsByTagName('gzoom')[0].childNodes[0].nodeValue));
						map.openInfoWindow(newInfo, missionDiv);
					} else {
						var newCenter = new GLatLng(missionInfo.getElementsByTagName('glat')[0].childNodes[0].nodeValue, missionInfo.getElementsByTagName('glon')[0].childNodes[0].nodeValue);
						map.setCenter(newCenter, parseInt(missionInfo.getElementsByTagName('gzoom')[0].childNodes[0].nodeValue));
					}
				}
			} else {
				alert(ajax.status);
			}
		}
	}

	ajax.open('GET', url, true);
	ajax.send(null);
}


/////////////////////////////////////////////////////////////////////////////////////
/// General Functions
/////////////////////////////////////////////////////////////////////////////////////

/* 
 * Removes all children from a node
 */
function emptyBlock(block) {
	var blockLength = block.childNodes.length;
	for (var i=0; i < blockLength ;++i)
		block.removeChild(block.firstChild);
}

/* 
 * Initilizes our XMLHttpRequest object
 */
function getAjax() {
	// Detect our browser and assign the xmlHttp variable
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return xmlHttp;
}
