var currentID = 0;
function ajaxFunction()
{
	var xmlHttp;
	xmlHttp = ajaxStart();
	xmlHttp.onreadystatechange=function()
    {
		if(xmlHttp.readyState==4)
		{ 
			var result = xmlHttp.responseText;
			var count = result.substring(0,result.indexOf('+'));
			var singleID = result.substring(result.indexOf('+')+1,result.indexOf('^'));
			
			result = result.substring(result.indexOf('^')+1);
			//alert(result);
			document.getElementById('divShow').innerHTML = result;
			if(count == 1 && currentID != singleID){ getCard(singleID); currentID = singleID;}
		}
	}
	xmlHttp.open("GET",'http://www.macu.edu/directory/AJAX/directory_search.php?searchtext=' + document.getElementById('name').value,true);
	xmlHttp.send(null);
}
  
function getCard(userid)
{
	document.getElementById('contact_information').innerHTML = '<div align="center" style="height:300px; vertical-align:middle;"><img style="border:0px; margin:0px;" src="http://www.macu.edu/directory/images/loading.gif"></div>';
	var xmlHttp;
	xmlHttp = ajaxStart();
	xmlHttp.onreadystatechange=function()
    {
		if(xmlHttp.readyState==4)
		{ document.getElementById('contact_information').innerHTML = xmlHttp.responseText; }
	}
	xmlHttp.open("GET",'http://www.macu.edu/directory/AJAX/show_card.php?userid=' + userid,true);
	xmlHttp.send(null);
}

function openFullList()
{
	window.open ("http://www.macu.edu/directory/full_list.php","mywindow","status=0,toolbar=0,menubar=0,location=0,resizable=0,height=710,width=800,scrollbars=1");
}
function setUpInput(inputElement)
{
	inputElement.style.color = '#000000';
	if(inputElement.value == 'Type Search Here')
	{
		inputElement.value = '';
	}
}
function resetInput(inputElement)
{
	inputElement.style.color = '#999999';
	inputElement.value = 'Type Search Here';
}