// ---------------------------------------------------------------------------
// js_base.js: Basic stuff for juniper javascript features. 
// ---------------------------------------------------------------------------
// Part of the Juniper website rendering framework, 
// http://immortalcookie.com/juniper
// Copyright (C) 2006 Eric Miller
// eric@immortalcookie.com
// 
// ---------------------------------------------------------------------------
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
// Lesser GPL license text:
// http://www.gnu.org/licenses/lgpl.txt
//
// The Creative Commons GNU-LGPL Summary:
// http://creativecommons.org/licenses/LGPL/2.1/
// ---------------------------------------------------------------------------

// our "namespace"
var juniper = new Object();


juniper.MapElement = function( key, value ) {
	this.first = key;
	this.second = value;
}

juniper.Map = function() {
	this.mElements = new Array();
}
	
juniper.Map.prototype.add = function( key, value ) {
	this.mElements.push( new juniper.MapElement( key, value ) );
	return value;
};
	
juniper.Map.prototype.valueForKey = function( key ) {
	var o = this.mElements.find( function( value, index ){
		return ( value.first == key );
	} );
	if( o !== undefined )
		return o.second;
	else
		return null;
};

juniper.Map.prototype.erase = function( key ) {
	// kinda silly ...
	this.mElements.splice( this.mElements.indexOf( this.mElements.find( function( value, index ){
		return ( value.first == key ); } ) ), 1 );
};

