/*
* blockquotes.js
*
* Simon Willison, 20th December 2002
* Modified by Erik Johansson, 2nd February 2006
*
* Explanation:
*   http://simon.incutio.com/archive/2002/12/20/#blockquoteCitations
* Inspired by Adrian Holovaty:
*   http://www.holovaty.com/blog/archive/2002/12/20/0454
* Alternative implementation of the same idea by Paul Hammond:
*   http://www.paranoidfish.org/boxes/2002/12/20/
*/

function extractBlockquoteCitations() {
	quotes = document.getElementsByTagName('blockquote');
	for (i = 0; i < quotes.length; i++) {
		cite = quotes[i].getAttribute('cite');
		if (cite != null && cite != '') {
			newlink = document.createElement('a');
			newlink.setAttribute('href', cite);
			newlink.setAttribute('title', cite);
			if (quotes[i].getAttribute('title') != '') {
				newlink.appendChild(document.createTextNode("-- " + quotes[i].getAttribute('title')));
			}
			else {
				newlink.appendChild(document.createTextNode('-- Source'));
			}
			newp = document.createElement('p');
			newp.className = 'blockquotesource';
			newp.appendChild(newlink);
			quotes[i].appendChild(newp);
		}
	}
}

if (window.addEventListener) // W3C standard
{
  window.addEventListener('load', extractBlockquoteCitations, false);
} 
else if (window.attachEvent) // Microsoft
{
  window.attachEvent('onload', extractBlockquoteCitations);
}