var slides = [];
slides.parse = function(slidesSpec) {
  _(trim(slidesSpec).split(/\n\n+/)).each(function(spec) {
    slides.push(new Slide(spec));
  });
};

function Slide(spec) {
  spec = $.trim(spec);

  spec = spec.replace(/^<\/.*?\>/, "");  // Strip silly closing tags
  log("ispec=="+spec+"===");

  this.explicitHTML = null;
  if ((/^\<[\s\S]+\>$/).test(spec)) {
    this.explicitHTML = spec;
    return;
  }

  spec = spec.replace(/^[ \n\t]*<p>[ \n\t]*/, ""); // allow (ie ignore) optional <p> to separate slides

  var lines = spec.split(/\n/).map(function(line) { return $.trim(line); });
  var imageParts = lines[lines.length-1].split(/ +/);
  var suffix = imageParts[0].replace(/^.*\.([a-zA-Z]+)$/, "$1").toLowerCase();
  this.image = null;
  if (["jpg","jpeg","gif","png"].indexOf(suffix) != -1) {
    this.image = imageParts[0];
    this.imageAttribution = imageParts[imageParts.length-1];
  }

  this.labels = _(lines).clone();
  if (this.image) this.labels.splice(this.labels.length-1);

  return this;
}

