/// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IDefaultPage page)
        {
            @"connecting...".ToDocumentTitle();

            page.Animation.Clear();


            page.Animation.style.marginTop = (JSCSolutionsNETWhiteCarouselCanvas.DefaultHeight / -2) +  "px";

            var c = new JSCSolutionsNETWhiteCarouselCanvas();
            
            c.CloseOnClick = false;
            c.Container.AttachToContainer(page.Animation);

            var IsStudio = Native.Document.location.hash.StartsWith("#/studio");

            Action  ActivateStudio =
                delegate
                {
                    page.PageContainer.Clear();
                    new StudioView(null).Content.AttachToDocument();
                };

            c.AtLogoClick +=
                delegate
                {
                    Native.Document.location.hash = "#/studio";
                    ActivateStudio();
                    //new Uri("http://www.jsc-solutions.net").NavigateTo();
                };

            new ApplicationWebService().WebMethod2("powered by ",
                e =>
                {
                    e.ToDocumentTitle();
                }
            );

            if (IsStudio)
                ActivateStudio();
        }
        public static void AnimateHomePage(this IDefault page)
        {
            var w = new JSCSolutionsNETWhiteCarouselCanvas();

            w.CloseOnClick = false;

            page.LogoContainer.Clear();

            var we = w.Container.ToHTMLElement();

            we.style.SetLocation((400 - 96) / -2, (400 - 96) / -2);

            page.LogoContainer.ReplaceContentWith(we);

            Action Deactivate = delegate { };
            Action Activate = null;

            Action<IHTMLAnchor, IHTMLElement> Bind =
                (Link, Content) =>
                {
                    Link.onmouseover +=
                       delegate
                       {
                           Deactivate();

                           if (Content == null)
                               Link.style.color = Color.Green;
                           else
                               Link.style.color = Color.Red;

                           Link.style.borderBottom = "2px solid red";
                       };

                    Link.onmouseout +=
                       delegate
                       {
                           Link.style.color = Color.Black;
                           Link.style.borderBottom = "";
                           Activate();
                       };

                    Action LinkDeactivate =
                         delegate
                         {
                             Link.style.borderBottom = "0px solid red";
                         };

                    Action LinkActivate =
                        delegate
                        {

                            Link.style.borderBottom = "2px solid red";
                        };

                    if (Activate == null)
                    {
                        Deactivate = LinkDeactivate;
                        Activate = LinkActivate;
                    }

                    if (Content != null)
                    {
                        Link.onclick +=
                          e =>
                          {
                              Deactivate();

                              Deactivate = LinkDeactivate;
                              Activate = LinkActivate;

                              Activate();

                              e.PreventDefault();

                              page.CurrentContent.ReplaceContentWith(Content);
                          };
                    }
                };

            Bind(page.HomeLink, page.HomeContent);
            Bind(page.AboutLink, page.AboutContent);
            Bind(page.VisionLink, page.VisionContent);
            Bind(page.ContactLink, page.ContactContent);
            Bind(page.DownloadLink, null);
        }
        private void XInitialize()
        {

            //this.Background = Brushes.Black;
            this.Background = Brushes.White;

            var b = new JSCSolutionsNETCarouselCanvas();

            b.CloseOnClick = false;
            b.Container.AttachTo(this);

            var bg_black = new Canvas
            {
                Background = Brushes.Black
            }.AttachTo(this);

            var bg_black_opacity = bg_black.ToAnimatedOpacity();

            bg_black_opacity.Opacity = 0;

            var w = new JSCSolutionsNETWhiteCarouselCanvas();

            w.CloseOnClick = false;
            w.Container.AttachTo(bg_black);

            bool OtherView = false;

            //new { b.step }.With(
            //    x =>
            //    {
            //        var counter = 0;

            //        (1000 / 60).AtIntervalWithTimer(
            //            speedboost =>
            //            {
            //                counter++;

            //                b.step = x.step * (1 + counter * 0.1);

            //                if (counter == 60 * 2)
            //                    speedboost.Stop();

            //            }
            //        );

            //    }
            //);



            Action ChooseView =
                delegate
                {

                    //V:\web\AvalonBrowserLogos\ApplicationCanvas___c__DisplayClass5.as(35): col: 36 Error: Implicit coercion of a value of type Boolean to an unrelated type Number.

                    //            if (!(((this.__4__this.Width > this.__4__this.Height) ^ this.OtherView) == 0))
                    //                                   ^

                    //V:\web\AvalonBrowserLogos\ApplicationCanvas___c__DisplayClass5.as(35): col: 74 Error: Implicit coercion of a value of type Boolean to an unrelated type Number.

                    //            if (!(((this.__4__this.Width > this.__4__this.Height) ^ this.OtherView) == 0))
                    //                                                                         ^


                    // X:\jsc.svn\examples\actionscript\Test\TestBooleanXor\TestBooleanXor\Class1.cs
                    // actionscript thinks this operator results in int?
                    //var flag = (Width > Height) ^ OtherView;
                    var flag = (Width > Height);

                    if (OtherView)
                        flag = !flag;

                    if (flag)
                        bg_black_opacity.Opacity = 0;
                    else
                        bg_black_opacity.Opacity = 1;
                };

            w.AtLogoClick +=
                delegate
                {
                    OtherView = !OtherView;

                    ChooseView();
                };

            b.AtLogoClick +=
                delegate
                {
                    OtherView = !OtherView;

                    ChooseView();

                };

            this.SizeChanged += (s, e) =>
            {
                ChooseView();

                w.Container.MoveTo(
                    (this.Width - 400) / 2, (this.Height - 400) / 2
                );

                b.Container.MoveTo(
                      (this.Width - 400) / 2, (this.Height - 400) / 2
                  );

                bg_black.SizeTo(this.Width, this.Height);
            };


        }