/**
 * Work around for Microsoft's security "feature" that prevents the flash player activeX
 * control from working until the user accepts a message.  
 * 
 * See: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/activating_activex.asp
 */
function writeSwf(swfUrl, width, height, flashVars)
{
	// set proto to existing protocol variable, or "http" if protocol is 
	// not set.  it is assumed the protocol variable is set outside the 
	// scope of this script file.
	var proto = protocol ? protocol : "http";
	
	var flashVarsString = "";
	
	// build query string from array provided
	if(flashVars)
	{
		for(i=0; i<flashVars.length; i++)
		{
			flashVarsString += flashVars[i] + "&";
		}
	}	
	
	document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' ");
	document.write("codebase='" + proto + "://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'  ");
	document.write("width='" + width + "'  ");
	document.write("height='" + height + "'  ");
	document.write("align='middle'> ");
	document.write("<param name='allowScriptAccess' value='always' /> ");
	document.write("<param name='movie' value='" + swfUrl + "' /> ");
	document.write("<param name='quality' value='high' /> ");
	document.write("<param name='scale' value='noscale' /> ");
	document.write("<param name='salign' value='lt' /> ");
	document.write("<param name='bgcolor' value='#ffffff' /> ");
	document.write("<param name='FlashVars' value='" + flashVarsString + "' />");
	document.write("<embed src='" + swfUrl + "'  ");
	document.write("	quality='high'  ");
	document.write("	scale='noscale'  ");
	document.write("	salign='lt'  ");
	document.write("	bgcolor='#ffffff'  ");
	document.write("	width='" + width + "'  ");
	document.write("	height='" + height + "'  ");
	document.write("	align='middle'  ");
	document.write("	allowScriptAccess='always'  ");
	document.write("	type='application/x-shockwave-flash'  ");
	document.write("	pluginspage='" + proto + "://www.macromedia.com/go/getflashplayer'  ");
	document.write("	flashVars='" + flashVarsString + "'/>");
	document.write("</object> ");
}

/**
 *	Writes a flash "rotator" billboard  using the array of images provided
 */
function writeBillboard(rotateImages)
{
	var imgs = createRotateImagesString(rotateImages);
	writeBillboardQS(imgs);
}

/**
 *	Writes a flash "rotator" billboard  using the array of images provided
 */
function writeBillboardQS(rotateImagesQueryString)
{
	var burl = baseUrl ? baseUrl : "";
	var flashVars = new Array(rotateImagesQueryString, "duration=120", "baseUrl=" + burl);
	writeSwf("/image_rotator.swf?v=1", 750, 300, flashVars);
}




function createRotateImagesString(rotateImages)
{
	var s = "";
	if(rotateImages)
	{
		if(rotateImages.length)
		{
			for(i=0; i<rotateImages.length; i++)
			{
				s += "img" + (i+1) + "=" + rotateImages[i] + "&";
			}
		}
		else
		{
			s = "" + rotateImages;
		}
	}
	return s;
}