var ContactInformationModel = (function() {
	function fnContactInformationModelConstructor() {
		/****************************************************/
		/*                                                  */
		/*                                                  */
		/*              Extend Observable Class             */
		/*                                                  */
		/*                                                  */
		/****************************************************/
		Observable.call(this);
		var SUPER = new Object();
		for (var sMember in this)
			SUPER[sMember] = this[sMember];
		for (var sMember in Observable.prototype)
			SUPER[sMember] = Observable.prototype[sMember];
	
		/****************************************************/
		/*                                                  */
		/*                                                  */
		/*                 Private Variables                */
		/*                                                  */
		/*                                                  */
		/****************************************************/
		
		var oRegistrationDetailsDAO = new RegistrationDetailsDAO();
		var oRegistrationDetails;
		
		/****************************************************/
		/*                                                  */
		/*                                                  */
		/*                Accessors/Mutators                */
		/*                                                  */
		/*                                                  */
		/****************************************************/
		
		this.getFirstName = function() {
			return oRegistrationDetails.getFirstName();
		}
		
		this.setFirstName = function(sNewFirstName) {
			oRegistrationDetails.setFirstName(sNewFirstName);
			this.setChanged();
			this.notifyObservers({event: "Value Changed", property: "First Name"});
		}
		
		this.getLastName = function() {
			return oRegistrationDetails.getLastName();
		}
		
		this.setLastName = function(sNewLastName) {
			oRegistrationDetails.setLastName(sNewLastName);
			this.setChanged();
			this.notifyObservers({event: "Value Changed", property: "Last Name"});
		}
		
		this.getCompany = function() {
			return oRegistrationDetails.getCompany();
		}
		
		this.setCompany = function(sNewCompany) {
			oRegistrationDetails.setCompany(sNewCompany);
			this.setChanged();
			this.notifyObservers({event: "Value Changed", property: "Company"});
		}
		
		this.getEmailAddress = function() {
			return oRegistrationDetails.getEmailAddress();
		}
		
		this.setEmailAddress = function(sNewEmailAddress) {
			oRegistrationDetails.setEmailAddress(sNewEmailAddress);
			this.setChanged();
			this.notifyObservers({event: "Value Changed", property: "Email Address"});
		}
		
		this.getPhoneNumber = function() {
			return oRegistrationDetails.getPhoneNumber();
		}
		
		this.setPhoneNumber = function(sNewPhoneNumber) {
		    oRegistrationDetails.setPhoneNumber(sNewPhoneNumber);
			this.setChanged();
			this.notifyObservers({event: "Value Changed", property: "Phone Number"});
		}
		
		this.getCountry = function() {
			return oRegistrationDetails.getCountry();
		}
		
		this.setCountry = function(sNewCountry) {
			oRegistrationDetails.setCountry(sNewCountry);
			this.setChanged();
			this.notifyObservers({event: "Value Changed", property: "Country"});
		}
		
		this.getState = function() {
			return oRegistrationDetails.getState();
		}
		
		this.setState = function(sNewState) {
			oRegistrationDetails.setState(sNewState);
			this.setChanged();
			this.notifyObservers({event: "Value Changed", property: "State"});
		}
		
		this.getAusState = function() {
			return oRegistrationDetails.getAusState();
		}
		
		this.setAusState = function(sNewAusState) {
			oRegistrationDetails.setAusState(sNewAusState);
			this.setChanged();
			this.notifyObservers({event: "Value Changed", property: "AusState"});
		}
		
		this.getCounty = function() {
			return oRegistrationDetails.getCounty();
		}
		
		this.setCounty = function(sNewCounty) {
			oRegistrationDetails.setCounty(sNewCounty);
			this.setChanged();
			this.notifyObservers({event: "Value Changed", property: "County"});
		}
		
		this.getSTDCode = function() {
			return oRegistrationDetails.getSTDCode();
		}
		
		this.setSTDCode = function(sNewSTDCode) {
			oRegistrationDetails.setSTDCode(sNewSTDCode);
			this.setChanged();
			this.notifyObservers({event: "Value Changed", property: "STD Code"});
		}
		
		this.getIndiaState = function() {
			return oRegistrationDetails.getIndiaState();
		}
		
		this.setIndiaState = function(sNewState) {
			oRegistrationDetails.setIndiaState(sNewState);
			this.setChanged();
			this.notifyObservers({event: "Value Changed", property: "India State"});
		}
		
		this.getPostalCode = function() {
			return oRegistrationDetails.getPostalCode();
		}
		
		this.setPostalCode = function(sNewPostalCode) {
			oRegistrationDetails.setPostalCode(sNewPostalCode);
			this.setChanged();
			this.notifyObservers({event: "Value Changed", property: "Postal Code"});
		}
		
		this.getProvince = function() {
			return oRegistrationDetails.getProvince();
		}
		
		this.setProvince = function(sNewProvince) {
			oRegistrationDetails.setProvince(sNewProvince);
			this.setChanged();
			this.notifyObservers({event: "Value Changed", property: "Province"});
		}
		
		this.getOriginalSource = function() {
			return oRegistrationDetails.getOriginalSource();
		}
		
		this.setOriginalSource = function(sNewOriginalSource) {
			oRegistrationDetails.setOriginalSource(sNewOriginalSource);
			this.setChanged();
			this.notifyObservers({event: "Value Changed", property: "Original Source"});
		}
		
		/****************************************************/
		/*                                                  */
		/*                                                  */
		/*          Class Level Priveleged Methods          */
		/*                                                  */
		/*                                                  */
		/****************************************************/
		
		this.createMemento = function() {
			var oRegistrationDetailsMemento = new RegistrationDetails();
			
			oRegistrationDetailsMemento.setFirstName(oRegistrationDetails.getFirstName());
			oRegistrationDetailsMemento.setLastName(oRegistrationDetails.getLastName());
			oRegistrationDetailsMemento.setCompany(oRegistrationDetails.getCompany());
			oRegistrationDetailsMemento.setEmailAddress(oRegistrationDetails.getEmailAddress());
			oRegistrationDetailsMemento.setPhoneNumber(oRegistrationDetails.getPhoneNumber());
			oRegistrationDetailsMemento.setCountry(oRegistrationDetails.getCountry());
			oRegistrationDetailsMemento.setState(oRegistrationDetails.getState());
			oRegistrationDetailsMemento.setIndiaState(oRegistrationDetails.getIndiaState());
			oRegistrationDetailsMemento.setSTDCode(oRegistrationDetails.getSTDCode());
			oRegistrationDetailsMemento.setPostalCode(oRegistrationDetails.getPostalCode());
			oRegistrationDetailsMemento.setProvince(oRegistrationDetails.getProvince());
			oRegistrationDetailsMemento.setAusState(oRegistrationDetails.getAusState());
			oRegistrationDetailsMemento.setCounty(oRegistrationDetails.getCounty());
			
			return oRegistrationDetailsMemento;
		}
		
		this.restoreDetailsFromMemento = function(oRegistrationDetailsMemento) {
			oRegistrationDetails = oRegistrationDetailsMemento;
			this.setChanged();
			this.notifyObservers({event: "Details Changed"});
		}
		
		this.saveData = function() {
			oRegistrationDetailsDAO.updateRegistrationDetails(oRegistrationDetails);
		}
		
		/****************************************************/
		/*                                                  */
		/*                                                  */
		/*                 Initialize Class                 */
		/*                                                  */
		/*                                                  */
		/****************************************************/
		
		oRegistrationDetails = oRegistrationDetailsDAO.retrieveRegistrationDetails();
		
	}
	
	fnContactInformationModelConstructor.prototype = new Observable();
	fnContactInformationModelConstructor.prototype.constructor = ContactInformationModel;
	
	return fnContactInformationModelConstructor;
})();