﻿
	    var type=null;
        var node=null;

        function correctSizes() {
            var box = document.getElementById('tabbarconteiner');
            box.style.height = (document.body.offsetHeight - 70) + 'px'
            if (_isIE && window.a_tabbar._tabZone) {
                a_tabbar._tabZone.style.position = (a_tabbar._tabZone.style.position == "relative") ? "" : "relative";
            }
            
            var box2 = document.getElementById('divContentBox');
            box2.style.height = document.documentElement.scrollHeight - 70;
              
        }

        /* init tree */
        var tree;
 
        function loadTree() {
            tree = new dhtmlXTreeObject("doctree_box", "100%", "100%", 0);
            tree.setImagePath("codebase/imgs/");
            tree.setOnClickHandler(function(id) { showContent(id); });
            tree.attachEvent("onOpenEnd", updateTreeSize);
            tree.enableCheckBoxes(false);
            tree.loadXML("xml/docs_tree.xml", autoselectNode);          
        }

        /* open path funtion */
        function showContent(id) {
            var itemno = tree.getUserData(id, "itemno");
            var urlid = tree.getUserData(id, "url");
            var appid = document.getElementById('hdinputAppID').value;
            
            if ( appid!="" && itemno!= null)
                WebSite.AppFormsService.GetFormItem(appid, itemno, showContentSucceed, genericFailure, "get");
            if (appid != "" && urlid != null)
                WebSite.AppFormsService.GetFormItem(appid, urlid, redirectUrl, genericFailure, "get");
        }
        // This is the callback function that
        // processes the Web Service return value.
        function showContentSucceed(result) {
            var div = window.frames.sampleframe.document.getElementById("divContent");
            div.innerHTML = result.text;

            try {
                var tables = window.frames.sampleframe.document.getElementsByTagName("table")[1];
                tables.width = "100%";
            }
            catch (e) { 
           }
           
        }
        function redirectUrl(result) {
            window.open(result.text, "mywindow", "location=1,toolbar= yes, menubar=yes,status=1,resizable=1,scrollbars=1,width=1020,height=760"); 

        }
        function genericFailure(error, context, operation) {
            alert(error.get_message());
        }
        function updateTreeSize() {
            this.allTree.style.overflow = "visible";
            if (_isOpera) this.allTree.style.marginBottom = "16px";
            this.allTree.style.height = "1px";
            this.allTree.style.height = this.allTree.scrollHeight + "px";
        }

        function autoselectNode() {
            if (type == "smpl") {
                tree_smpl.selectItem(node, true); tree_smpl.openItem(node)
            } else {
                tree.selectItem(node, true); tree.openItem(node)
            }
        }

       