﻿var Step3ContactInformationViewHelper = (function() {
    function fnStep3ContactInformationViewHelperConstructor(oNewView) {
        /****************************************************/
		/*                                                  */
		/*                                                  */
		/*                 Private Variables                */
		/*                                                  */
		/*                                                  */
		/****************************************************/
		
		var oView;
		
		/****************************************************/
		/*                                                  */
		/*                                                  */
		/*            Class Level Private Methods           */
		/*                                                  */
		/*                                                  */
		/****************************************************/
		
		function getDisplayValue(sValue) {
		    return sValue == undefined ? "" : sValue;
		}
		
		/****************************************************/
		/*                                                  */
		/*                                                  */
		/*          Class Level Priveleged Methods          */
		/*                                                  */
		/*                                                  */
		/****************************************************/
		
		this.loadValues = function(oValues) {
		    this.setCompany(oValues.sCompany);
		    this.setEmailAddress(oValues.sEmailAddress);
		    this.setLocation(oValues.sCountry, oValues.sProvince, oValues.sState, oValues.sPostalCode);
		    this.setName(oValues.sFirstName, oValues.sLastName);
		    this.setPhoneNumber(oValues.sPhoneNumber);
		}
		
		this.setCompany = function(sCompany) {
		    oView.setCompany(getDisplayValue(sCompany));
		}
		
		this.setEmailAddress = function(sEmailAddress) {
		    oView.setEmailAddress(getDisplayValue(sEmailAddress));
		}
		
		this.setLocation = function(sCountry, sProvince, sState, sPostalCode) {
		    var sLocation = getDisplayValue(sCountry);
			switch (sLocation) {
				case "Canada":
					sLocation += ", " + getDisplayValue(sProvince);
					break;
				case "United States":
					sLocation += ", " + getDisplayValue(sState) + " " + getDisplayValue(sPostalCode);
					break;
			}		
		    oView.setLocation(sLocation);
		}
		
		this.setName = function(sFirstName, sLastName) {
		    oView.setName(getDisplayValue(sFirstName) + " " + getDisplayValue(sLastName));
		}
		
		this.setPhoneNumber = function(sPhoneNumber) {
		    oView.setPhoneNumber(getDisplayValue(sPhoneNumber));
		}
		
		/****************************************************/
		/*                                                  */
		/*                                                  */
		/*                 Initialize Class                 */
		/*                                                  */
		/*                                                  */
		/****************************************************/
		
		oView = oNewView;
    }
    
    return fnStep3ContactInformationViewHelperConstructor;
})();