var lastID = "";

function makeRequest(item, type){
	var div = document.getElementById(type);
		
	var handleSuccess = function(o){
		if(o.responseText !== undefined){
			
			div.innerHTML = o.responseText;
		}
	};
	
	var handleFailure = function(o){
			div.innerHTML = "FAILURE";
	};
	
	var callback =
	{
	  success:handleSuccess,
	  failure:handleFailure,
	  argument:['foo','bar']
	};

	//if it's not the first selection, set the previous selection back to the un-selected color
	if (lastID != "") {
		var lastDiv = document.getElementById(lastID);
		lastDiv.style.color = '#B17327';
		lastDiv.style.cursor = 'pointer';
	}
	
	if (type == 'people') {
		var sUrl = "http://cocat.ischool.berkeley.edu/index.php/peopleAJAX";
		var postData = "person="+item;
		if (item != 'showAll'){
			var activeDiv = document.getElementById('pid'+item);
			lastID = 'pid'+item;
		} else {
			var activeDiv = document.getElementById('showAll');
			lastID = 'showAll';
		}
		
	}
	if (type == 'research') {
		var sUrl = "http://cocat.ischool.berkeley.edu/index.php/researchAJAX";
		var postData = "research="+item;
		if (item != 'showAll'){
			var activeDiv = document.getElementById('kid'+item);
			lastID = 'kid'+item;
		} else {
			var activeDiv = document.getElementById('showAll');
			lastID = 'showAll';
		}
		
	}
	//reset the last div to the original color
	
	
	//set the active div to the selected color and remove the pointer
	activeDiv.style.color = '#899647';
	activeDiv.style.cursor = 'default';
	
	var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
}

var showList = function() { 
	   var div = document.getElementById('items');
	   div.style.visibility = "visible";
}

var hideList = function() { 
	   var div = document.getElementById('items');
	   div.style.visibility = "hidden";
}  
