/**
 * ObjectUtils: adding boilerplate and convenience methods to objects 
 * 
 * (c) 2007 Ray Djajadinata <ray dot djajadinata at gmail dot com>
 */
var ObjectUtils = {
	
	/**
	 * Clone an object. Returns a shallow copy of the object.
	 * 
	 * @param {Object} cloneable
	 */
	shallowClone: function(cloneable) {
		var clone = {};
		for(prop in cloneable) {
			clone[prop] = cloneable[prop];
		}
		return clone;
	},
	
	/**
	 * Returns a deep copy of the object. 
	 * 
	 * @param {Object} cloneable
	 */
	deepClone: function(cloneable) {
		var clone = {};
		for(prop in cloneable) {
			if(typeof(cloneable[prop]) == "object") {
				// if it's an object, do a copy
				clone[prop] = deepClone(cloneable[prop]);
			} else {
				clone[prop] = cloneable[prop];
			}
		}
		return clone;
	},	

	/**
	 * Add equals() method to an object, taking all properties
	 * specified in props into account
	 * 
	 * @param {Object} obj
	 * @param {Object} props an array that contains the names of the properties
	 * to consider. If props is not supplied, check using ==
	 */
	addEquals: function(obj, props) {
		obj.equals = function(o) {
			if(this === o) {
				return true;
			}
			if(o == null) {
				return false;
			}
			for(var i = 0; i < props.length; i++) {
				if(typeof(obj[props[i]]) == "object") {
					
				}
			}			
		};
	},

	/**
	 * Calculates the hash of a string
	 * 
	 * @param {Object} str
	 */
	hashString: function(str) {
		var h = 0;
    	var len = str.length;
        for (var i = 0; i < len; i++) {
            h = (31*h) + str.charCodeAt(i);
        }
        return h;
	},

	/**
	 * Calculates the hash of a boolean
	 * 
	 * @param {Object} b
	 */
	hashBoolean: function(b) {
		return (b ? 0 : 1);
	},

	hashNumber: function(n) {
		return ObjectUtils.hashString(n.toString());
	},

	/**
	 * Calculates the hash of the object obj. props is an array
	 * that contains the names of the properties to include in the
	 * hash calculation.
	 *  
	 * @param {Object} obj
	 * @param {Object} props
	 */
	hash: function(obj, props) {
		
	}
	

};
