// Title:     Extract Blockquote Info - http://1976design.com/blog/archive/2003/11/10/updates/
// Author:    Dunstan Orchard
// Updated:   June 07

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')) )
              {
                newlink = document.createElement('a');
                newlink.setAttribute('href', cite);
                title = quotes[i].getAttribute('title');
                if ((title) && (title != ''))
                  {newlink.appendChild(document.createTextNode(title));}
                else
                  {newlink.appendChild(document.createTextNode(cite));}
                newp = document.createElement('p');
                newp.className = 'source';
                newp.appendChild(document.createTextNode('\u2014 '));
		newcite = document.createElement('cite');
                newp.appendChild(newcite);
                newcite.appendChild(newlink);
                quotes[i].appendChild(newp);
              }
            else
              {
                newp = document.createElement('p');
                newp.className = 'source';
                newp.appendChild(document.createTextNode('\u2014 '));
                newcite = document.createElement('cite');
                newp.appendChild(newcite);
                newcite.appendChild(document.createTextNode(cite));
                quotes[i].appendChild(newp);
              }
          }
        else if ((title) && (title != ''))
          {
            newp = document.createElement('p');
            newp.className = 'source';
            newp.appendChild(document.createTextNode('\u2014 '));
            newcite = document.createElement('cite');
            newp.appendChild(newcite);
            newcite.appendChild(document.createTextNode(title));
            quotes[i].appendChild(newp);
          }
       }
    }
  window.onload = function(e) {extractBlockquoteInfo();}