function addLoadEvent(func) {
	var oldonload = window.onload;
	if ( !window.onload ) {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

/*--- supportive functions for controlling classnames ---*/
String.prototype.attach = function ( sClass ) {
	var string = this;
	if ( string.contains( sClass ) ) {
		return string;	
	} else {
		return string += ( string != "" ? " " : "" ) + sClass;
	}
	
}
String.prototype.detach = function ( sClass ) {
	var string = this;
	return string.replace ( ( string.indexOf ( " " ) !=-1 ? " " : "" ) + sClass, "" );
}
String.prototype.contains = function ( sString ) {
	var string = this;
	return this.indexOf ( sString ) !=-1;
}

if ( !Array.prototype.push ) {
	Array.prototype.push = function ( item ) {
		this [ this.length ] = item;
		return this.length;
	}
}

function Hash()
{
	this.length = 0;
	this.items = new Array();
	
	if(arguments.length < 2){
		try {
			var oJSON = arguments[0];
			for(key in oJSON){
				if (typeof(oJSON[key]) != 'undefined') {
					this.items[key] = oJSON[key];
					this.length++;
				}
			}
		}
		catch (exception){
			//do nothing
		}
	}
	else if(arguments.length % 2 == 0){
		for (var i = 0; i < arguments.length; i += 2) {
			if (typeof(arguments[i + 1]) != 'undefined') {
				this.items[arguments[i]] = arguments[i + 1];
				this.length++;
			}
		}
	}
	else
		throw "illegal number"
	this.removeItem = function(in_key) {
		var tmp_value;
		if (typeof(this.items[in_key]) != 'undefined') {
			this.length--;
			var tmp_value = this.items[in_key];
			delete this.items[in_key];
		}  
		return tmp_value;
	}
	this.getItem = function(in_key) {
		return this.items[in_key];
	}
	this.getKeyAt = function(in_index) {
		if(in_index < 0 || in_index > this.length)
			throw "index out of bounds"; 
		var index = 0;
		for(key in this.items){
			if(in_index == index)
				return key;
			index++;
		}
		return null;
	}
	this.getItemAt = function(in_index) {
		var key = this.getKeyAt(in_index);
		return key == null ? null : this.items[key];
	}
	this.setItem = function(in_key, in_value) {
		if (typeof(in_value) != 'undefined') {
			if (typeof(this.items[in_key]) == 'undefined') {
				this.length++;
			}
			this.items[in_key] = in_value;
		}
		return in_value;
	}
	this.hasItem = function(in_key) {
		return typeof(this.items[in_key]) != 'undefined';
	}
	this.getIndexOf = function(in_key) {
		var index = 0;
		for(key in this.items){
			if(key == in_key)
				return index;
			index++;
		}
		return -1;
	}
}
		

