/*
SAMPLES

	//extends example
	function ClassX (sMsg) {  
	   this.message = sMsg;  
	}  
	 
	function ClassY (sName) {  
	   this.name = sName  
	}  
	 
	function ClassZ() {  
		   this.extends(new ClassX("Hello World"));  
		   this.extends(new ClassY("Joe Schmoe"));  
	}  
	 
	var oTest = new ClassZ();  
	alert(oTest.message);  
	alert(oTest.name);
	//


	function ClassB() {    
	   this.addProperty("string", "message", "Hello world");    
	   this.addProperty("string", "name", "Joe Schmoe");    
	   this.addProperty("number", "age", 25);    
	}    
	   
	ClassB.prototype.onpropertychange = function(oEvent) {    
	   if (oEvent.propertyName == "name") {    
		   oEvent.returnValue = false;  //don’t allow name to be changed    
	   }    
	}    
	   
	var Test = new ClassB();    
	alert(Test.getMessage()); //outputs "Hello world"    
	Test.setMessage("Goodbye world");    
	alert(Test.getMessage());  //outputs "Goodbye world"    
	alert(Test.getName());      //outputs "Joe Schmoe"    
	Test.setName("Michael A. Smith");    
	alert(Test.getName());       //outputs "Joe Schmoe"    
	alert(Test.getAge());      //outputs 25    
	Test.setAge("45");         //generates error message    
	alert(Test.getName());       //outputs 25
*/

Object.prototype.addProperty = function (sType, sName, vValue) {    
           
       if (typeof vValue != sType && vValue != null) {    
           alert("Property " + sName + " must be of type " + sType + ".");    
           return;    
       }    
         
       this[sName] = vValue;    
           
       var sFuncName = sName.charAt(0).toUpperCase() + sName.substring(1, sName.length);    
           
       this["get" + sFuncName] = function () { return this[sName] };    
       this["set" + sFuncName] = function (vNewValue) {    
   
                if (typeof vNewValue != sType) {    
                   alert("Property " + sName + " must be of type " + sType + ".");    
                   return;    
               }    
   
               var vOldValue = this["get" + sFuncName]();    
               var oEvent = {    
                       propertyName: sName,    
                       propertyOldValue: vOldValue,    
                       propertyNewValue: vNewValue,    
                       returnValue: true    
                       };    
               this.onpropertychange(oEvent);    
               if (oEvent.returnValue) {    
                       this[sName] = oEvent.propertyNewValue;    
               }    
   
       };    
}

Object.prototype._extends = function (oSuper) {
       for (sProperty in oSuper) {
               this[sProperty] = oSuper[sProperty];
       }
}

//default onpropertychange() method – does nothing  
Object.prototype.onpropertychange = function (oEvent) {  
       
}
