

function signupModel(){
	var myModelBase = new modelBase("signup");
	// Create a new object with the modelBase object as prototype
	var mysignupModel = Object.create(myModelBase);
	
 	
	/***
	 * VALIDATION
	 * We use object augmentation to override the default validate function
	 * of the modelBase used. 'this' keyword refers to the modelBase instance. 
	 * @param {Object} group A string that can be used to only validate a subgroup, e.g. a panel  
	 */
	mysignupModel.validate = function(group){
		var notifications;
		var inputIsOK = true; 
		

		// A simple function that also can be used on the server side
		function performValidation(dataToValidate, settings){
			var errorMsgs = new Array();
			var defined;
			
			//Validate email
			defined = typeof(dataToValidate['emailAddress']) !== "undefined";					
			if (!defined || (defined && dataToValidate['emailAddress'].length === 0)) {	
				errorMsgs.push({
					"Reciever": "emailAddress",
					"Error": "You must enter a valid email address."
				});
			}
			else{
				var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;				
				if(reg.test(dataToValidate['emailAddress']) == false) {
					errorMsgs.push({
						"Reciever": "emailAddress",
						"Error": "The email address you enterd is not valid. Please enter a valid email address."
					});
				}
			}
			
			//Validate password
			defined = typeof(dataToValidate['password']) !== "undefined";					
			if (!defined || (defined && dataToValidate['password'].length < 6)) {	
				errorMsgs.push({
					"Reciever": "password",
					"Error": "Your password must be at least 6 characters long."
				});
			}

			//Validate acceptance of privacy and terms						
			if (!(dataToValidate['acceptLegal'] && dataToValidate['acceptLegal'][0] === "accepted")) {	
				errorMsgs.push({
					"Reciever": "acceptLegal",
					"Error": "Please read and accept the User Agreement and Privacy Policy."
				});
			}
			
			
			if(dataToValidate.displayName){				
				if(dataToValidate.displayName.length > 25){
					errorMsgs.push({
						"Reciever": "displayName",
						"Error": "Display name may not be longer than 25 characters.",	
					});				
				} 
			}
			else{
				errorMsgs.push({
					"Reciever": "displayName",
					"Error": "You must enter a display name.",	
				});
			}
			return errorMsgs;
		}

		
		notifications = performValidation(this.getData());
		
		if(notifications.length > 0){
			inputIsOK = false;
			for (i=0;i<notifications.length;i++)
			{
				this.notifyValidationListers(notifications[i]);	
			}
		}
		
		// Always notify the savebutton which must know if there were any errors.	
		this.notifyValidationListers({
					"Reciever": "saveButton",
					"Error": !inputIsOK
				});
						
		// Return true if validation was ok				
		return inputIsOK;

	} 
			
	// Return the created model as the last act of the constructor
	return mysignupModel;
}

