// Add a method conditionally
Function.prototype.method = function (name, func) {
	if (!this.prototype[name]) {
		this.prototype[name] = func;
		return this;
	}
};

Number.method('integer', function () {
	return Math[this < 0 ? 'ceil' : 'floor'](this);							   
});

String.method('trim', function () {
	return this.replace(/^\s+|\s+$/g, '');
});


// 2010-09-15 [AP] - Deep Copy of an Object
/*
Object.method('supercopy', function(obj) {
	// Descr.:  Erstellt eine Kopie des Objekcts und gibt diese zurück.
	// Values:  obj =  Objekt (Object)
	if (!obj)
		return null;
	if (typeof obj != 'object' || obj instanceof Function || obj instanceof RegExp || obj instanceof Date)
		var newObj = obj; // Copy Reference
	else {
		var newObj = (obj instanceof Array) ? [] : {};
		for ( var n in obj ){
			var node = obj[n];
			if (typeof node=='object')
				newObj[n]=Object.supercopy(node);
			else
	 			newObj[n]=node;			
		}
	}
	return newObj;
});

cloneObject: function (obj){
  // Descr.:  Erstellt eine Kopie des Objekcts und gibt diese zurück.
  // Values:  obj =  Objekt (Object)
  
  if (!obj){
   return null;
  }
  if (typeof obj != 'object' || obj instanceof Function || obj instanceof RegExp || obj instanceof Date){
   newObj = obj; // Copy Reference
  }
  else {
   var newObj = (obj instanceof Array) ? [] : {};
   for ( var n in obj ){
    var node = obj[n];
    if ( typeof node == 'object' ){
     newObj[n] = this.cloneObject(node);
    }
    else {
     newObj[n] = node;
    }
   }
  }
  return newObj;
 }
*/
