﻿


function User()
{

    this.FirstName = "";
    this.LastName = "";
    this.Company = ""
    this.Email = "";
    this.Password = "";
    
    this.Phone = "";
    this.Newsletter = false;
    this.ValidationMessage = "";
    
    this.DiscountUsed = false;
    
    this.CCEmail = "";
    this.CCFirstName = "";
    this.CCLastName = "";
    this.CCCompanyName = "";
    this.CCStatus = 0;
    

}


User.prototype.ValidEmail = function(validEmail)
{   
    this.ValidationMessage = "";
    var retVal = false;
	var strRes = this.Email;
	if (strRes != null && strRes != "")
	{
		var emailTest = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (emailTest.test(strRes)) {
			retVal = (this.Email == validEmail);
			if (!retVal)
			{
			    this.ValidationMessage = "The email addresses you provided do not match.";
		    }
		}
		else
		{
		    this.ValidationMessage = "Please provide a valid email address.";
		}
	}
	else
	{
	    this.ValidationMessage = "Please provide a valid email address.";
	}
	return retVal;
}

User.prototype.ValidUserName = function(validUser)
{
	this.ValidationMessage = "";
    var retVal = false;
	var strRes = this.Email;
	if (strRes != null && strRes != "")
	{

		retVal = (this.Email == validUser);
		if (!retVal)
		{
			  this.ValidationMessage = "The usernames you provided do not match.";
		}

	}
	else
	{
	    this.ValidationMessage = "Please provide a valid username.";
	}
	return retVal;

}

User.prototype.ValidPassword = function(validPass)
{
    this.ValidationMessage = "";
    var retVal = false;
    if (this.Password != null && validPass != null)
    {   
        if (this.Password.length == validPass.length)
        {
            if (this.Password.length >= 4 && this.Password.length <= 10)
            {
                retVal = (this.Password == validPass);
                if (!retVal)
                {
                 
                    this.ValidationMessage = "The passwords you provided do not match.";
                }
            }
            else
            {
                this.ValidationMessage = "Please provide a password that has between 4 and 10 characters.";

            }
        }
        else
        {
            this.ValidationMessage = "The passwords you provided do not match.";

        }
    }
    else
    {
        this.ValidationMessage = "Please provide a valid password.";

    }
    
    return retVal;
}





