var xmlhttp;
var _query;
var _name;
var _image;
var _position;
var _profile;
var _div;
var _month;

function loadXMLDoc(url, query, div, month)
{
	xmlhttp=null;
	_query=query;
	_name = new Array();
	_image = new Array();
	_position = new Array();
	_profile = new Array();
	_div = div;
	_month = month;
	
	if (window.XMLHttpRequest)
  	{// code for IE7, Firefox, Mozilla, etc.
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{// code for IE5, IE6
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}

	if (xmlhttp!=null)
  	{
  		xmlhttp.onreadystatechange=onResponse;
  		xmlhttp.open("GET",url,true);
  		xmlhttp.send(null);
  	}
	else
  	{
  		alert("Your browser does not support XMLHTTP.");
  	}
}

function onResponse()
{
	if(xmlhttp.readyState!=4) return;
	if(xmlhttp.status!=200)
	{
  		alert("Problem retrieving XML data");
  		return;
  	}

	y=xmlhttp.responseXML.documentElement.getElementsByTagName(_month.toUpperCase());	
	x=y[0].getElementsByTagName(_query);
	
	for(i=0; i<x.length; i++)
	{
		var name = (x[i].getElementsByTagName("NAME"))[0].firstChild.nodeValue;
		var image = (x[i].getElementsByTagName("IMAGE"))[0].firstChild.nodeValue;
		var position = (x[i].getElementsByTagName("POSITION"))[0].firstChild.nodeValue;
		var profile = (x[i].getElementsByTagName("PROFILE"))[0].firstChild.nodeValue;		
		
		_name[i] = name;
		_image[i] = image;
		_position[i] = position;
		_profile[i] = profile;
	}
	
	main_table();
}

function main_table()
{
	var titles = new Array(['Borromeo Seminarian'], ['Borromeo Faculty'], ['Borromeo Almunus']);
	var txt = '<table class="honors"><tr><td><table><tr>';
	
	for(i=0; i<3; i++)
	{
		txt = txt + "<td class='honorsdata'><center><strong>" + titles[i] + "</strong></center></td>";
	}
	
	txt = txt + "</tr><tr>";
	
    for(i=0; i<3; i++)
	{
		txt = txt + "<td class='honorsdata'><center><strong><img src='" + _image[i] + "' alt='" + _name[i] + " width='110' height='110' border='0' usemap='#MapMap2' longdesc='" + _image[i] + "'/></strong></center></td>";
	}
     
	txt = txt + "</tr><tr>";

	for(i=0; i<3; i++)
	{
		txt = txt + "<td class='honorstext'><center><strong>" + _name[i] + "</strong><br />" + _position[i] + "</center></td>";
	}
	
	txt = txt + "</tr><tr>";
	
	for(i=0; i<3; i++)
	{
		if(_profile[i] != "none")
		{
			txt = txt + "<td height='21'><center><span onclick=\"getProfile('" + i + "', '" + _div + "')\">View Profile</strong></center></td>";
		}
	}
     
	txt = txt + "</tr></table></td></tr></table>";
	document.getElementById(_div).innerHTML= txt;
}

function getProfile(record, div_target)
{
	var txt = "<table class='mos'>"
	{
		try
		{
			txt=txt + "<tr><td class='mosIcon'><img src='" + _image[record] + "' align='middle' alt='" + _name[record] + "' width='120' height='120' usemap='#Map2' longdesc='http://www.clevelandcatholicpriesthood/" + _image[record] + "'/><map name='Map2'><area shape='rect' coords='-44,-139,379,134'/></map></td>";
		}
		catch (er)
		{
			txt=txt + "<td> </td>";
		}
	}		
	{
		try
		{
			txt=txt + "<td class='mosText'><strong>" + _name[record] + "</strong><br />" + _position[record] + "<br />";
			txt=txt + "<td class='mosIcon'></td><td class='mosText'></td></tr>";
		}
		catch (er)
		{
				txt=txt + "<td> </td>";
		}
	}

	txt = txt + "<tr><td colspan='4'></td></tr><tr><td colspan='4'>" + _profile[record] + "</td></tr></table>";
	txt = txt + "<span onclick='main_table()'>Click to Return</span>"
	
	document.getElementById(div_target).innerHTML = txt;
}