/********************************************************************************
	This script is copyrighted by Orange Street Softare
		www.orangestreetsoftware.com
	
********************************************************************************/

// ============================================ THE CONTAINER OBJECT ============================================

function right_bar_container ( banner_image_url, item_urls, item_frames, item_frame_parms, item_image_urls, allow_render_caching )
{
	// set the object properties...
	this.banner_image_url = banner_image_url;			// the banner image for the right bar 
	this.item_urls = item_urls;							// an array of urls for each each link
	this.item_frames = item_frames;						// an array of frames names to use as target when items are clicked, same length as item_urls
	this.item_frame_parms = item_frame_parms;			// an array of javascript paramters to use for each frame, empty for those that are not popups, same length as item_urls
	this.item_image_urls = item_image_urls;				// an array of image urls for each each link
	this.allow_render_caching = allow_render_caching;	// a flag to indicate whether render caching is enabled

	// check the item arrays are the same size and store the mimumum size,
	// this is to prevent array overflows
	this.item_count = this.item_urls.length;
	if (this.item_count > this.item_image_urls.length)
		this.item_count = this.item_image_urls.length;

	// if there was inconsistancy, show warning!
	if (this.item_count != this.item_urls.length)
		alert ( "Set-up data inconsistant!" );

	// set up caching variables 
	//   caches the result of a right bar run see: right_bar_run.js
	//   these variables are not dealt with by this object 
	//   but are provided here so as to be global accross all web pages
	//   the rendering implementation can use them as it sees fit (see: right_bar_run.js)
	this.render_cache = "";
	this.is_cached = false;

	// --------------------------------------------------------------------------------------------------------
	// this is called when an item is clicked, the index of the item must be passed in
	function item_click ( index )
	{
		// ensure that index in valid range
		if ((index < 0) || (index >= this.item_count))
		{
			alert ( "Bad index used in item click: " + index.toString() );
			return;
		}

		// if the item points to a page, open it
		if ( this.item_urls[index] != '' )
		{
			// if popup parms are supplied, open in popup window, else open in frame
			if ( this.item_frame_parms[index] != '' )
				window.open ( this.item_urls[index], this.item_frames[index], this.item_frame_parms[index] );
			else
				window.open ( this.item_urls[index], this.item_frames[index] );
		}
	}
	this.item_click = item_click;

	// --------------------------------------------------------------------------------------------------------
}

