<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="MYAPP.Manage.Project.Area.index" %>
<%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<script language="JavaScript" type="text/javascript" src="/js/tdialog.js"></script>
<script language='JavaScript' type='text/javascript' src='/js/common.js'></script>
<script language="JavaScript" type="text/javascript" src="/js/odialog.js"></script>
<link href="/CSS/main.css" rel="stylesheet" type="text/css" />
<link href="splitterStyle.css" type="text/css" rel="stylesheet" />
<link href="treeStyle.css" type="text/css" rel="stylesheet" />
<title>Area</title>
<script language="JavaScript" type="text/javascript">
    var _Value = 0;
	var _NodeSelectTF = true;
    function nodeSelect(node)
    {
		if (_NodeSelectTF==true){
        _Value = node.GetProperty('Value');
    	switch (_Value.split("_")[0]) 
	    {
	        case "area": getmainFrame().location = "List_Area.aspx?Area_ID=" + _Value.split("_")[1]; break; 
		}
		}
    }

    function resizeTree(DomElementId, NewPaneHeight, NewPaneWidth) {
        TV_Tree.Render();
    }

    function Command_AddChildNode(_text, _value, _image, _up_value) {
        TV_Tree.beginUpdate();
        var newNode = new ComponentArt.Web.UI.TreeViewNode();
        newNode.set_text(_text);
        newNode.set_value(_value);
        newNode.set_imageUrl(_image);
        newNode.set_expanded(true);
        TV_Tree.findNodeByProperty("Value", _up_value).get_nodes().add(newNode);
        TV_Tree.endUpdate();
    }

    function Command_EditChildNode(_text, _value, _image, _up_value) {

        TV_Tree.beginUpdate();
        var newNode = TV_Tree.findNodeByProperty("Value", _value);
        if (_up_value == newNode.get_parentNode().get_value()) {
            newNode.set_text(_text);
            newNode.set_value(_value);
            newNode.set_imageUrl(_image);
        }
        else {
            TV_Tree.findNodeByProperty("Value", _value).remove();
            newNode.set_text(_text);
            newNode.set_value(_value);
            newNode.set_imageUrl(_image);
            newNode.set_expanded(true);
            TV_Tree.findNodeByProperty("Value", _up_value).get_nodes().add(newNode);
        }
        TV_Tree.endUpdate();
    }

    function Command_DelChildNode() {
        TV_Tree.get_selectedNode().remove();
    }


    function getmainFrame() {
        return mainFrame;
    }

function re_select()
{
	try
	{
	 TV_Tree.selectNodeById(_Value);
	 TV_Tree.findNodeById(_Value).expand(true);
	}catch(exception){}
}

function Command_EditChildNodeN(newNode,_name,_id,_expanded,_imageurl,_navurl,_target,_ShowCheckBox)
    {    
		newNode.set_id(_id);
		newNode.set_text(_name);
        newNode.set_value(_id);
        newNode.set_imageUrl(_imageurl);    
        newNode.set_expanded(_expanded);
        newNode.set_target(_target);
        newNode.set_navigateUrl(_navurl);
		newNode.setProperty("ShowCheckBox", _ShowCheckBox); 
    } 
	
function Command_AddChildNodeN(up_node,_name,_id,_expanded,_imageurl,_navurl,_target,_ShowCheckBox)
    {    
        var newNode = new ComponentArt.Web.UI.TreeViewNode(); 
		newNode.set_id(_id);
		newNode.set_text(_name);
        newNode.set_value(_id);
        newNode.set_imageUrl(_imageurl);    
        newNode.set_expanded(_expanded);
        newNode.set_target(_target);
        newNode.set_navigateUrl(_navurl);
		newNode.setProperty("ShowCheckBox", _ShowCheckBox); 
		newNode.set_selectable(true); 
        try
        {
            up_node.get_nodes().add(newNode);
        }
        catch(exception){up_node.add(newNode);}    
        return newNode;
    }      

function updateareatree()
{
    TV_Tree.beginUpdate();
    var newNode = TV_Tree.findNodeByProperty("Value", "area_");
    newNode.get_nodes().clear();
    var dr_area = AjaxDemo.Get_AreaTree().value;

    //默认分组
    var mNode = Command_AddChildNodeN(newNode, "[默认区域]", "area_-1", true, "", "", "", false);
    updateareatreenode(newNode, dr_area, "");
    TV_Tree.endUpdate();
}
function updateareatreenode(upNode, dr_area, upid)
{
    for (var i = 0; i < dr_area.length; i++)
	{
	    var dr = dr_area[i];
		if (dr.upid==upid)
		{
		    var newNode = Command_AddChildNodeN(upNode, dr.id + ":" + dr.name, "area_" + dr.id, true, "", "", "", false);
			updateareatreenode(newNode, dr_area, dr.id);
		}
	}
}

