Object.prototype.extend = function (cls) {
	bck = this.prototype;
	this.prototype = new cls();
	this.prototype.constructor=this;
	
	for (var i in bck) {
		this.prototype[i] = bck[i];
	}
};

function isset(v) {
	return (typeof v != "undefined");
}

function inArray(toSearch, list) {
	for (var i in list) {
		if (list[i] == toSearch) {
			return true;
		}
	}
	return false;
}

function parseJSON (txt) {
	if (txt.charAt(0)=="{") {
		return eval("(" + txt + ")");
	} else {
		return eval(txt);
	}
}

function measureObjectPollution() {
	var temp = new Object();
	i = 0;
	for(var a in temp) {
	    i++;
	}
	return i;
}

/**
 * Tiré de la librairie prototype
 */

function $A(iterable) {
  if (!iterable){ return []};
  if (iterable.toArray) {
    return iterable.toArray();
  } else {
    var results = [];
    for (var i = 0, length = iterable.length; i < length; i++) {
      results.push(iterable[i]);
    }
    return results;
  }
}

Function.prototype.bind = function () {
	var __method = this, args = $A(arguments), object = args.shift();
	
	return function() {
	  return __method.apply(object, args.concat($A(arguments)));
	}
};
