(function() {
    BemsWebApplication.CmCompanyViewModel = function(data) {
            this.SiteId = ko.observable();
            this.CompanyId = ko.observable();
            this.CompanyTypeId = ko.observable();
            this.Name = ko.observable();
            this.PhoneNo = ko.observable();
            this.FaxNo = ko.observable();
            this.RepresentativeName = ko.observable();
            this.SalesName = ko.observable();
            this.SalesPhoneNo = ko.observable();
            this.AddressZip1 = ko.observable();
            this.AddressZip2 = ko.observable();
            this.Address1 = ko.observable();
            this.Adderss2 = ko.observable();
            this.Homepage = ko.observable();
            this.Comment = ko.observable();
            this.IsUse = ko.observable();
            if(data)
                this.fromJS(data);
    };

    $.extend(BemsWebApplication.CmCompanyViewModel.prototype, {
        toJS: function() {
            return {
                SiteId: this.SiteId(),
                CompanyId: this.CompanyId(),
                CompanyTypeId: this.CompanyTypeId(),
                Name: this.Name(),
                PhoneNo: this.PhoneNo(),
                FaxNo: this.FaxNo(),
                RepresentativeName: this.RepresentativeName(),
                SalesName: this.SalesName(),
                SalesPhoneNo: this.SalesPhoneNo(),
                AddressZip1: this.AddressZip1(),
                AddressZip2: this.AddressZip2(),
                Address1: this.Address1(),
                Adderss2: this.Adderss2(),
                Homepage: this.Homepage(),
                Comment: this.Comment(),
                IsUse: this.IsUse(),
            };
        },

        fromJS: function(data) {
            if(data) {
                this.SiteId(data.SiteId);
                this.CompanyId(data.CompanyId);
                this.CompanyTypeId(data.CompanyTypeId);
                this.Name(data.Name);
                this.PhoneNo(data.PhoneNo);
                this.FaxNo(data.FaxNo);
                this.RepresentativeName(data.RepresentativeName);
                this.SalesName(data.SalesName);
                this.SalesPhoneNo(data.SalesPhoneNo);
                this.AddressZip1(data.AddressZip1);
                this.AddressZip2(data.AddressZip2);
                this.Address1(data.Address1);
                this.Adderss2(data.Adderss2);
                this.Homepage(data.Homepage);
                this.Comment(data.Comment);
                this.IsUse(data.IsUse);

            }
        }
    });
})();