//Tribute to DOM Scripting: Web Design with JavaScript and the Document Object Model
//Publisher: Friends of ED 
/* ThinkQuest International 2006
	The DReaMers - DRM: Two Sides of the Story
	displayCitations.js
	--------------------------------------------
	Copyright: You may use this script for non-commercial purposes,
	but must acknowledge the team.
	--------------------------------------------
	Last Revised: 04/01/06
*/

function displayCitations()
//Use: <blockquote cite="url">...</blockquote>
{
  if (!document.getElementsByTagName || !document.createElement || !document.createTextNode)
  return false;
  //get all blockquotes
  var quotes=document.getElementsByTagName("blockquote");
  //loop thru blockquotes

  for (var i=0; i<quotes.length; i++)
  {
	if (!quotes[i].getAttribute("cite"))
	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('*');
	if (quoteChildren.length < 1)
	continue;
	//get last element node in blockquote
	var elem=quoteChildren[quoteChildren.length-1];
	//create markup
	var link = document.createElement("a");
	var link_text = document.createTextNode(" " + name);
	link.appendChild(link_text);
	link.setAttribute("href","javascript:window.open('" + url + "'); imagePreload();");
	//link.setAttribute("target","_blank");
	link.setAttribute("class","quoteSource");
	link.setAttribute("className","quoteSource");
	//add to last element in blockquote
	elem.appendChild(link);
	}
}