/* 
Object methods/functions 
I tend to make these functions rather than Object methods, else we increase the size of all our objects.
*/

var cloneObject = function(source) {
	
	var target = {};
	for (property in source) {
		if (typeof source.property == 'object') {
			target[property] = cloneObject(source[property]);
		}
		else {
			target[property] = source[property];
		}
	}
	return target;
};

/**
 * Merge the keys of two objects together. The combination parameter(s)
 * will overwrite any duplicate keys in obj.
 * @method combine
 * @param {Object} obj the object to be written to
 * @param {Object} combination the object to combine into obj
 */
var combine = function(obj, combination) {
	var curCombination = null;
	
	for( var i = 1; i < arguments.length; ++i ) {
		curCombination = arguments[i];
		for( var key in curCombination ) {
			obj[key] = curCombination[key];
		}
	}
};

/**
 * Merge the keys of two objects together. The combination parameter(s)
 * will overwrite any duplicate keys in obj. Any keys that are not
 * already in obj will be ignored.
 * @method apply
 * @param {Object} obj the object to be written to
 * @param {Object} combination the object to combine into obj
 */
var apply = function(obj, combination) {
	var curCombination = null;
	
	for( var i = 1; i < arguments.length; ++i ) {
		curCombination = arguments[i];
		for( var key in curCombination ) {
			if( typeof(obj[key]) != "undefined" ) {
				obj[key] = curCombination[key];
			}
		}
	}
};