﻿if (!String.prototype.lastChr) { String.prototype.lastChr = function(str) {return (this.length-str.length)==this.lastIndexOf(str);}}
if (!String.prototype.reverse) { String.prototype.reverse = function() {var s="",i=this.length;while(i>0){s += this.substring(i-1,i);i--;}return s;}}
if (!String.prototype.toInt  ) { String.prototype.toInt   = function() {var a=new Array();for(var i=0;i<this.length;i++){a[i]=this.charCodeAt(i);}return a;}}

//	trim methods delete ALL whitespace-type characters below ANSI ' '!!!
if (!String.prototype.ltrim) { String.prototype.ltrim = function(){return this.replace(/^\s\s*/,'');}}
if (!String.prototype.rtrim) { String.prototype.rtrim = function(){var str=this,ws=/\s/,i=str.length;while(ws.test(str.charAt(--i)));return str.slice(0,i+1);}}
if (!String.prototype.trim ) { String.prototype.trim  = function(){return this.ltrim().rtrim();}}

if (!String.prototype.strip) { String.prototype.strip = function(c){var re=new RegExp(c,"g"); return this.replace(re,this);}}

if (!Array.prototype.sum) { Array.prototype.sum = function(){for(var i=0,sum=0;i<this.length;sum+=this[i++]);return sum;}}
if (!Array.prototype.max) { Array.prototype.max = function(){return Math.max.apply({},this);}}
if (!Array.prototype.min) { Array.prototype.min = function(){return Math.min.apply({},this);}}

if (!Array.prototype.clone    ) { Array.prototype.clone     = function(){return Array.apply(null,this);};}
if (!Array.prototype.sortIt   ) { Array.prototype.sortIt    = Array.prototype.sort;}
if (!Array.prototype.reverseIt) { Array.prototype.reverseIt = Array.prototype.reverse;}
if (!Array.prototype.sort     ) { Array.prototype.sort      = function(){var tmp = this.clone();return tmp.sortIt.apply(tmp,arguments);}}
if (!Array.prototype.reverse  ) { Array.prototype.reverse   = function(){var tmp = this.clone();return tmp.reverseIt.apply(tmp,arguments);}}
