	// A list of creatives to render.
	var creatives = new Array();

	// The ad global data.
	ad_area		= "GEN";
	ad_keyword	= "";

	// This function loads a creative.
	function loadCreative (id, type, pos, keyword)
		{	// Add the creative.
			creatives					= new Array();
			creatives[creatives.length]	= { type: type, pos: pos };

			// Now get it from the server.
			getCreatives(id, keyword);
		}; // function displayCreative (type, pos)

	// This function loads all the creatives.
	function loadCreatives ()
		{	// Get the number of creatives.
			var num_creatives = creatives ? creatives.length : 0;

			// Load each creative.
			for ( var index = 0; index < num_creatives; index++ )
				{	// Get the div that should contain the creative.
					var container = document.getElementById("INV" + (index + 1));

					// Load the creative since we have something to work with.
					if ( container )
						{	// Get the creative's values.
							var creative	= creatives[index];
							var id			= creative.id;
							var type		= creative.type;
							var pos			= creative.pos;
							var width		= creative.width;
							var height		= creative.height;
							var keyword		= creative.keyword;

							// Construct the creative URL.
							var url = '/display_creative.html?id=' + ad_area + '&type=' + type + '&pos=' + pos + '&keyword=' + escape(keyword);

							// Set the container's inner HTML.
							container.innerHTML = '<iframe src="' + url + '" frameborder="no" scrolling="no" width="' + width + '" height="' + height + '" style="margin: 0 auto;"></iframe>';
						}; // if ( container )
				}; // for ( var index = 0; index < num_creatives; index++ )
		}; // function displayCreative (type, pos)

	// This function retrieves the creative data from the bserver.
	function getCreatives (id, keyword)
		{	// Cache-busting and pageid value.
			var aamRnd = Math.round(Math.random() * 10000000000);						

			// Data to append on all creatives.
			creative_global_data = "/site=MW/area=" + id + "/keyword=" + keyword;

			// Adserver URL.
			adserver = "http://eb.adbureau.net/bserver";

			// Ad tag targeting values which will be appended to each ad request section in the bserver ad call.
			allAdTags = "/AAMALL" + creative_global_data + "/acc_random="  + aamRnd + "/pageid=" + aamRnd;
		
			// Get the number of creatives.
			var num_creatives = creatives ? creatives.length : 0;

			// The bserver call.
			var url = adserver + allAdTags;

			// Construct the bserver call.
			for ( var index = 0; index < num_creatives; index++ )
				{	// Get the next creative.
					var creative = creatives[index];

					// Get its values.
					var var_name	= "AAMB" + (index + 1);
					var type		= "aamsz=" + creatives[index].type;
					var pos			= "pos=" + creatives[index].pos;

					// Add the creative to the url.
					url += "/" + var_name + "/" + type + "/" + pos;

					// Setup the variable for the creative.
					eval("AAMB" + (index + 1) + "='';");
				}; // for ( var index = 0; index < num_creatives; index++ )

			// Make the bserver call.
			document.write('<scr' + 'ipt text="text/javascript" src="' + url + '?"></scri' + 'pt>');					
		}; // function getCreatives ()

	// This function displays the creatives.
	function displayCreatives ()
		{	// Get the number of creatives.
			var num_creatives = creatives ? creatives.length : 0;
		
			// Now render each creative's div.
			for ( var index = 0; index < num_creatives; index++ )
				{	var invDiv	= 'INV' + ( index + 1 );								
					document.write('<div id="' + invDiv + '">' + eval("AAMB" + (index + 1)) + '</div>');					
				}; // for ( var index = 0; index < num_creatives; index++ )
		}; // function displayCreatives ()

	// This function places a creative on the webpage.
	function placeCreative (id, type, pos, keyword)
		{	// An hash of width's and heights.
			var dims				= new Array();
			dims["BANNER.tb"]		= new Array(728, 90);
			dims["BANNER.bb"]		= new Array(728, 90);
			dims["300x250.rec1"]	= new Array(300, 250);
			dims["300x250.rec"]		= new Array(300, 250);
			
			// Set the dimensions.
			var width	= ( dims[type + "." + pos] ) ? dims[type + "." + pos][0] : 100;
			var height	= ( dims[type + "." + pos] ) ? dims[type + "." + pos][1] : 100;
			
			// Add the creative info to be loaded later.
			creatives[creatives.length] = { id: id, type: type, pos: pos, width: width, height: height, keyword: keyword };
			
			// Output the containing element.
			document.write('<div id="INV' + creatives.length + '" style="height: ' + height + 'px; width: ' + width + 'px; margin: 0 auto;"></div>');
		}; // function placeCreative (id, type, pos, keyword)

	// This function sets the data to appended to all the creatives.
	function setGlobalCreativeData (area, keyword)
		{	ad_area		= area;
			ad_keyword	= keyword;
		}; // function setGlobalCreativeData (area, keyword)
