/* Mike's stack functions.  ECMA-262 specifies push, pop, shift, and unshift functions
 * as part of the Array object, and Netscape Javascript supports them.  However, Microsoft
 * JScript, claimed to "fully conform to the ECMA-262 specification", does not support
 * these functions.  Stacks are very useful things, so I have created my own push and pop
 * functions.
 */

/* MPush - Adds any number of items to the end of the array, in the order listed.
 * Returns the new length of the array.
 */
function MPush(itemToPush) {
	var ptrArgs;

	for (ptrArgs=0; ptrArgs < MPush.arguments.length; ptrArgs++)  // for each argument
		this[this.length] = MPush.arguments[ptrArgs];             // add to end of array
	return this.length;                                           // return array length
	}

/* MPop - Removes the last element of the array and returns it.  Array length is
 * shortened by 1.  Does nothing if array is empty.
 */
function MPop() {
	var retval;

	if (this.length) {                   // if there is something in array
		retval = this[this.length - 1];  // get last value in array
		this.length--;                   // shorten array, removing last element
		return retval;                   // return removed element
		}
	}

/* Add functions to Array object. */
Array.prototype.MPush = MPush;
Array.prototype.MPop = MPop;