/* ThinkQuest International 2006/2007
   TQ Toolkit - A web building guide for ThinkQuesters (C)
   Your TQ Guides (R)
   Visit http://library.thinkquest.org/06aug/02048/

*/
/* 
   Tribute to DOM Scripting: Web Design with JavaScript and the Document Object Model
   Publisher: Friends of ED 
*/

function displayCitations() {
  if (document.getElementsByTagName && document.createElement && document.createTextNode) {
  	//get all blockquotes
  	var quotes=document.getElementsByTagName("blockquote");
  	//loop thru blockquotes

  	for (var i=0; i<quotes.length; i++)
  	{
	if (quotes[i].getAttribute("cite") == null)
		continue;
	//store cite attribute
	var url=quotes[i].getAttribute("cite");
	var name = quotes[i].getAttribute("title");
	//get all element nodes in blockquote
	var quoteChildren=quotes[i].getElementsByTagName("p");
	if (quoteChildren.length < 1)
		continue;
	//get last element node in blockquote
	var elem=quoteChildren[quoteChildren.length-1];
	//create markup
	var hlink = document.createElement("a");
	var link_text = document.createTextNode(" " + name);
	hlink.appendChild(link_text);
	hlink.setAttribute("href", url);
	hlink.setAttribute("rel","external");
	hlink.setAttribute("class","external");
	hlink.setAttribute("className","external");
	var superscript = document.createElement("sup");
	superscript.appendChild(hlink);
	//add to last element in blockquote
	elem.appendChild(superscript);
	}
  }
}
