var returnVal = '';
var orig = '';
var chiefName = '';

function GetText(xmlHttp,name)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}
	var respText = "";
	if (respDOM[0].firstChild != null) {
		respText = respDOM[0].firstChild.nodeValue;
	}
	return respText;
}

function DisplayText(xmlHttp,name,style,label)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}
	if (respDOM[0].firstChild != null) {
		var respText = respDOM[0].firstChild.nodeValue;
		if (style != "") {
			document.write('<'+style+' class="'+name+'">');
		if (label != "")
			document.write("<span class=textLabel>"+label+": </span>")
			document.write(respText + "</"+style+"> ");
		}
		else
			document.write(respText +" ");
	}
}

function DisplayTextNoSpace(xmlHttp,name)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}
	if (respDOM[0].firstChild != null) {
		var respText = respDOM[0].firstChild.nodeValue;
		document.write(respText);
	}
}

function DisplayComma(xmlHttp,name,style,label)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}
	if (respDOM[0].firstChild != null) {
		var respText = respDOM[0].firstChild.nodeValue;
		if (label != "")
			document.write("<span class=textLabel>"+label+": </span>")
			if (style != "") {
			document.write('<'+style+' class="'+name+'">');
			document.write(respText + ", </"+style+">");
		}
		else
			document.write(respText + ", ");
	}
}

function DisplayGivenLink(xmlHttp,name,style,label,link)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}
	if (respDOM[0].firstChild != null && respDOM[0].firstChild.nodeValue != "NotProvided" && respDOM[0].firstChild.nodeValue != "NotApplicable") {
		var respText = respDOM[0].firstChild.nodeValue;
			if (style != "") {
			document.write('<'+style+' class="'+name+'">');
		if (label != "")
			document.write("<span class=textLabel>"+label+": </span>")
			document.write("<a href='" + link + "'>" + respText + "</a></"+style+"> ");
		}
		else
			document.write("<a href='" + link + "'>" + respText + "</a> ");
	}
}

function DisplayLink(xmlHttp,name,style,label)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}
	if (respDOM[0].firstChild.nodeValue != null) {
		var respText = respDOM[0].firstChild.nodeValue;
			if (style != "") {
			document.write('<'+style+' class="'+name+'">');
		if (label != "")
			document.write("<a href='" + respText + "'>"+label+"</a></"+style+"> ");
		}
		else
			document.write("<a href='" + respText + "'>"+label+"</a> ");
	}
}

function DisplayFeature(xmlHttp,name,style,label)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}
	if (respDOM[0].firstChild != null) {
		var respText = respDOM[0].firstChild.nodeValue;
		if (label != "")
			document.write("<span class=textLabel>"+label+": </span>")
			if (style != "") {
			document.write('<'+style+' class="'+name+'">');
//			document.write("<a href='http://www.marine-geo.org/link/details.php?feature_id=" + respText + "'>"+respText+"</a></"+style+"> ");
			document.write(respText+"</"+style+"> ");
		}
		else
			document.write(respText);
//			document.write("<a href='http://www.marine-geo.org/link/details.php?feature_id=" + respText + "'>"+respText+"</a> ");
	}
}

function DisplayLat(xmlHttp,name,style,label)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}
	if (respDOM[0].firstChild != null  && respDOM[0].firstChild.nodeValue.indexOf("NaN") != 0) {
		var respText = respDOM[0].firstChild.nodeValue;
		if (label != "") {
			if (label == "stopCoord")
				document.write("<br><span class=stopCoord></span>");
			else
				document.write("<span class=textLabel>"+label+": </span>");
		}
			if (style != "") {
			document.write('<'+style+' class="'+name+'">');
			document.write(respText + "</"+style+">, ");
		}
		else
			document.write(respText + ", ");
	}
}

