/**
 * (constructor) The FlashBanner object is a convenience object for 
 * generating the HTML necessary to render a flash banner with the 
 * appropriate parameters (FlashVars) needed to cycle images and
 * captions dynamically.
 *
 * This constructor takes a banner duration argument, which represents
 * the number of seconds a banner is displayed before switching to the
 * next banner.
 *
 * See the addBanner function
 */
function FlashBanner(bannerDurationInSeconds_)
{
	this.images = new Array();
	this.text = new Array(); 
	this.params = new Array();
	this.waitFrames = isNaN(bannerDurationInSeconds_) ? 100 : Math.round(bannerDurationInSeconds_ * 20);
}

/**
 * Function for adding a banner, consisting of an image and a caption,
 * to the list of banners that will by cycled when the Flash banner
 * is rendered.
 */
FlashBanner.prototype.addBanner = function(imgUrl, textLine1, textLine2, textLine3)
{
	this.images[this.images.length] = imgUrl;
	this.text[this.text.length] = textLine1+":"+textLine2+":"+textLine3; 	
}

/**
 * Generates the HTML needed to render an embedded Flash player with 
 * the necessary parameters (FlashVars) for displaying the banners added
 * by calling the addBanner function.
 */
FlashBanner.prototype.generateHTML = function()
{
	var html = "";
	var flashVars =  "waitFrames=" + this.waitFrames + "&";
	
	for(i=0; i<this.images.length; i++)
	{
		num = i+1;
		flashVars += "img" + num + "=" + this.images[i] + "&" + "text" + num + "=" + this.text[i] + "&";
	}
	
	html += "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"  ";
	html += "codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\"  ";
	html += "width=\"450\" height=\"197\" id=\"ree_banner\" align=\"right\"> ";
	html += "<param name=\"allowScriptAccess\" value=\"sameDomain\" /> ";
	html += "<param name=\"movie\" value=\"/flash/ree_banner.swf\" /> ";
	html += "<param name=\"quality\" value=\"high\" /> ";
	html += "<param name=\"bgcolor\" value=\"#ffffff\" /> ";
	html += "<param name=\"wmode\" value=\"transparent\" /> ";
	html += "<param name=\"FlashVars\" value=\"" + flashVars + "\" /> ";
	html += "<embed src=\"/flash/ree_banner.swf\" quality=\"high\" bgcolor=\"#ffffff\"  ";
	html += "width=\"450\" height=\"197\" name=\"ree_banner\"  ";
	html += "align=\"right\" allowScriptAccess=\"sameDomain\"  ";
	html += "type=\"application/x-shockwave-flash\"  ";
	html += "wmode=\"transparent\"  ";
	html += "FlashVars=\"" + flashVars + "\"  ";
	html += "pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /> ";
	html += "</object> ";
		
	return html;
}

/**
 * Writes the HTML created by the generateHTML function to the document.  
 */
FlashBanner.prototype.writeHTML = function()
{
	document.write(this.generateHTML());
}