

// This object prevents errors (or even not executed scripts) in IE and browsers w/o Firebug installed.

var FirebugUtils = {



	consoleMethods: ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"],



	available: function() {

		return (window.console) ? (window.console.firebug) : false;

	},

	check: function() {

		if (!this.available()) this.disable();

	},

	disable: function() {

		window.console = {};

		var methods = this.consoleMethods;

		for (var i = methods.length - 1; i > -1; i--) {

			window.console[methods[i]] = function(){};

		}

	}

}

FirebugUtils.check();





// Checks whether a string ends with the given suffix.

if (!String.prototype.endsWith) {

	String.prototype.endsWith = function(suffix) {

		var startPos = this.length - suffix.length;

		if (startPos < 0) {

			return false;

		}

		return (this.lastIndexOf(suffix, startPos) == startPos);

	};

}



// Checks whether a string ends with the given suffix.

if (!String.prototype.startsWith) {

	String.prototype.startsWith = function(term) {

		return (this.indexOf(term) == 0);

	};

}



// takes an object and replaces 

// all occurrences of the object's field names 

// surrounded by curly brackets with the objects values 



// "Hello {person}".fillInTemplateTags({person:"Fred"}) yields "Hello Fred"



String.prototype.fillInTemplateTags=function(obj){

	var result=this.toString();



	for(var field in obj){

		var fieldTag="{"+field+"}";

		var fieldTagEncoded=escape(fieldTag);

		// does not replace multiple occurrences??

		// result=result.replace(fieldTag, obj[field]);

		// does not replace multiple occurrences??

		result=result.split(fieldTag).join(obj[field]);

		result=result.split(fieldTagEncoded).join(obj[field]);		

	}

	return result;

}





function HashMap() {

	this.internalMap = new Object();

}

HashMap.prototype.size = function() {

	var i = 0;

	for (var v in this.internalMap) {

		i++;

	}

	return i;

}

HashMap.prototype.add = function(key, value) {

	this.internalMap[key] = value;

}

HashMap.prototype.get = function(key) {

	return this.internalMap[key];

}

HashMap.prototype.remove = function(key) {

	delete this.internalMap[key];

}

HashMap.prototype.empty = function() {

	this.internalMap = new Object();

}



