
if(!Array.prototype.toSource) {
	function array_tosource(){
		st = "";
		for(var i=0;i<this.length;i++) {
			tEl = this[i];
			switch(typeof tEl){
				case "string":
					st+="\"" + tEl.replace(/"/g,"\\\"") + "\"";
					break;
				case "object":
					st+=tEl.toSource();
					break;			
		 		default:
	 				st+=tEl
			}
			if(i<this.length-1)st+=","
		}
		return "[" + st + "]"
	}
	Array.prototype.toSource = array_tosource;
}

if(!Array.prototype.shift) {
	function array_shift() {
		firstElement = this[0];
		this.reverse();
		this.length = Math.max(this.length-1,0);
		this.reverse();
		return firstElement;
	}

	Array.prototype.shift = array_shift;
}

if(!Array.prototype.unshift) {
	function array_unshift() {
		this.reverse();
		for(var i=arguments.length-1;i>=0;i--){
			this[this.length]=arguments[i]
		}
		this.reverse();
		return this.length
	}
	Array.prototype.unshift = array_unshift;
}

if(Array.prototype.push && ([0].push(true)==true))Array.prototype.push = null;
if(Array.prototype.splice && typeof([0].splice(0))=="number")Array.prototype.splice = null;

if(!Array.prototype.push) {

	function array_push() {
		for(i=0;i<arguments.length;i++){
			this[this.length]=arguments[i]
		};
		return this.length;
	}
	Array.prototype.push = array_push;

}

if(!Array.prototype.pop) {

	function array_pop(){
	    lastElement = this[this.length-1];
		this.length = Math.max(this.length-1,0);
	    return lastElement;
	}

	Array.prototype.pop = array_pop;

}

if(!Array.prototype.splice) {

	function array_splice(ind){
		if(ind==null) return ind;
		if(ind<0) ind = this.length + ind;
		if(ind > this.length) {
			if(arguments.length>2) ind = this.length;
			else return [];
		}
		cnt = arguments[1] ? arguments[1] : this.length-ind;

		firstArray = [];
		secondArray = [];
		thirdArray = [];

		for(var i=0;i<this.length;i++){
			tEl = this[i];
			if(i<ind) firstArray.push(tEl);
			else if(i<ind+cnt) secondArray.push(tEl);
			else thirdArray.push(tEl);
		}

		this.length = firstArray.length;
		for(i=2;i<arguments.length;i++){
			this.push(arguments[i]);
		}
		this.concat(thirdArray);
		return secondArray;
	}

	Array.prototype.splice = array_splice;

}








