// JavaScript Document

function showBio(tag)
{
 	tag.setAttribute("title", "");
	if (Element.next(tag) == null  || Element.next(tag).className != 'bio')
	{

	var thisHref = tag.getAttribute("href");
	//convert regular link to boi to the equiv with .xml
	
	if (!(thisHref.length > 0)) { return; }	  
	
	 thisHref = thisHref.substring(0, (thisHref.length - 5)) + "_tn.html?_="+ new  Date().getTime();
	var newBio = new Insertion.After(tag, "<span class=\"bio\" style=\"position: relative\"><div class=\"bioPopUp\" style=\"display:none;\">Loading</div></span>");
	new Ajax.Request(thisHref, {
  	method: 'get',
  	onSuccess: function(transport) {
        //alert(Element.next(tag,"span[class=bio]").firstChild.innerHTML); // this works!
	try {Element.next(tag, "span[class=bio]").firstChild.update(transport.responseText);
	      }
	    catch (e) {
	           // IE fails unless we wrap the string in another element.
	         var wrappingElement = document.createElement('div');
		var temphtml = transport.responseText.replace(/<div>/,'');
		wrappingElement.innerHTML=temphtml.replace(/<\/div>/,'');
		
		Element.next(tag,"span[class=bio]").firstChild.appendChild(wrappingElement);
		Element.next(tag,"span[class=bio]").firstChild.removeChild(Element.next(tag,"span[class=bio]").firstChild.childNodes[0]);
	   }        
  	},
	onFailure: function(transport) {
	Element.next(tag, "span[class=bio]").firstChild.innerHTML = "Error loading text.";
	}

  
});  

	}

	
	var bioElem = Element.next(tag, "span[class=bio]").firstChild;
	if (bioElem.style.display == 'none') {
		Effect.toggle(bioElem, 'blind', {duration: .2});
	} else 
	{
		Effect.toggle(bioElem, 'appear', {duration: .2});
		tag.setAttribute("title", "Show biography");
	}

}


function hideBio(tag)
{
	//var givenBio = Element.next(tag, "span[class=bio]");
	if (tag != null && tag.firstChild.visible())
	Effect.toggle(tag.firstChild, 'appear', {duration: .3});
	
}


