

// Array.pop() - Remove and return the last element of an array
if( typeof Array.prototype.pop==='undefined' ) {
 Array.prototype.pop = function() {
  var b = this[this.length-1];
  this.length--;
  return b;
 };
}

// Array.push() - Add an element to the end of an array, return the new length
if( typeof Array.prototype.push==='undefined' ) {
 Array.prototype.push = function() {
  for( var i = 0, b = this.length, a = arguments, l = a.length; i<l; i++ ) {
   this[b+i] = a[i];
  }
  return this.length;
 };
}

// Array.contains - check to see if the supplied object is contained in the array
if ( typeof Array.prototype.contains==='undefined' )
{
	Array.prototype.contains = function(value)
	{
		for ( var i = 0; i < this.length; i++)
		{
			if (this[i] == value)
			{
				return true;
			}
		}
		
		return false;
	}
}

// Array.erase - removes the element at the supplied index from the array
if (typeof Array.prototype.erase === "undefined")
{
	Array.prototype.erase = function(index)
	{
		var tempArray = [];
		
		if (this.length > 0)
		{
			for (var i = index; i < this.length - 1; i++)
			{
				this[i] = this[i + 1];
			}
			
			this.length--;
		}
		else
		{
			this.length = 0;
		}
	}
}

// String.startsWith - check to see if the string starts with the supplied string
if (typeof String.prototype.startsWith === "undefined")
{
	String.prototype.startsWith = function(stringToFind)
	{
		if (this.length < stringToFind.length)
		{
			return false;
		}
		
		if (this.substring(0, stringToFind.length) == stringToFind)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
}

// String.padding - pads the numbers with the specified number of zeros
// eg string.padding(3) would become "005"
if (typeof String.prototype.padding === "undefined")
{
	String.prototype.padding = function(character, numberofzeros)
	{

		var numberOfZerosNeeded = 0;
		var ret = "";
	
		if (this.length > numberofzeros)
		{
			return this;
		}
		
		numberOfZerosNeeded = numberofzeros - this.length;
		
		for (var i = 0; i < numberOfZerosNeeded; i++)
		{
			ret += character;
		}
		
		ret += this.toString();
		
		return ret;
	}
}

// getElementsByClassName - returns an array of elements which have the supplied class name
/*
	Written by Jonathan Snook, http://www.snook.ca/jonathan
	Add-ons by Robert Nyman, http://www.robertnyman.com
*/
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}