String.prototype.replaceEnd = function (s1, s2)
{
 str = this;
 c = str.lastIndexOf(s1);
 str2 = str.substring(c, str.length);
 str = str.substring(0, c) + str2.replace(s1, s2);
 return str;
}

Array.prototype.inArray = function (value)
{
 for (var i=0; i<this.length; i++) if(this[i]==value) return i;
 return -1;
}

Array.prototype.insertAfter = function (pos, value)
{
 for (var i=this.length+1; i>pos; i--) this[i] = this[i-1]; 
 this[pos]=value;
}
