


/**
 *	Abstract Class InfoTipList
 *	==========================
 *
 * 	A class representing a list of customized tooltips whose definitions will 
 *	display upon a mouseover or click event, and hide upon a mouseout event.
 *
 *	Class (Static) Fields:
 *	----------------------
 *			(none)
 *
 *	
 *	Instance Fields:
 *	----------------
 *
 *			Object terms - contains the InfoTip Objects, keyed on the name of the term
 *
 *
 */
function InfoTipList() {
	return this;
}



//
// Class (Static) Methods
//

/**
 *	static void create_list()
 *
 *	Instantiates an InfoTipList Object and sets it as a static property of the
 *	InfoTip class.
 *
 */
InfoTipList.create_list = function() {

 	var infotip_list = new InfoTipList();
 	
 	// Info Help Context tooltip definitions
 	infotip_list.add_term(InfoTip.TOOLTIP_TERM,'Click for context info.',InfoTip.TOOLTIP_KEY);
	infotip_list.init();
	
	// hack: need a reference to this list...
	InfoTip.list = infotip_list;
}







/**
 *	abstract void init 
 *
 *	A method that must be written by the integration code. This function must
 *	contain  a series of calls to the 'add_term()' method. This must be done
 *	this way due to the need to load the browser before initializing the objects.
 *	Otherwise there's no InfoTips.
 *
 *	Example:
 *	--------
 *
 *	InfoTipList.prototype.init = function() {
 *	
 *		this.add_term('Tent','A tent.');
 *		this.add_term('Dorm','Room with mattresses only, and a number of people. Bathroom is shared.');
 *		this.add_term('Shared','Hotel style room with up to 5 people.');
 *		this.add_term('Single','Hotel style room with you alone.');
 *		this.add_term('Double','Hotel style room shared with another person.');
 *	}
 *	
 */
InfoTipList.prototype.init = function() {}


// a hash of InfoTip Objects, the term is the key.
InfoTipList.prototype.terms = new Object();



/**
 *	public void add_term ( String term, String definition )
 *
 * 	Instantiates a new InfoTip Object if the term doesn't already exist, and
 *	places it into the terms list, using the term as the key for lookups.
 *
 *	@param String term - the word to add a definition for
 *	@param String definition - the definition for the term being added
 *
 */
//InfoTipList.prototype.add_term = function ( term, definition ) {
InfoTipList.prototype.add_term = function ( term, definition, key ) {
	//if ( this.terms[term] == null ) {
	if ( this.terms[key] == null ) {
		this.terms[key] = new InfoTip( term, unescape(definition), key);
	}
}



/**
 *	public InfoTip get_infotip ( String term )
 *
 * 	If the term exists in the list, the corresponding InfoTip Object for
 *	that term will be retrieved. Null is returned otherwise.
 *
 *	@param String term - the term to lookup in the list
 *	@return an InfoTip Object
 *
 */
//InfoTipList.prototype.get_infotip = function ( term ) {
InfoTipList.prototype.get_infotip = function ( key ) {
	var infotip = null;
	//if ( this.terms[term] != null ) {
		//infotip = this.terms[term];
	if ( this.terms[key] != null ) {
		infotip = this.terms[key];
	}
	
	return infotip;
}





/**
 *	public String get_definition( String term )
 *
 *	Looks up the term in the list and returns the definition for that term
 * 	from its corresponding InfoTip Object.
 *
 *	@param String term - the word to lookup in the list, and retrieve the definition for
 *	@return String - the definition for the term provided
 *
 */
//InfoTipList.prototype.get_definition = function ( term ) {
InfoTipList.prototype.get_definition = function ( key ) {

	//var infotip = this.get_infotip( term );
	var infotip = this.get_infotip( key );
	var definition = '';
	
	if ( infotip != null ) {
		definition = infotip.definition;
	}
	
	return definition;
}




