<!--

var DEFAULT_IMAGE_WIDTH = 260;
var DEFAULT_IMAGE_HEIGHT = 160;

function toHtml() {
   if(this.type == "image") {
      return "<a href='"+this.link+"'><img src='"+this.src+"' width='"+this.width+"' height='"+this.height+"' alt='"+this.alt+"' border='0'></a><br>"; 
   } else if(this.type == "flash") {
      // note that this next line assumes that flash_detect.js has been loaded
      return getFlashObjectTag( this.src, this.width, this.height, this.loop, this.alt );
   } else if(this.type == "fragment") {
      return this.src;
   } else {
      return "<!-- Unrecognized type for MediaObject: "+ this.type +" -->";
   }
}

function setLink(link) {
    this.link = link;
}

function setAlt(alt) {
    this.alt = alt;
}

function setSize(width, height) {
    this.width = width;
    this.height = height;
}

function MediaObject(type, src) {

    this.type = type; 
    this.src = src;
    this.alt = "";
    this.link = "";
    this.width = DEFAULT_IMAGE_WIDTH;
    this.height = DEFAULT_IMAGE_HEIGHT;
    this.loop = false;
    this.setAlt = setAlt; 
    this.setLink = setLink; 
    this.setSize = setSize; 
    this.toHtml = toHtml; 
}

function addImage(src, link, alt) {
    var mo = new MediaObject("image", src, alt);
    mo.setAlt(alt);
    mo.setLink(link);
    mo.setSize( this.imageWidth, this.imageHeight );
    this.objects[this.objects.length] = mo;
	this.images[this.images.length] = mo;
}

function addFlash(src, width, height, loop, alt) {
    var mo = new MediaObject("flash", src);
    mo.setAlt(alt);
    mo.setSize(width, height);
    this.loop = loop;
    this.objects[this.objects.length] = mo;
}

function addHTMLFragment(fragment) {
    var mo = new MediaObject("fragment", fragment);
    this.objects[this.objects.length] = mo;
}

function getRandomObject() {
    if(this.objects.length == 0) return null;
    var rand = Math.round((this.objects.length - 1) * Math.random());
    return this.objects[rand];
}

function getRandomImage() {
    if(this.images.length == 0) return null;
    var rand = Math.round((this.images.length - 1) * Math.random());
    return this.images[rand];
}

function setImageSize(width, height) {
    this.imageWidth = width;
    this.imageHeight = height;
}

function MediaPool() {
    this.objects = new Array();
    this.images = new Array();
    this.addImage = addImage;
    this.addFlash = addFlash;
    this.addHTMLFragment = addHTMLFragment;
    this.getRandomObject = getRandomObject;
    this.getRandomImage = getRandomImage;

    this.imageWidth = DEFAULT_IMAGE_WIDTH;
    this.imageHeight = DEFAULT_IMAGE_HEIGHT;
    this.setImageSize = setImageSize;
}

// -->

