/********************************************************************************
	This script is copyrighted by Orange Street Softare
		www.orangestreetsoftware.com
	
********************************************************************************/

// ============================================ THE CONTAINER OBJECT ============================================

function quik_link_container ( item_urls, item_frames, item_frame_parms, item_names, allow_render_caching )
{      

	// set the object properties...
	this.item_urls = item_urls;							// an array of urls for each item in the top bar, same length as item_frames, item_frame_parms, item_names
	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_names = item_names;						// an array of frames names to use as target when items are clicked
	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_frames.length)
		this.item_count = this.item_frames.length;
	if (this.item_count > this.item_frame_parms.length)
		this.item_count = this.item_frame_parms.length;
	if (this.item_count > this.item_names.length)
		this.item_count = this.item_names.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 top bar run see: top_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: top_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;


	// --------------------------------------------------------------------------------------------------------
}

