/*  LayerZero
 *  (c) 2007 Maioli Giacomo Luca
 *
 *  LayerZero is freely distributable under the terms of an MIT-style license.
 *
/*--------------------------------------------------------------------------*/

function get(str) {
  	result = null
	if (typeof str == 'string'){
	    result =  document.getElementById(str)
	}
  
	/** Used for flash objects TODO: change this (EVIL EVAL)*/
  
	if (!result){
		result = eval("document." + str)
	}
	return result;
}

function add(receiver, propertyDict){
	classAdd(receiver.prototype, propertyDict)
}

/* add a property from a string or a object */ 
function classAdd(receiver, properties){
	if (properties.constructor == String && properties.length > 0){
		receiver[properties] = {}
		return true
	}else{
		var addedKeys = 0
		for (key in properties){
			receiver[key] = properties[key]
			addedKeys++
		}
		if (addedKeys != 0)
			return true
	}
	return false
}

add(Array, {
	changeIfValueIs : function(value, newValue){
		var result = null
		for (var i = 0; i < this.length; i++){
			if (this[i] == value){
				this[i] = newValue
			}
		}
	}
})
