protected void Page_Load(object sender, EventArgs e)
        {
            IModelFactory modelFactory = Vortx.OnePageCheckout.ObjectFactory.CreateModelFactory();
            IConfigurationProviderFactory configurationFactory = Vortx.OnePageCheckout.ObjectFactory.CreateConfigurationFactory();

            ConfigurationProvider.DefaultProvider = configurationFactory.CreateConfigurationProvider();

            this.StringResourceProvider = modelFactory.CreateStringResourceProvider();

            this.AccountModel = modelFactory.CreateAccountModel();
            this.AccountModel.CreateAccountCompleted         += new CreateAccountHandler(AccountModel_CreateAccountCompleted);
            this.AccountModel.FindAccountCompleted           += new FindAccountHandler(AccountModel_FindAccountCompleted);
            this.AccountModel.LogOnCompleted                 += new LogOnHandler(AccountModel_LogOnCompleted);
            this.AccountModel.LogOutCompleted                += new LogOutHandler(AccountModel_LogOutCompleted);
            this.AccountModel.AccountChanged                 += new AccountChangedHandler(AccountModel_AccountChanged);
            this.AccountModel.BillingAddress.AddressChanged  += new AddressChangedEventHandler(BillingAddressEditModel_AddressChanged);
            this.AccountModel.ShippingAddress.AddressChanged += new AddressChangedEventHandler(ShippingAddressEditModel_AddressChanged);
            this.AccountModel.PasswordChanged                += new PasswordChangedHandler(AccountModel_PasswordChanged);

            this.LoginView.StringResourceProvider = this.StringResourceProvider;
            this.LoginView.SetModel(this.AccountModel);

            this.CreateAccountView.StringResourceProvider = this.StringResourceProvider;
            this.CreateAccountView.SetModel(this.AccountModel);
            this.CreateAccountView.AccountCreationActivated += (o, ea) => ApplyAccountCreation();

            // Create shopping cart models
            this.ShoppingCartModel = modelFactory.CreateShoppingCartModel();
            this.ShoppingCartModel.AccountModel         = this.AccountModel;
            this.ShoppingCartModel.ItemQuantityChanged += new ItemQuantityChangedHandler(ShoppingCartModel_ItemQuantityChanged);
            this.ShoppingCartModel.ItemRemoved         += new ItemRemovedHandler(ShoppingCartModel_ItemRemoved);
            this.ShoppingCartModel.ShipMethodChanged   += new ShipMethodChangedEventHandler(ShipMethodModel_ShipMethodChanged);

            // Create shopping cart views
            this.ShipMethodView.StringResourceProvider = this.StringResourceProvider;
            this.ShipMethodView.SetModel(this.ShoppingCartModel);

            this.MiniCartView.StringResourceProvider = this.StringResourceProvider;
            this.MiniCartView.SetModel(this.ShoppingCartModel);

            this.MiniCartCartSummary.StringResourceProvider = this.StringResourceProvider;
            this.MiniCartCartSummary.SetModel(this.ShoppingCartModel);

            this.AddressBookView.StringResourceProvider = this.StringResourceProvider;
            this.AddressBookView.SetModel(this.AccountModel);
            this.AddressBookView.SetAddressType(AddressType.Shipping);

            this.ShippingAddressEditView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressEditView.SetModel(this.AccountModel.ShippingAddress);

            this.ShippingAddressEditUKView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressEditUKView.SetModel(this.AccountModel.ShippingAddress);

            this.ShippingAddressNoZipEditView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressNoZipEditView.SetModel(this.AccountModel.ShippingAddress);

            this.ShippingAddressStaticView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressStaticView.SetModel(this.AccountModel.ShippingAddress);
            this.ShippingAddressStaticView.AddressEdit += new AddressEditEventHandler(ShippingAddressStaticView_AddressEdit);

            // Create payment model
            this.PaymentModel = modelFactory.CreatePaymentModel();
            this.PaymentModel.ActivePaymentMethodChanged += new ActivePaymentMethodChangedHandler(PaymentMethodModel_ActivePaymentMethodChanged);
            this.PaymentModel.ProcessPaymentComplete     += new ProcessPaymentCompleteHandler(PaymentModel_ProcessPaymentComplete);

            if (!ConfigurationProvider.DefaultProvider.ShowCreateAccount &&
                !ConfigurationProvider.DefaultProvider.PasswordIsOptionalDuringCheckout)
            {
                throw new Exception(StringResourceProvider.GetString("smartcheckout.aspx.129"));
            }

            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();

            // Setup payment events
            PaymentMethodBaseModel paymentMethod = null;

            if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut && (this.PaymentModel.ActivePaymentMethod == null || this.PaymentModel.ActivePaymentMethod.Name.ToLower() != PaymentType.CheckoutByAmazon.ToString().ToLower()))
            {
                this.PaymentModel.SetActivePaymentMethod(PaymentType.CheckoutByAmazon.ToString());
            }
            else
            {
                paymentMethod = this.PaymentModel.PaymentMethods.FirstOrDefault(pm => pm.Key == PaymentType.CreditCard).Value;
                if (paymentMethod != null)
                {
                    this.CreditCardModel = (CreditCardPaymentModel)paymentMethod;
                    this.CreditCardModel.BillingEqualsShippingChanged += new BillingEqualsShippingChangedHandler(CreditCardModel_BillingEqualsShippingChanged);
                }
            }

            // registered payment data changed events
            foreach (var kvp in this.PaymentModel.PaymentMethods)
            {
                var method = kvp.Value;
                method.PaymentDataChanged += new PaymentDataChangedHandler(PaymentModel_PaymentDataChanged);
            }

            // Create payment views
            this.PaymentView.StringResourceProvider = this.StringResourceProvider;
            this.PaymentView.SetModel(this.PaymentModel);

            this.BillingAddressEditView = this.PaymentView.BillingAddressEditView;
            this.BillingAddressEditView.StringResourceProvider = this.StringResourceProvider;
            this.BillingAddressEditView.SetModel(this.AccountModel.BillingAddress);

            this.BillingAddressStaticView = this.PaymentView.BillingAddressStaticView;
            this.BillingAddressStaticView.StringResourceProvider = this.StringResourceProvider;
            this.BillingAddressStaticView.SetModel(this.AccountModel.BillingAddress);

            this.BillingAddressBookView = this.PaymentView.AddressBookView;
            this.BillingAddressBookView.StringResourceProvider = this.StringResourceProvider;
            this.BillingAddressBookView.SetModel(this.AccountModel);

            this.AccountModel.PrimaryShippingAddressChanged += new PrimaryShippingAddressChangedHandler(AccountModel_PrimaryShippingAddressChanged);
            this.AccountModel.PrimaryBillingAddressChanged  += new PrimaryBillingAddressChangedHandler(AccountModel_PrimaryBillingAddressChanged);

            this.CustomerServiceModel = modelFactory.CreateContentModel();
            this.CustomerServiceModel.LoadContext(Vortx.OnePageCheckout.Settings.ConfigurationProvider.DefaultProvider.CustomerServiceTopic);
            this.CustomerServicePanel.StringResourceProvider = this.StringResourceProvider;
            this.CustomerServicePanel.SetModel(this.CustomerServiceModel);
            this.CustomerServicePanel.Initialize();
            this.CustomerServicePanel.Show();
            this.CustomerServicePanel.BindView();

            // if billing equals shipping then copy the shipping address to the billing address
            // TODO: evaluate whether or not this logic is neccessary
            if (this.PaymentModel.ActivePaymentMethod != null)
            {
                if (this.PaymentModel.ActivePaymentMethod.PaymentType == PaymentType.CreditCard)
                {
                    if (this.CreditCardModel != null)
                    {
                        if (this.ShoppingCartModel.ShippingRequired && this.CreditCardModel.BillingEqualsShipping)
                        {
                            this.AccountModel.CopyShippingAddressToBilling();
                        }
                    }
                }
            }

            if (ConfigurationProvider.DefaultProvider.RequireTermsAndConditions)
            {
                IContentModel termsModel = modelFactory.CreateContentModel();
                termsModel.LoadContext(ConfigurationProvider.DefaultProvider.TermsAndConditionsTopicName);
                ContentPanelTerms.StringResourceProvider = this.StringResourceProvider;
                ContentPanelTerms.SetModel(termsModel);
                ContentPanelTerms.BindView();
            }

            if (!Page.IsPostBack)
            {
                this.InitializePage();

                string error = Request.QueryString["error"];
                if (error != null && error.Equals("true"))
                {
                    this.PaymentView.ShowError(StringResourceProvider.GetString("smartcheckout.aspx.130"));
                }

                Page.DataBind();
            }

            StylesheetLiteral.Text = "<link rel=\"stylesheet\" href=\"OPCControls/" + ConfigurationProvider.DefaultProvider.OPCStyleSheetName + "\" />";

            this.UpdatePanelOnePageCheckoutMain.Update();

            ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "registerBuySafeKickers", "try{WriteBuySafeKickers();}catch(err){}", true);
            if (ConfigurationProvider.DefaultProvider.BuySafeEnabled)
            {
                OPC_BuySafeWrap.Attributes.Add("style", "height:102px;");
            }
        }