private void RegisterScrollToSelectedScript()
        {
            // http://www.developer.com/net/asp/article.php/3643956
            StringBuilder js = new StringBuilder();


            js.Append(" function ScrollToSelectedTreeNode()" + Environment.NewLine);
            js.Append("{ " + Environment.NewLine);
            js.Append("try " + Environment.NewLine);
            js.Append("{   " + Environment.NewLine);
            js.Append("var elem = document.getElementById('" + FolderTreeView.ClientID + "_SelectedNode');   " + Environment.NewLine);
            js.Append("if(elem != null )   " + Environment.NewLine);
            js.Append("{     " + Environment.NewLine);
            js.Append("var node = document.getElementById(elem.value);     " + Environment.NewLine);
            js.Append("if(node != null)     " + Environment.NewLine);
            js.Append("{       " + Environment.NewLine);
            js.Append("node.scrollIntoView(true); " + Environment.NewLine);
            // js.Append("Panel1.scrollLeft = 0;     "+Environment.NewLine);
            js.Append("}   " + Environment.NewLine);
            js.Append("} " + Environment.NewLine);
            js.Append("} " + Environment.NewLine);
            js.Append("catch(oException) " + Environment.NewLine);
            js.Append("{}" + Environment.NewLine);
            js.Append("}" + Environment.NewLine + Environment.NewLine);

            js.Append(CmsPageHeadSection.getOnloadJavascript("ScrollToSelectedTreeNode"));


            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ScrollToSelectedTreeNode", js.ToString(), true);
        }
        private void RegisterScrollToSelectedScript(TreeView treeView)
        {
            // http://www.developer.com/net/asp/article.php/3643956
            StringBuilder js = new StringBuilder();

            js.Append(" function ScrollToSelectedTreeNode()" + Environment.NewLine);
            js.Append("{ " + Environment.NewLine);
            js.Append("try " + Environment.NewLine);
            js.Append("{   " + Environment.NewLine);
            js.Append("var elem = document.getElementById('" + treeView.ClientID + "_SelectedNode');   " + Environment.NewLine);
            js.Append("if(elem != null )   " + Environment.NewLine);
            js.Append("{     " + Environment.NewLine);
            js.Append("var node = document.getElementById(elem.value);     " + Environment.NewLine);
            js.Append("if(node != null)     " + Environment.NewLine);
            js.Append("{       " + Environment.NewLine);
            js.Append("node.scrollIntoView(true); " + Environment.NewLine);
            // js.Append("Panel1.scrollLeft = 0;     "+Environment.NewLine);
            js.Append("}   " + Environment.NewLine);
            js.Append("} " + Environment.NewLine);
            js.Append("} " + Environment.NewLine);
            js.Append("catch(oException) " + Environment.NewLine);
            js.Append("{}" + Environment.NewLine);
            // -- add onclick events to all links

            /*
             * js.Append(" var links = document.getElementsByTagName('a');" + Environment.NewLine);
             * js.Append(" for(var i=0; i< links.length; i++) {" + Environment.NewLine);
             * js.Append("     if(links[i].href.indexOf('ToggleNode') >= 0) { continue; } " + Environment.NewLine);
             * js.Append("     links[i].addEventListener('click', function(){"+Environment.NewLine);
             * // js.Append("alert(this.href);" + Environment.NewLine);
             * js.Append("         var links = document.getElementsByTagName('a');" + Environment.NewLine);
             * js.Append("         for(var i=0; i< links.length; i++) {" + Environment.NewLine);
             * js.Append("             if (links[i].getAttribute('rel')) { links[i].removeAttribute('rel'); links[i].style.borderStyle = 'none'; break; }" + Environment.NewLine);
             * js.Append("         }" + Environment.NewLine);
             * js.Append("         this.rel = '1';" + Environment.NewLine);
             * js.Append("         this.style.border = '2px solid red';" + Environment.NewLine);
             *
             * js.Append("     }, false );" + Environment.NewLine);
             * js.Append(" }" + Environment.NewLine);
             */

            js.Append("}" + Environment.NewLine + Environment.NewLine);

            js.Append("function ckSelLink(url, linkEl) {" + Environment.NewLine);
            js.Append(" window.parent.CKEDITOR.dialog.getCurrent().setValueOf('info', 'url', encodeURI(url));" + Environment.NewLine);
            js.Append(" window.parent.CKEDITOR.dialog.getCurrent().setValueOf('target', 'linkTargetType', '_self');" + Environment.NewLine);
            js.Append("}" + Environment.NewLine + Environment.NewLine);



            js.Append(CmsPageHeadSection.getOnloadJavascript("ScrollToSelectedTreeNode"));


            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ScrollToSelectedTreeNode", js.ToString(), true);
        }