// also give every object the ability to add properties and 
// throw some modifiers in there for good measure.  override 
// the onpropertychange method and fire it when the set modifier 
// is called. 
Object.prototype.addProperty = function (who, what) { 
  this[who] = what; 
  var brand = who.charAt(0).toUpperCase() + who.substring(1, who.length); 
  this["get" + brand] = function () { return this[who] }; 
  this["set" + brand] = function (newVal) { 
     var oldVal = this['get' + brand](); 
     var evt = {  propertyName: who,  propertyOldValue: oldVal,  propertyNewValue: newVal, returnValue: true }; 
	 // call the overridden onpropertychange to check for anything to disallow
     this.onpropertychange(evt); 
	 
     if (evt.returnValue) { 
       this[who] = evt.propertyNewValue; 
     } 
  }; 
} 

//default onpropertychange() method - does nothing 
// override this in any subclasses:
// menuobject.prototype.onpropertychange = function( evt ){ blah; stuff; }
// addProperty then calls that function when the set modifier is called.
Object.prototype.onpropertychange = function (evt) { 
  // return true as default.  could add type checking in here.
}


// testing
/*
function ClassB() { 
   this.addProperty('message', 'Hello world'); 
   this.addProperty('name', 'Nicholas C. Zakas'); 
} 

//ClassB.prototype.onpropertychange = function(oEvent) { 
//   if (oEvent.propertyName == "name") { 
//       oEvent.returnValue = false;  //don't allow name to be changed 
//   } 
//} 

var Test = new ClassB(); 
Test.setMessage('Goodbye world'); 
Test.setName('Michael A. Smith');  


*/

// end testing	