function DisplayDateOld(xmlHttp,name,style,label)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}

	if (respDOM[0].firstChild != null) {
		var respYear = parseInt(respDOM[0].childNodes['10'].firstChild.nodeValue) + 1900;
		var month = (parseInt(respDOM[0].childNodes['6'].firstChild.nodeValue)+1);
		if (month < 10)
			month = "0"+month;
		var day = parseInt(respDOM[0].childNodes['2'].firstChild.nodeValue);
		if (day < 10)
			day = "0"+day;
		var respText = month + "/" + day + "/" + respYear;
		var hour = parseInt(respDOM[0].childNodes['4'].firstChild.nodeValue);
		if (hour < 10)
			hour = "0"+hour;
		var minute = parseInt(respDOM[0].childNodes['5'].firstChild.nodeValue);
		if (minute < 10)
			minute = "0"+minute;
		var second = parseInt(respDOM[0].childNodes['7'].firstChild.nodeValue);
		if (second < 10)
			second = "0"+second;
		if (respDOM[0].childNodes['4'].firstChild.nodeValue != "0") {
			respText += " " + hour + ":" + minute + ":" + second;
			label = "Time";
		}
			if (style != "") {
			document.write('<'+style+' class="'+name+'">');
		if (label != "")
			document.write("<span class=textLabel>"+label+": </span>")
			document.write(respText + "</"+style+"> ");
		}
		else
			document.write(respText +" ");
	}
}

function DisplayDate(xmlHttp,name,style,label)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}
	if (respDOM[0].firstChild != null) {
		var respUnixTime = parseInt(respDOM[0].childNodes['1'].firstChild.nodeValue);
		var theDate = new Date(respUnixTime);
		respText = theDate.toLocaleString();
		if (style != "") {
			document.write('<'+style+' class="'+name+'">');
		if (label != "")
			document.write("<span class=textLabel>"+label+": </span>")
			document.write(respText + "</"+style+"> ");
		}
		else
			document.write(respText +" ");
	}
}

function DisplayStopDateOld(xmlHttp,name)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}

	if (respDOM[0].firstChild != null) {
		var respYear = parseInt(respDOM[0].childNodes['10'].firstChild.nodeValue) + 1900;
		var month = (parseInt(respDOM[0].childNodes['6'].firstChild.nodeValue)+1);
		if (month < 10)
			month = "0"+month;
		var day = parseInt(respDOM[0].childNodes['2'].firstChild.nodeValue);
		if (day < 10)
			day = "0"+day;
		var respText = month + "/" + day + "/" + respYear;
		var hour = parseInt(respDOM[0].childNodes['4'].firstChild.nodeValue);
		if (hour < 10)
			hour = "0"+hour;
		var minute = parseInt(respDOM[0].childNodes['5'].firstChild.nodeValue);
		if (minute < 10)
			minute = "0"+minute;
		var second = parseInt(respDOM[0].childNodes['7'].firstChild.nodeValue);
		if (second < 10)
			second = "0"+second;
		if (respDOM[0].childNodes['4'].firstChild.nodeValue != "0") {
			respText += " " + hour + ":" + minute + ":" + second;
		}
		document.write(" - " + respText);
	}
}

function DisplayStopDate(xmlHttp,name)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}

	if (respDOM[0].firstChild != null) {
		var respUnixTime = parseInt(respDOM[0].childNodes['1'].firstChild.nodeValue);
		var theDate = new Date(respUnixTime);
		respText = theDate.toLocaleString();
		document.write(" - " + respText);
	}
}

function DisplayTextTip(xmlHttp,name,style,label)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}
	if (respDOM[0].firstChild != null && respDOM[0].firstChild.nodeValue.indexOf("NaN") != 0 && respDOM[0].firstChild.nodeValue != "NotProvided" && respDOM[0].firstChild.nodeValue != "NotApplicable") {

		if (label != "")
			document.write("<span class=textLabel>"+label+": </span>")

		var respText = respDOM[0].firstChild.nodeValue;
			if (style != "") {
			document.write('<'+style+' class="'+name+'">');
			document.write(respText.replace("'","\\'") + "</"+style+"> ");
		}
		else
			document.write(respText.replace("'","\\'") +" ");
	}
}

