Listing 1

// Constructor
function Calculator(ops) {
    	this.ops = ops;
}
with (Calculator) {
	// Make constructor available as a member function
	prototype.Calculator = Calculator;
	// Member functions
	prototype.evaluate = function () {
		this.opsStack = new Array();
		for (var i = 0; i < this.ops.length; i++) {
			var op = this.ops[i];
			if (typeof op == "number")
				this.push(op);
			else if (typeof this[op] == "function")
				this[op]();
		}
		return this.pop();
	};
	prototype.pop = function () {return this.opsStack.pop();}
	prototype.push = function (val) {this.opsStack.push(val);}
}

//Constructor
function ArithmeticCalcuator(ops) {
	this.Calculator(ops);	// super
};
with (ArithmeticCalcuator) {
	// Establish inheritance
	ArithmeticCalcuator.prototype = new Calculator();
	prototype.constructor = ArithmeticCalcuator;
	// Make constructor available as a member function
	prototype.ArithmeticCalcuator = ArithmeticCalcuator;
	// Member functions
	prototype.add = function () {this.push(this.pop() + this.pop()); }
	prototype.sub = function () {this.push(this.pop() - this.pop());}
	prototype.mul = function () {this.push(this.pop() * this.pop());}
	prototype.div = function () {this.push(this.pop() / this.pop());}	
}

Listing 2

<PUBLIC:COMPONENT NAME="cbx" tagName="CHECKBOX">
<PROPERTY NAME="label" />
<PROPERTY NAME="checked" GET="getChecked" PUT="putChecked" />
<PROPERTY NAME="labelonleft" VALUE="true"/>
<PROPERTY NAME="value" GET="getValue" PUT="putValue" />
<PROPERTY NAME="onValue" VALUE="true"/>
<PROPERTY NAME="offValue" VALUE="false"/>
<METHOD NAME="show"/>
<EVENT NAME="onItemChanging" ID="onItemChanging"/>
<EVENT NAME="onItemChanged" ID="onItemChanged" />
<ATTACH EVENT="oncontentready" HANDLER="constructor" />
<SCRIPT >

	var _value;

	function constructor() 	{
		var s;
		s = '<INPUT name="cb_'+ uniqueID + '" id="cb_' + uniqueID + '" type="checkbox" '
		 + 'onclick="' + uniqueID + '.checked= +cb_' + uniqueID+ '.checked" ';
		if( _value == onValue )
			s +=' checked="true" ';
		s+= "/>";
		element.insertAdjacentHTML('afterBegin', s);
		element.insertAdjacentHTML((labelonleft == "true")?'afterBegin':'beforeEnd', 
			'<LABEL for="cb_' + uniqueID+ '">' + label + '</LABEL>');
	}

	function putChecked( newValue ) {
		value = (newValue?onValue:offValue);
	}
	function getChecked(){ 
		return ( _value == onValue); 
	}

	function getValue(){ 
		return _value ; 
	}
	function putValue( newValue ) {
		if (window.event == null) 
			_value = newValue; /* initial*/
		else if (_value != newValue) {
			var oEvent = createEventObject();
			oEvent.newValue = newValue;
			oEvent.returnValue = true;
			onItemChanging.fire(oEvent);
			if (oEvent.returnValue) 
				_value = newValue;
			eval('cb_'+uniqueID).checked= ( _value == onValue );
			if (_value == newValue)
				onItemChanged.fire(oEvent);
		}
	}

	function show(bCmdShow){
		style.visibility= (bCmdShow?'visible':'hidden') ;
	}

</SCRIPT>
</PUBLIC:COMPONENT>