var pathname1 = document.location.pathname;
var pathname2 = pathname1.substring(pathname1.indexOf("/")+1,pathname1.length);
var ctxPath = "/" + pathname2.substring(0,pathname2.indexOf("/"));

function addToLib(image, id) {
	var url = ctxPath + "/addCitationToLib/" +id + ".html";
	var req = newXMLHttpRequest();
	req.onreadystatechange = getReadyStateHandlerForText(req, showSectionPopup);
	req.open("POST", url, true);
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	req.send("");
    image.className="removeref-library";
 	image.title = "Remove this citation from My Library";
	image.onclick = function(){removeFromLib(this,'" + id + "'); return false;};
 	 
}

function removeFromLib(image, id) {
	var url = ctxPath + "/removeCitationFromLib/" +id + ".html";
	var req = newXMLHttpRequest();
	req.onreadystatechange = getReadyStateHandlerForText(req, updateContents);
	req.open("POST", url, true);
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	req.send("");
    image.className="addref-library";
	image.title = "Add this citation to My Library";
	image.onclick = function(){addToLib(this,'" + id + "');return false;};
}

function updateContents(){
	return true;
}