function GetLaunchLinks(xmlHttp)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_launch_name");
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_launch_name");
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_launch_name");
	}

	if (respDOM[0].firstChild != null) {
		document.write("(<a href='");
		if (GetText(xmlHttp,"event_set_uid") != "0") {
			document.write("http://www.marine-geo.org/tools/search/Events.php?event_set_uid=")
			document.write(GetText(xmlHttp,"event_set_uid"));
			document.write("'>");
		}
		else
			document.write("#'>");
		document.write(respDOM[0].firstChild.nodeValue);
		document.write("</a>)");
	}
}

function GetLineLinks(xmlHttp)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_line_name");
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_line_name");
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_line_name");
	}

	if (respDOM[0].firstChild != null) {
		document.write("<div class=textLabel>Line: <a href='");
		document.write("http://www.marine-geo.org/tools/search/Events.php?event_set_uid=")
		document.write(GetText(xmlHttp,"event_set_uid"));
		document.write("'>");
		document.write(respDOM[0].firstChild.nodeValue);
		document.write("</a></div>");
	}
}

function GetPersonText(xmlHttp,name)
{
		var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}

	if (respDOM[0].firstChild != null) {
		document.write("<div class=textLabel>Investigator: ");
		GetPersonInfo(respDOM[0].firstChild.nodeValue);
	}
}

function GetChiefText(xmlHttp,name)
{
		var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}

	if (respDOM[0].firstChild != null) {
		document.write("<div class=textLabel>Chief Scientist: ");
		GetPersonInfo(respDOM[0].firstChild.nodeValue);
	}
}

function GetEntryText(xmlHttp,name)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}

	if (respDOM[0].firstChild != null) {
		GetEntryInfo(respDOM[0].firstChild.nodeValue);
	}
}

function GetReferenceText(xmlHttp,name)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_"+name);
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_"+name);
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_"+name);
	}

	if (respDOM[0].firstChild != null && respDOM[0].firstChild.nodeValue != "0") {
		GetReferenceInfo(respDOM[0].firstChild.nodeValue);
	}
}

function GetCategory(xmlHttp)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_category_id");
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_category_id");
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_category_id");
	}
			var respText = "";
			for (i=0;i<respDOM.length;i++)
	{
		if (i == respDOM.length-1)
			respText += respDOM[i].firstChild.nodeValue;
		else
			respText += respDOM[i].firstChild.nodeValue + ", ";
	}
	return respText;
}

function GetFunding(xmlHttp)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_organization_id");
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_organization_id");
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_organization_id");
	}
	if (GetText(xmlHttp,"media_uid") != "0")
		document.write("<div class=textLabel>Funding Source: ");
		for (i=0;i<respDOM.length;i++)
	{
		if (i == respDOM.length-1)
			GetOrganizationInfo(respDOM[i].firstChild.nodeValue)
		else {
			GetOrganizationInfo(respDOM[i].firstChild.nodeValue)
			document.write(", ");
		}
	}
	if (GetText(xmlHttp,"media_uid") != "0")
		document.write("</div>");
}

function GetInitiative(xmlHttp)
{
	var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_term");
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_term");
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_term");
	}
	document.write("<div class=textLabel>Initiative: <a href='"+GetText(xmlHttp,"url"));
	document.write("'>");
	document.write(respDOM[0].firstChild.nodeValue);
	document.write("</a></div>");
}

function GetCopyright(xmlHttp)
{
		var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_copyright_organization_id");
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_copyright_organization_id");
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_copyright_organization_id");
	}
	if (respDOM[0].firstChild != null) {
		document.write("<div class=textLabel>Copyright: ");
		GetCopyrightOrganizationInfo(respDOM[0].firstChild.nodeValue);
		document.write("</div>");
	}
}

var speciesSearchText = "";
function GetSpeciesSearch(xmlHttp)
{
		var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_bio_species_id");
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_bio_species_id");
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_bio_species_id");
	}
	if (GetText(xmlHttp,"media_uid") != "0") {
			for (i=0;i<respDOM.length;i++)
	{
		if (i == respDOM.length-1) {
			speciesSearchText += respDOM[i].firstChild.nodeValue;
		}
		else { 
			speciesSearchText += respDOM[i].firstChild.nodeValue + " ";
		}
	}
	}
}

