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("These mothers are on a mission to powerfully tear down stereotypes and promote religious and cultural tolerance around the world. Hand-selected for their beauty both inside and out, the \"devout dozen\" are stepping away from the Mormon traditions of modest dress, and \"baring their testimony\" to demonstrate that they can have strong faith and be proud of who they are, while reaching out to a broad audience with a sense of individualism and a sense of humor."));
	bioBlock.appendChild(para);
}

function showMuffin(muffin, 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/'+muffin+'.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(191, 158);
				shirt.src = '/'+PREFIX+'images/meet/head_'+muffin+'.png';

				var skin = new Image(266, 181);
				skin.src = '/'+PREFIX+'images/meet/cal_'+muffin+'.png';

				var muffinHead = document.getElementById('muffinHead');
				muffinHead.src = '/'+PREFIX+'images/meet/head_'+muffin+'.png';

				muffinHead.onmouseover = function() {
					this.src = '/'+PREFIX+'images/meet/cal_'+muffin+'.png';
					return true;
				}
				muffinHead.onmouseout = function() {
					this.src = '/'+PREFIX+'images/meet/head_'+muffin+'.png';
					return true;
				}

				var muffinInfo = xmlDoc.getElementsByTagName('muffin');
				if (muffinInfo.length > 0) {
					muffinInfo = muffinInfo[0];
					
					// get rid of the current bio
					emptyBlock(bioBlock);
					
					// find our bio and MySpace Address
					var bios = muffinInfo.getElementsByTagName('bio');
					var myspace = muffinInfo.getElementsByTagName('myspace');
					var facebook = muffinInfo.getElementsByTagName('facebook');
					var hometown = muffinInfo.getElementsByTagName('hometown');
					var month = muffinInfo.getElementsByTagName('month')[0].childNodes[0].nodeValue;
					var muffinName = muffinInfo.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/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/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(muffinName+' '));
					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);
					}
				}
			} 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;
}
