
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Dunstan Orchard | http://1976design.com/ */
// Altered from original idea by Simon Willison at:
// http://simon.incutio.com/archive/2002/12/20/blockquoteCitations

function extractBlockquoteInfo() {
 	quotes = document.getElementsByTagName('blockquote');
 	for (i = 0; i < quotes.length; i++) {
  		cite = quotes[i].getAttribute('cite');
  		title = quotes[i].getAttribute('title');
  		if ((cite) && (cite != '')) {
   			if ( (cite.match('http://', 'i')) || (cite.match('ftp://', 'i')) || (cite.match('person://', 'i')) ) {
   				newlink = document.createElement('a');
   				newlink.setAttribute('href', cite);
   				newlink.setAttribute('title', ('Go to ' + cite));
   				title = quotes[i].getAttribute('title');
   				if ((title) && (title != '')) {
    					newlink.appendChild(document.createTextNode(title));
   				} else {
   	 				newlink.appendChild(document.createTextNode('Quoted source'));
   				}
   				newdiv = document.createElement('div');
   				newdiv.className = 'source';
   				newdiv.appendChild(document.createTextNode('\u2014 '));
   				newdiv.appendChild(newlink);
   				quotes[i].appendChild(newdiv);
  			} else {
   				newdiv = document.createElement('div');
   				newdiv.className = 'source';
   				newdiv.appendChild(document.createTextNode('\u2014 ' + cite));
   				quotes[i].appendChild(newdiv);
  			}
  		} else if ((title) && (title != '')) {
   			newdiv = document.createElement('div');
   			newdiv.className = 'source';
   			newdiv.appendChild(document.createTextNode('\u2014 ' + title));
   			quotes[i].appendChild(newdiv);
  		}
 	}
}

// Multiple onload function created by: Simon Willison
// http://simon.incutio.com/archive/2004/05/26/addLoadEvent
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(function(e) {
extractBlockquoteInfo();
});