function GetSpecies(xmlHttp)
{
		var respXML=xmlHttp.responseXML;
	var respDOM=respXML.getElementsByTagName("_bio_species_id");
	if(navigator.appName == "Microsoft Internet Explorer")
		respDOM=respXML.getElementsByTagName("ax21:_bio_species_id");
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3)
			respDOM=respXML.getElementsByTagName("ax21:_bio_species_id");
	}
	if (GetText(xmlHttp,"media_uid") != "0") {
			for (i=0;i<respDOM.length;i++)
	{
		if (i == 0)
			document.write("<div><span class=textLabel>Species (latin):</span> ");
		if (i == respDOM.length-1) {
			document.write(respDOM[i].firstChild.nodeValue);
			document.write("</div>");
		}
		else { 
			document.write(respDOM[i].firstChild.nodeValue + ", ");
		}
	}
	}
}

function GetMediaId(name) {
	var url="/axis2/services/MediaBankService/GetMediaId";
	url=url+"?name="+name;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetMediaIdResponse
	});
}

function GetMediaIdResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		var respXML=xmlHttp.responseXML;
		returnVal = respXML.firstChild.firstChild.firstChild.nodeValue;
	}
}

function GetOrigImage(id) {
	var url="/axis2/services/MediaBankService/GetMediaInfo";
	url=url+"?id="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetOrigImageResponse
	});
}

function GetOrigImageResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		document.write("The image below is the hi-resolution image you chose. To download this image, right-click and select 'Save Image As...' or click and drag the image to your desktop.<br />You can also right-click on the following link and select 'Save Target As...' (Internet Explorer and Firefox) or 'Download Linked File As...' (Safari): <a href='/files/images/"+GetText(xmlHttp,"file_name")+"'>Download Image</a><br /><H2>"+GetText(xmlHttp,"media_title")+"</H2><img src='/files/images/"+GetText(xmlHttp,"file_name")+"' /><br />");
	}
}

function GetPreviewImage(id) {
	var url="/axis2/services/MediaBankService/GetMediaInfo";
	url=url+"?id="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetPreviewImageResponse
	});
}

function GetPreviewImageResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		document.write("<H2>"+GetText(xmlHttp,"media_title")+"</H2><img src='/files/images/"+GetText(xmlHttp,"file_name").replace(/.jpg/i,".preview.jpg")+"' /><br />");
	}
}

function GetMediaInfo(id) {
	var url="/axis2/services/MediaBankService/GetMediaInfo";
	url=url+"?id="+id;
	_media_uid = id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetMediaInfoResponse
	});
}

function GetMediaInfoResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		var respXML=xmlHttp.responseXML;
		var respDOM=respXML.getElementsByTagName("_media_uid");
		if(navigator.appName == "Microsoft Internet Explorer")
			respDOM=respXML.getElementsByTagName("ax21:_media_uid");
		if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
			var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
			if (ffversion>=3)
				respDOM=respXML.getElementsByTagName("ax21:_media_uid");
		}
		DisplayText(xmlHttp,"caption","div","");
		document.write("<br>");
		GetChiefEntry3(GetText(xmlHttp,"entry_id"));
		if (GetText(xmlHttp,"investigator_person_id") != chiefName && chiefName != '') {
			document.write("<span id='investigator' style='float:left'>");
			GetPersonText(xmlHttp,"investigator_person_id");
			//document.write("</span><span id='chiefScientist' style='clear:right'>, <a href='http://media.marine-geo.org/search/node/"+chiefName+"'>"+chiefName+"<span></div>");
			document.write("</span><span id='chiefScientist' class='textLabel' style='clear:right'>, ");
			GetChiefEntry2(GetText(xmlHttp,"entry_id"));
			document.write("</span>");
		}
		else
			GetPersonText(xmlHttp,"investigator_person_id");
		DisplayFeature(xmlHttp,"feature_id","span","Feature");
		document.write("<div>");
		DisplayLat(xmlHttp,"start_latitude","span","Location");
		DisplayText(xmlHttp,"start_longitude","","");
		DisplayLat(xmlHttp,"stop_latitude","span","stopCoord");
		DisplayText(xmlHttp,"stop_longitude","","");
		document.write("</div>");
		DisplayDate(xmlHttp,"start_date","span","Date");
		DisplayStopDate(xmlHttp,"stop_date");
		GetEntryText(xmlHttp,"entry_id");
		if (GetText(xmlHttp,"platform_id") != "")
			GetPlatformInfo(GetText(xmlHttp,"platform_id"));
		GetLaunchLinks(xmlHttp);
		GetLineLinks(xmlHttp);
		DisplayGivenLink(xmlHttp,"nav_type","div","Navigation Type","http://www.marine-geo.org/references/descriptions/NavType.php");
		DisplayText(xmlHttp,"depth","div","Depth(m)");
