function Blurb(what, who, where, when) {
  this.what = what;
  this.who = who;
  this.where = where;
  this.when = when;
}

Blurb.prototype.toString = function() {
  this.string = '<div id="SPA_Epigram" class="blurb">\n<div class="ldquo"><img src="images/ldquo" alt="&ldquo;"></div>\n<blockquote><div class="quote">'+this.what
    +'</div>\n<div class="rdquo ieOnly"><img src="images/rdquo" alt="&rdquo;"></div>\n</blockquote>\n<cite class="blurb">&mdash;'
  +(this.who ? '<span class="name">'+this.who +'</span>':'')
  +(this.who && this.where ? ', ':'')
  +(this.where ? '<span class="journal">'+this.where+'</span>':'')
  +'</cite>\n</div><!-- #SPA_Epigram -->';
  this.toString = function () {return this.string;};
  return this.string;
};

Blurb.prototype.toNode = function () {
  var node;
  this.node = document.createElement('div');
  this.node.id = "SPA_Epigram";
  this.node.className="blurb";

  this.node.appendChild(node=document.createElement('div'));
  node.className="ldquo";
  node.appendChild(document.createElement('img'));
  node.lastChild.src="images/ldquo";
  node.lastChild.alt="&ldquo;";

  this.node.appendChild(node = document.createElement('blockquote'));
  node.appendChild(document.createElement('div'));
  node.lastChild.className='quote';
  node.lastChild.appendChild(document.createTextNode(this.what));
  node.appendChild(document.createElement('div'));
  node.lastChild.className='rdquo ieOnly';
  node.lastChild.appendChild(document.createElement('img'));
  node.lastChild.lastChild.src="images/rdquo";
  node.lastChild.lastChild.alt="&rdquo;";
  this.node.appendChild(node = document.createElement('cite'));
  node.className="blurb";
  node.appendChild(document.createTextNode('&mdash;'));
  if (this.who) {
	node.appendChild(document.createElement('span'));
	node.lastChild.className="name";
	node.lastChild.appendChild(document.createTextNode(this.who));
  }
  if (this.who && this.where) {
	node.appendChild(document.createTextNode(', '));
  }
  if (this.where) {
	node.appendChild(document.createElement('span'));
	node.lastChild.className="journal";
	node.lastChild.appendChild(document.createTextNode(this.where));
  }
  

  this.toNode = function () {return this.node;};
  return this.node;
};

var blurbs = [
  new Blurb("There&#8217;s something to be said about the diligent eagerness of a developing troupe such as that at Lane Community College.",
			"Kori Irons", "Eugene Weekly"),
  new Blurb('Like young pals in a 1930s movie, the students at LCC have decided to take things in their own hands and put on a show.', '', 'Register Guard'),
  new Blurb("Lane's Student Productions Association has stepped up to find new ways to keep the (Theatre Arts) program alive.", '', 'Register Guard')
];

function randBlurb() {
  return blurbs[Math.floor(Math.random() * blurbs.length)];
}

function writeBlurb() {
  var blurb = randBlurb();
  document.write(blurb.toString());
}

function appendBlurb(parent) {
  if (parent.appendChild) {
	var blurb = randBlurb();
	parent.appendChild(blurb.toNode());
  } else {
	writeBlurb();
  }
}

