﻿//  -----   feel free to use this stuff   ---   play with it   ---   copy as You  like   -----
//  -----   but leave this authors 2 lines untouched:  pseliger@gmx.net  [august 2005]   -----
//
//  extended javascript-api-methods       :
//  * jsApi-extension-name / file-name    : "jsApi.Array.mozExtensions.js"
//  * original download-location          : "http://www.pseliger.de/jsExtendedApi/jsApi.Array.mozExtensions.js"
//
//  first public release:  august 18-2005 - implements the specifications of mozillas recently introduced additional Array methods as it can be
//                                          read at [http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array#Methods];
//                                        - adds the method "Array.contains" as well;
//                                        - also have a look at this old stuff of my own like:
//                                          [http://www.pseliger.de/jsExtendedApi/jsApi.Array.normalize.js],
//                                          [http://www.pseliger.de/jsExtendedApi/jsApi.Array.shuffle.js] and
//                                          [http://www.pseliger.de/jsExtendedApi/jsApi.Array.setMethods.js];
//
if (typeof Array.prototype.indexOf != "function") {Array.prototype.indexOf = function (obj, idx) {idx=((idx&&isNaN(Number(idx)))?(parseInt(Number(idx),10)):(0));idx=((idx<0)?(Math.max(0,(this.length+idx))):(idx));var k,i=-1;for(k=idx;k<this.length;++k){if(this[k]===obj){i=k;break;}}return i;};}
if (typeof Array.prototype.lastIndexOf != "function") {Array.prototype.lastIndexOf = function (obj, idx) {idx=((idx&&isNaN(Number(idx)))?(parseInt(Number(idx),10)):(this.length-1));idx=((idx<0)?(Math.max(0,(this.length+idx))):(idx));idx=((idx>this.length)?(this.length):(idx));var k,i=-1;for(k=idx;k>=0;--k){if(this[k]===obj){i=k;break;}}return i;};}
if (typeof Array.prototype.contains != "function") {Array.prototype.contains = function (obj) {return(this.indexOf(obj)>=0);};}
if (typeof Array.prototype.forEach != "function") {Array.prototype.forEach = function (fct, thisArr) {if(typeof fct=="function"){thisArr=((thisArr&&(typeof thisArr=="object")&&(thisArr instanceof Array))?(thisArr):(null));var i,l=this.length;for(i=0;i<l;++i){fct.call(thisArr,this[i],i,this);}}};}
if (typeof Array.prototype.every != "function") {Array.prototype.every = function (fct, thisArr) {var isAnd=false;if(typeof fct=="function"){thisArr=((thisArr&&(typeof thisArr=="object")&&(thisArr instanceof Array))?(thisArr):(null));isAnd=true;var i,l=this.length;for(i=0;i<l;++i){if(!fct.call(thisArr,this[i],i,this)){isAnd=false;break;}}}return isAnd;};}
if (typeof Array.prototype.some != "function") {Array.prototype.some = function (fct, thisArr) {var isOr=false;if(typeof fct=="function"){thisArr=((thisArr&&(typeof thisArr=="object")&&(thisArr instanceof Array))?(thisArr):(null));var i,l=this.length;for(i=0;i<l;++i){if(fct.call(thisArr,this[i],i,this)){isOr=true;break;}}}return isOr;};}
if (typeof Array.prototype.map != "function") {Array.prototype.map = function (fct, thisArr) {var arr=[];if(typeof fct=="function"){thisArr=((thisArr&&(typeof thisArr=="object")&&(thisArr instanceof Array))?(thisArr):(null));var i,l=this.length;for(i=0;i<l;++i){arr.push(fct.call(thisArr,this[i],i,this));}}return arr;};}
if (typeof Array.prototype.filter != "function") {Array.prototype.filter = function (fct, thisArr) {var arr=[];if(typeof fct=="function"){thisArr=((thisArr&&(typeof thisArr=="object")&&(thisArr instanceof Array))?(thisArr):(null));var i,l=this.length;for(i=0;i<l;++i){if(fct.call(thisArr,this[i],i,this)){arr.push(this[i]);}}}return arr;};}