//		DisplayText(xmlHttp,"species_name_common","div","Species (common)");
		GetSpeciesInfo(respDOM[0].firstChild.nodeValue);
		GetFundingInfo(respDOM[0].firstChild.nodeValue);
		if (GetText(xmlHttp,"initiative_id") != "")
			GetInitiativeInfo(GetText(xmlHttp,"initiative_id"));
		GetCopyright(xmlHttp);
		GetReferenceText(xmlHttp,"reference_uid");
		if (GetText(xmlHttp,"file_format_id") == 'JPEG' || GetText(xmlHttp,"file_format_id") == 'JPG' || GetText(xmlHttp,"file_format_id") == 'GIF' || GetText(xmlHttp,"file_format_id") == 'PNG' || GetText(xmlHttp,"file_format_id") == 'BMP') {
			if (GetText(xmlHttp,"permissions_for_use") == "1")
				document.write('<br /><b>Instructions:</b><br />To download this preview image, right-click and select "Save Image As..." or click and drag the image to your desktop.<br /><br /><div class="textLabel"><img src="/files/download_icon.gif"> <a href="/view-hi-res-image?image_url='+orig+'&image_uid='+respDOM[0].firstChild.nodeValue+'">Download Full Resolution Image</a>');
			if (GetText(xmlHttp,"permissions_for_use") == "2")
				document.write('<br /><b>Instructions:</b><br />To download this preview image, right-click and select "Save Image As..." or click and drag the image to your desktop.<br /><br /><div class="textLabel"><img src="/files/download_icon.gif"> <a href="/email-hi-res-image?image_url='+orig+'&image_uid='+respDOM[0].firstChild.nodeValue+'">Download Full Resolution Image</a> (This image has restricted access and requires permission first)');
		}
		document.write("<div class='textLabel'><br><img src='/files/googleEarth.gif'> <a href='http://www.marine-geo.org/services/mediabankkmz?media_uid="+respDOM[0].firstChild.nodeValue+"'>Download for Google Earth</a></div>");
		document.write("<div class='commericalUse'><br>For non-commerical use only.</div>");
	}
}

function GetMediaInfoSlim(id) {
	var url="/axis2/services/MediaBankService/GetMediaInfo";
	url=url+"?id="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetMediaInfoSlimResponse
	});
}

function GetMediaInfoSlimResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		DisplayText(xmlHttp,"caption","div","");
	}
}

function GetEntryInfo(id) {
	var url="/axis2/services/MediaBankService/GetEntryInfo";
	url=url+"?id="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetEntryInfoResponse
	});
}

function GetEntryInfoResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		document.write("<div class=hasTip onmouseover=\"Tip('");
		DisplayTextTip(xmlHttp,"entry_type","","Type");
		DisplayTextTip(xmlHttp,"feature_id","","<br>Feature");
		DisplayTextTip(xmlHttp,"operator_id","","<br>Operator");
		DisplayTextTip(xmlHttp,"platform_id","","<br>Platform");
		if (GetText(xmlHttp,"northernmost_latitude").substring(0,3) != "NaN") {
			DisplayLat(xmlHttp,"northernmost_latitude","","<br><div class=coords>Coordinates</div>NW");
			DisplayTextTip(xmlHttp,"westernmost_longitude","","");
			DisplayLat(xmlHttp,"southernmost_latitude","","<br>SE");
			DisplayTextTip(xmlHttp,"easternmost_longitude","","");
		}
		document.write("')\" onmouseout='UnTip()'>");
		document.write("<span class=textLabel>Expedition/Compilation: </span>");
		document.write("<a href='");
		DisplayText(xmlHttp,"url","","");
		document.write("'>");
		DisplayText(xmlHttp,"entry_id","","");
		document.write("</a></div>");
		//GetChiefText(xmlHttp,"person_id");
	}
}

