protected void Page_Load(object sender, EventArgs e)
    {
        //Validate
        OrderId = PrgFunctions.TryCastInt(Request["order_id"], OrderId);
        OrderGuid = PrgFunctions.TryCastGuid(Request["order_guid"], OrderGuid);

        OrderDetail oDetail = null;

        if (OrderGuid != Guid.Empty)
        {
            try
            {
                oDetail = BusinessFlow.WebServices.Order.GetDetail(OrderGuid);
            }
            catch (Exception)
            {
                Response.Redirect(ResolveUrl("~/checkout/checkout_step2.aspx"));
            }
        }
        else if ((OrderId.ToString().Length > 2))
        {
            try
            {
                oDetail = BusinessFlow.WebServices.Order.GetDetail(OrderId.ToString());
            }
            catch (Exception)
            {
                Response.Redirect(ResolveUrl("~/checkout/checkout_step2.aspx"));
            }
        }
        else
        {
            Response.Redirect(ResolveUrl("~/checkout/checkout_step2.aspx"));
        }

        if ((oDetail == null) || (oDetail.OrderRow == null))
            Response.Redirect(ResolveUrl("~/checkout/checkout_step2.aspx"));

        //Save the IP
        PrgFunctions f = new PrgFunctions((MainStreet.BusinessFlow.SDK.Web.BusinessFlowWebContext)BusinessFlow.Context);
        string ip = f.GetIP();
        f.UpdateOrderAttribute(PrgFunctions.TryCastGuid(oDetail.OrderRow["order_guid"]), "IpAddress", ip);

        //Save the referer
        if ((Session != null) && (Session["UrlReferer"] != null) && (Session["UrlReferer"].ToString().Length!=0))
        {
            f.UpdateOrderAttribute(PrgFunctions.TryCastGuid(oDetail.OrderRow["order_guid"]), "UrlReferer", Session["UrlReferer"].ToString());
        }

        //Google Analytics
        string jsCode = buildGAJavaScript(oDetail);

        /* Valentin fixed we use google analitic in control
        if (jsCode.Length > 5)
        {
            HtmlGenericControl hgc2 = new HtmlGenericControl("script");
            hgc2.Attributes.Add("language", "javascript");
            hgc2.Attributes.Add("type", "text/javascript");
            hgc2.InnerHtml = jsCode;
            Page.Header.Controls.Add(hgc2);

            jsCode = string.Empty;
        }
         */
         jsCode = string.Empty;

        //Nextopia
        jsCode = buildNXTJavaScript(oDetail);

        if (jsCode.Length > 5)
        {
            HtmlGenericControl hgc3 = new HtmlGenericControl("script");
            hgc3.Attributes.Add("language", "javascript");
            hgc3.Attributes.Add("type", "text/javascript");
            hgc3.InnerHtml = jsCode;
            Page.Header.Controls.Add(hgc3);
        }

        //Commision Junction
        jsCode = buildCommissionJunctionScript(oDetail);

        if (jsCode.Length > 5)
        {
            Output = jsCode;
        }
    }