function _load()
{
	updateareatree();
}

function selectbyvalue(_value)
{
	_NodeSelectTF=false;
	try
	{
		 TV_Tree.selectNodeById(_value);
		 TV_Tree.findNodeById(_value).expand(true);
	}catch(exception){}
	_NodeSelectTF=true;
}
self.focus();
</script>
</head>
</head>
<body style="margin:0px; padding:0px; overflow-y:hidden; overflow-x:hidden"  onload="_load();">
<form id="theform" runat="server">
  <table width="100%" cellspacing="0" border="1" align="center" cellpadding="0" bordercolor="#CCCCCC"
            class="board_kong">
    <tr>
      <td><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="1">
          <tr>
            <td style="border-bottom: #CCCCCC 1px solid; height: 24px"><table class="title_table">
              <tr>
                <td class="l_title">[城市区域管理]</td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td valign="top"><ComponentArt:Splitter runat="server" ID="sp" FillHeight="true" FillWidth="true"
                                    ImagesBaseUrl="images/Splitter/">
                <Layouts>
                  <ComponentArt:SplitterLayout>
                    <Panes Orientation="Horizontal" SplitterBarCssClass="HorizontalSplitterBar" SplitterBarActiveCssClass="ActiveSplitterBar"
                                                SplitterBarWidth="5">
                      <ComponentArt:SplitterPane PaneContentId="TreeViewContent" Width="200" MinWidth="0"
                                                    ClientSideOnResize="resizeTree" CssClass="SplitterPane" />
                      <ComponentArt:SplitterPane>
                      <panes orientation="Vertical" splitterbarcollapseimageurl="splitter_verCol.gif" splitterbarcollapsehoverimageurl="splitter_verColHover.gif"
                                                        splitterbarexpandimageurl="splitter_verExp.gif" splitterbarexpandhoverimageurl="splitter_verExpHover.gif"
                                                        splitterbarcollapseimagewidth="116" splitterbarcollapseimageheight="5" splitterbarcssclass="VerticalSplitterBar"
                                                        splitterbarcollapsedcssclass="CollapsedVerticalSplitterBar" splitterbaractivecssclass="ActiveSplitterBar"
                                                        splitterbarwidth="5">
                        <ComponentArt:SplitterPane PaneContentId="MainContent" CssClass="SplitterPane" />
                      </panes>
                      </ComponentArt:SplitterPane>
                    </Panes>
                  </ComponentArt:SplitterLayout>
                </Layouts>
                <Content>
                  <ComponentArt:SplitterPaneContent id="TreeViewContent">
                    <ComponentArt:TreeView ID="TV_Tree" Height="100%" Width="100%" EnableViewState="false"
                                                ClientSideOnNodeSelect="nodeSelect" KeyboardEnabled="false" ShowLines="true"
                                                DisplayMargin="false" NodeCssClass="TreeNode" SelectedNodeCssClass="SelectedTreeNode"
                                                MultipleSelectedNodeCssClass="MultipleSelectedTreeNode" HoverNodeCssClass="HoverTreeNode"
                                                NodeEditCssClass="NodeEdit" CutNodeCssClass="CutTreeNode" MarginWidth="20" DefaultMarginImageWidth="24"
                                                DefaultMarginImageHeight="20" LineImageWidth="19" LineImageHeight="20" NodeLabelPadding="3"
                                                ParentNodeImageUrl="folders.gif" LeafNodeImageUrl="folder.gif" CollapseImageUrl="exp.gif"
                                                ExpandImageUrl="col.gif" ExpandCollapseImageWidth="19" ExpandCollapseImageHeight="20"
                                                ImagesBaseUrl="images/tree/" LineImagesFolderUrl="images/lines/" runat="server" CausesValidation="False" CollapseNodeOnSelect="False" MultipleSelectEnabled="False" ViewStateMode="Disabled" ExpandNodeOnSelect="False" ExpandSelectedPath="False"> </ComponentArt:TreeView>
                  </ComponentArt:SplitterPaneContent>
                  <ComponentArt:SplitterPaneContent id="MainContent">
                    <iframe src="List_Area.aspx?Area_ID=" id="mainFrame" name="mainFrame" width="100%" height="100%" 
                                                frameborder="0"></iframe>
                  </ComponentArt:SplitterPaneContent>
                </Content>
              </ComponentArt:Splitter></td>
          </tr>
        </table></td>
    </tr>
  </table>
</form>
</body>
</html>