function GetReferenceInfo(id) {
	var url="/axis2/services/MediaBankService/GetReferenceInfo";
	url=url+"?id="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetReferenceInfoResponse
	});
}

function GetReferenceInfoResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		document.write("<div><span class=textLabel>Reference: </span>");
		DisplayText(xmlHttp,"authors","","");
		document.write('('+GetText(xmlHttp,"year")+'), ');
		document.write(GetText(xmlHttp,"title"));
		document.write(', <i>'+GetText(xmlHttp,"journal")+'</i>, ');
		DisplayComma(xmlHttp,"volume","","");
		DisplayComma(xmlHttp,"pages","","");
		DisplayComma(xmlHttp,"issn","","");
		DisplayTextNoSpace(xmlHttp,"doi");
		document.write('. ');
		DisplayLink(xmlHttp,"url","","Webpage");
		document.write("</div>");
	}
}

function GetPlatformInfo(id) {
	var url="/axis2/services/MediaBankService/GetPlatformInfo";
	url=url+"?term="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetPlatformInfoResponse
	});
}

function GetPlatformInfoResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		document.write('<span class="platform_id">');
		document.write("<span class=textLabel>Platform: </span>")
		if (GetText(xmlHttp,"url") != "")
			document.write("<a href='"+GetText(xmlHttp,"url")+"'>"+GetText(xmlHttp,"term")+"</a>");
		else
			document.write(GetText(xmlHttp,"term"));
		document.write("</span> ");
	}
}

function GetPersonInfo(id) {
	var url="/axis2/services/MediaBankService/GetPersonInfo";
	url=url+"?id="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetPersonInfoResponse
	});
}

function GetPersonInfoResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		document.write("<span class=hasTip onmouseover=\"Tip('");
					DisplayTextTip(xmlHttp,"email","","Email");
			DisplayTextTip(xmlHttp,"email_alternative","","<br>Secondary Email");
			DisplayTextTip(xmlHttp,"nick_name","","<br>Nickname");
					DisplayTextTip(xmlHttp,"phone","","<br>Phone");
					DisplayTextTip(xmlHttp,"fax","","<br>Fax");
					DisplayTextTip(xmlHttp,"current_institution_name","","<br>Institution");
		document.write("')\" onmouseout='UnTip()'>");
		document.write("<a href='http://media.marine-geo.org/search/node/"+GetText(xmlHttp,"first_name")+"+"+GetText(xmlHttp,"last_name")+"'>");
		DisplayText(xmlHttp,"first_name","","");
		DisplayText(xmlHttp,"middle_name","","");
		DisplayText(xmlHttp,"last_name","","");
		document.write("</a></span></div>");
	}
}

function GetCategoryMap(id) {
	var url="/axis2/services/MediaBankService/GetCategoryMap";
	url=url+"?id="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetCategoryMapResponse
	});
}

function GetCategoryMapResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		var Category = null;
		Category = GetCategory(xmlHttp);
		if (Category == "null")
			$ID('edit-taxonomy-tags-5').value="Uncategorized";
		else
			$ID('edit-taxonomy-tags-5').value=Category;
	}
}

function GetOrganizationInfo(term) {
	var url="/axis2/services/MediaBankService/GetOrganizationInfo";
	url=url+"?term="+term;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetOrganizationInfoResponse
	});
}

function GetOrganizationInfoResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		document.write("<span class=hasTip onmouseover=\"Tip('");
					DisplayTextTip(xmlHttp,"term","","Organization");
					DisplayTextTip(xmlHttp,"description","","<br>Description");
					DisplayTextTip(xmlHttp,"url","","<br>Website");
		document.write("')\" onmouseout='UnTip()'>");
		document.write("<a href='");
		DisplayText(xmlHttp,"url","","");
		document.write("'>"+GetText(xmlHttp,"description"));
		document.write("</a></span>");
	}
}

function GetCopyrightOrganizationInfo(term) {
	var url="/axis2/services/MediaBankService/GetOrganizationInfo";
	url=url+"?term="+term;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetCopyrightOrganizationInfoResponse
	});
}

function GetCopyrightOrganizationInfoResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		document.write("<span class=hasTip onmouseover=\"Tip('");
					DisplayTextTip(xmlHttp,"term","","Organization");
					DisplayTextTip(xmlHttp,"description","","<br>Description");
					DisplayTextTip(xmlHttp,"url","","<br>Website");
		document.write("')\" onmouseout='UnTip()'>");
		document.write("<a href='");
		if (GetText(xmlHttp,"url_copyright") == "")
		DisplayText(xmlHttp,"url","","");
		else
		DisplayText(xmlHttp,"url_copyright","","");
		document.write("'>"+GetText(xmlHttp,"description"));
		document.write("</a></span>");
	}
}

function GetSpeciesInfo(id) {
	var url="/axis2/services/MediaBankService/GetSpeciesInfo";
	url=url+"?id="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetSpeciesInfoResponse
	});
}

function GetSpeciesInfoResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		GetSpecies(xmlHttp);
	}
}

function GetSpeciesInfoSearch(id) {
	var url="/axis2/services/MediaBankService/GetSpeciesInfo";
	url=url+"?id="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetSpeciesInfoResponseSearch
	});
}

function GetSpeciesInfoResponseSearch(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		GetSpeciesSearch(xmlHttp);
	}
}

function GetFundingInfo(id) {
	var url="/axis2/services/MediaBankService/GetFundingInfo";
	url=url+"?id="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetFundingInfoResponse
	});
}

function GetFundingInfoResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		GetFunding(xmlHttp);
	}
}

function GetInitiativeInfo(id) {
	var url="/axis2/services/MediaBankService/GetInitiativeInfo";
	url=url+"?term="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetInitiativeInfoResponse
	});
}

function GetInitiativeInfoResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		GetInitiative(xmlHttp);
	}
}

function GetChief(id)
{
	var url="/axis2/services/MediaBankService/GetMediaInfo";
	url=url+"?id="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetChiefResponse
	});
}

function GetChiefResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		GetChiefEntry(GetText(xmlHttp,"entry_id"));
	}
}

function GetChiefEntry(id) {
	var url="/axis2/services/MediaBankService/GetEntryInfo";
	url=url+"?id="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetChiefEntryResponse
	});
}

function GetChiefEntryResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		GetName(GetText(xmlHttp,"person_id"));
	}
}

function GetChiefEntry2(id) {
	var url="/axis2/services/MediaBankService/GetEntryInfo";
	url=url+"?id="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetChiefEntryResponse2
	});
}

function GetChiefEntryResponse2(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		GetPersonInfo(GetText(xmlHttp,"person_id"));
	}
}

function GetName(id) {
	var url="/axis2/services/MediaBankService/GetPersonInfo";
	url=url+"?id="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetNameResponse
	});
}

function GetNameResponse(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		chiefName = GetText(xmlHttp,"first_name") + " " + GetText(xmlHttp,"last_name");
	}
}

function GetChiefEntry3(id) {
	var url="/axis2/services/MediaBankService/GetEntryInfo";
	url=url+"?id="+id;
	var pars=null;
	var ajaxRequest = new Ajax.Request(url, {
			method:       "get", 
			parameters:   pars, 
			asynchronous: false,
			onComplete:   GetChiefEntryResponse3
	});
}

function GetChiefEntryResponse3(xmlHttp)
{
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
		chiefName = GetText(xmlHttp,"person_id");
	}
}