<%@ page contentType="text/html;charset=gbk" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="java.util.*" %>
<%@ include file="sessionInfo2.jsp"%>
<%
  strSkin_SESSION = "../../images/skin2_blue2";
%>
<html>
<body>
<head>
<TITLE>数飞表单引擎-编辑界面</TITLE>
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
<style type="text/css">
  img{vertical-align: text-bottom ;} 

  .readClass {
      background:#D4D0C8;
      readonly;
  }
  .selectClass {
      width:70;
  }  
  .trMouseOver {
      background:#F6F6F4;
      cursor:hand;
  }
  .trMouseOut {
      background:#FFFFFF;
      cursor:none;
  }
  .trMouseDown {
      background:#A6F6F4;
      cursor:hand;
  }
  
.btnImg {
    cursor: hand;
}
.btnImgOver {
    cursor: hand;
    BORDER-RIGHT: #C0C0C0 1px solid; 
    BORDER-TOP: #C0C0C0 1px solid;  
    BORDER-LEFT: #C0C0C0 1px solid;  
    BORDER-BOTTOM: #C0C0C0 1px solid;    
}


.tool_01 {
    width: 10px;
    height: 30px;
    background-image:  url(../../images/share2/form/tool_01.gif);
}
.tool_02 {
    height: 30px;
    width: 70px;
    background-image:  url(../../images/share2/form/tool_02.gif);
}
.tool_03 {
    width: 10px;
    height: 30px;
    background-image:  url(../../images/share2/form/tool_03.gif);
}

.tool_11 {
    width: 10px;
    height: 30px;
    background-image:  url(../../images/share2/form/tool_11.gif);
}
.tool_12 {
    height: 30px;
    width: 70px;
    background-image:  url(../../images/share2/form/tool_12.gif);
}
.tool_13 {
    width: 10px;
    height: 30px;
    background-image:  url(../../images/share2/form/tool_13.gif);
}

.tool_21 {
    width: 10px;
    height: 20px;
    background-image:  url(../../images/share2/form/tool_21.gif);
}
.tool_22 {
    height: 20px;
    width: 70px;
    background-image:  url(../../images/share2/form/tool_22.gif);
}
.tool_23 {
    width: 10px;
    height: 20px;
    background-image:  url(../../images/share2/form/tool_23.gif);
}

.line_img {
    height: 5px;
}

.line_img2 {
    height: 2px;
}
  
  
</style>
<script src="../../share/mootools/mootools-core.js" type="text/javascript"></script>
<script src="../../share/mootools/mootools-more.js" type="text/javascript"></script>
<script type="text/javascript">  
  //保存几个工具div的名称
  var divArray = new Array("divProperties", "divMain", "divTableTools", "divObjectTools");

  var divPropertiesTop = 0;
  var divTableToolsTop = 0;
  var divObjectToolsTop = 0;  
  //参数为选中的div：把选中的div.zIndex设置为99，保证为最大。其他的逐个减一。
  function changeDivIndex(vDiv) {
    //var vDiv = event.target;
    var oDiv = null;
    var vLen = divArray.length;
    for (var v=0; v<vLen; v++) {
      oDiv = $(divArray[v]);
      if (oDiv == null) {
      	continue;
      }
  	  if (divArray[v] == vDiv) {
  	    oDiv.style.zIndex = "99";
  	  } else {
  	    oDiv.style.zIndex = oDiv.style.zIndex - 1;
  	  }
    } //for
  }  //function changeDivIndex

//mootools,domready
window.addEvent('domready', function() {

    var mouseOver = function(event) {
      event.target.className="btnImgOver";
    }

    var mouseOut = function(event) {
      event.target.className="btnImg";
    }
  	
	var divFlow = $("divFlow");		
	var divProperties = $("divProperties");	
	var divPropertiesHandle = $("divPropertiesHandle");	
	
	var propsDrag = new Drag.Move(divProperties, { 
	    //设置需要拖动的div
		droppables: divProperties,
	    //container: divFlow,
		//某个位置才可以拖动	
		handle: divPropertiesHandle,
		onDrop: function(el, dr) { 
       		divPropertiesTop = parseInt(divProperties.style.top); 
    	}			
			
	}); //var toolsDrag = new Drag.Move(dragElement, {	
			
    var propClose = function() {
      divProperties.style.display="none";	
    }
    var propOpen = function() {
      divProperties.style.display="";	
      changeDivIndex("divProperties");
    }  	
	var p_close = $("p_close");	
	p_close.addEvent("mouseover", mouseOver);
	p_close.addEvent("mouseout", mouseOut);    
    //属性关闭event
    p_close.addEvent("click", propClose);
    //divProperties增加点中event
    //注释掉2012-01-11
    //divProperties.addEvent("click", function() {changeDivIndex("divProperties")} );       
    
    //////////////divTableTools方面	
	var divTableTools = $("divTableTools");	
	var divTableToolsHandle = $("divTableToolsHandle");		    

	var tableToolsDrag = new Drag.Move(divTableTools, { 
	    //设置需要拖动的div
		droppables: divTableTools,
	    //container: divFlow,
		//某个位置才可以拖动	
		handle: divTableToolsHandle,

		onDrop: function(el, dr) { 
       		divTableToolsTop = parseInt(divTableTools.style.top); 
    	}						
	}); //var toolsDrag = new Drag.Move(dragElement, {	
  
    var tableClose = function() {
      divTableTools.style.display="none";	
    }
    var tableOpen = function() {
      divTableTools.style.display="";	
      changeDivIndex("divTableTools");
    }  	
	var t_close = $("t_close");	
	t_close.addEvent("mouseover", mouseOver);
	t_close.addEvent("mouseout", mouseOut);    
    //属性关闭event
    t_close.addEvent("click", tableClose);	    	
    //注释掉2012-01-11
    //divTableTools.addEvent("click", function() {changeDivIndex("divTableTools")} );    
  
    //////////////divObjectTools方面	
	var divObjectTools = $("divObjectTools");	
	var divObjectToolsHandle = $("divObjectToolsHandle");		    

	var objectToolsDrag = new Drag.Move(divObjectTools, { 
	    //设置需要拖动的div
		droppables: divObjectTools,
	    //container: divFlow,
		//某个位置才可以拖动	
		handle: divObjectToolsHandle,	
		
		onDrop: function(el, dr) { 
       		divObjectToolsTop = parseInt(divObjectTools.style.top); 
    	}	
	}); //var toolsDrag = new Drag.Move(dragElement, {	
  
    var objectClose = function() {
      divObjectTools.style.display="none";	
    }
    var objectOpen = function() {
      divObjectTools.style.display="";	
      changeDivIndex("divObjectTools");
    }  	
	var o_close = $("o_close");	
	o_close.addEvent("mouseover", mouseOver);
	o_close.addEvent("mouseout", mouseOut);    
    //属性关闭event
    o_close.addEvent("click", objectClose);	    	
    ////注释掉2012-01-11
    //divObjectTools.addEvent("click", function() {changeDivIndex("divObjectTools")} );  
    
    //////////////main方面	
	var divMain = $("divMain");	
	var divMainHandle = $("divMainHandle");		    

	var mainDrag = new Drag.Move(divMain, { 
	    //设置需要拖动的div
		droppables: divMain,
	    //container: divFlow,
		//某个位置才可以拖动	
		handle: divMainHandle			
	}); //var toolsDrag = new Drag.Move(dragElement, {	
      	
    
    divMain.addEvent("click", function() {changeDivIndex("divMain")} );    
    
    var o_open = $("o_open");
    var t_open = $("t_open");
    var p_open = $("p_open");
    
    o_open.addEvent("mouseover", mouseOver);
    o_open.addEvent("mouseout", mouseOut);  
    o_open.addEvent("click", objectOpen);
    
    t_open.addEvent("mouseover", mouseOver);
    t_open.addEvent("mouseout", mouseOut);
    t_open.addEvent("click", tableOpen);
         
    p_open.addEvent("mouseover", mouseOver);
    p_open.addEvent("mouseout", mouseOut);  
    p_open.addEvent("click", propOpen);   
    
    var o_open1 = $("o_open1");
    var t_open1 = $("t_open1");
    var p_open1 = $("p_open1");
    
    o_open1.addEvent("mouseover", mouseOver);
    o_open1.addEvent("mouseout", mouseOut);  
    o_open1.addEvent("click", objectOpen);
    
    t_open1.addEvent("mouseover", mouseOver);
    t_open1.addEvent("mouseout", mouseOut);
    t_open1.addEvent("click", tableOpen);
         
    p_open1.addEvent("mouseover", mouseOver);
    p_open1.addEvent("mouseout", mouseOut);  
    p_open1.addEvent("click", propOpen);     
    
    var o_open2 = $("o_open2");
    var t_open2 = $("t_open2");
    var p_open2 = $("p_open2");
    
    o_open2.addEvent("mouseover", mouseOver);
    o_open2.addEvent("mouseout", mouseOut);  
    o_open2.addEvent("click", objectOpen);
    
    t_open2.addEvent("mouseover", mouseOver);
    t_open2.addEvent("mouseout", mouseOut);
    t_open2.addEvent("click", tableOpen);
         
    p_open2.addEvent("mouseover", mouseOver);
    p_open2.addEvent("mouseout", mouseOut);  
    p_open2.addEvent("click", propOpen);   
    
    var o_open3 = $("o_open3");
    var t_open3 = $("t_open3");
    var p_open3 = $("p_open3");
    
    o_open3.addEvent("mouseover", mouseOver);
    o_open3.addEvent("mouseout", mouseOut);  
    o_open3.addEvent("click", objectOpen);
    
    t_open3.addEvent("mouseover", mouseOver);
    t_open3.addEvent("mouseout", mouseOut);
    t_open3.addEvent("click", tableOpen);
         
    p_open3.addEvent("mouseover", mouseOver);
    p_open3.addEvent("mouseout", mouseOut);  
    p_open3.addEvent("click", propOpen);             
    
    //object
    var object01 = $("object01");
    object01.addEvent("mouseover", mouseOver);
    object01.addEvent("mouseout", mouseOut); 
    var object02 = $("object02");
    object02.addEvent("mouseover", mouseOver);
    object02.addEvent("mouseout", mouseOut); 
    var object03 = $("object03");
    object03.addEvent("mouseover", mouseOver);
    object03.addEvent("mouseout", mouseOut); 
    var object04 = $("object04");
    object04.addEvent("mouseover", mouseOver);
    object04.addEvent("mouseout", mouseOut); 
    var object05 = $("object05");
    object05.addEvent("mouseover", mouseOver);
    object05.addEvent("mouseout", mouseOut); 
    var object06 = $("object06");
    object06.addEvent("mouseover", mouseOver);
    object06.addEvent("mouseout", mouseOut); 
    var object07 = $("object07");
    object07.addEvent("mouseover", mouseOver);
    object07.addEvent("mouseout", mouseOut); 
    var object08 = $("object08");
    object08.addEvent("mouseover", mouseOver);
    object08.addEvent("mouseout", mouseOut);                 
    var object09 = $("object09");
    object09.addEvent("mouseover", mouseOver);
    object09.addEvent("mouseout", mouseOut);  
    var object10 = $("object10");
    object10.addEvent("mouseover", mouseOver);
    object10.addEvent("mouseout", mouseOut); 
    var object11 = $("object11");
    object11.addEvent("mouseover", mouseOver);
    object11.addEvent("mouseout", mouseOut); 
    var object12 = $("object12");
    object12.addEvent("mouseover", mouseOver);
    object12.addEvent("mouseout", mouseOut); 
    var object13 = $("object13");
    object13.addEvent("mouseover", mouseOver);
    object13.addEvent("mouseout", mouseOut); 
    var object14 = $("object14");
    object14.addEvent("mouseover", mouseOver);
    object14.addEvent("mouseout", mouseOut); 
    var object15 = $("object15");
    object15.addEvent("mouseover", mouseOver);
    object15.addEvent("mouseout", mouseOut);  
    //var object16 = $("object16");
    //object16.addEvent("mouseover", mouseOver);
    //object16.addEvent("mouseout", mouseOut);
    var object17 = $("object17");
    object17.addEvent("mouseover", mouseOver);
    object17.addEvent("mouseout", mouseOut);
    //var object18 = $("object18");
    //object18.addEvent("mouseover", mouseOver);
    //object18.addEvent("mouseout", mouseOut); 
    /*   
    var object19 = $("object19");
    object19.addEvent("mouseover", mouseOver);
    object19.addEvent("mouseout", mouseOut);        
    var object20 = $("object20");
    object20.addEvent("mouseover", mouseOver);
    object20.addEvent("mouseout", mouseOut);
    var object21 = $("object21");
    object21.addEvent("mouseover", mouseOver);
    object21.addEvent("mouseout", mouseOut);
    */    
    var table01 = $("table01");
    table01.addEvent("mouseover", mouseOver);
    table01.addEvent("mouseout", mouseOut);    
  
    var table02 = $("table02");
    table02.addEvent("mouseover", mouseOver);
    table02.addEvent("mouseout", mouseOut); 
    
    var table03 = $("table03");
    table03.addEvent("mouseover", mouseOver);
    table03.addEvent("mouseout", mouseOut); 

    var table11 = $("table11");
    table11.addEvent("mouseover", mouseOver);
    table11.addEvent("mouseout", mouseOut); 
    var table12 = $("table12");
    table12.addEvent("mouseover", mouseOver);
    table12.addEvent("mouseout", mouseOut);
    var table13 = $("table13");
    table13.addEvent("mouseover", mouseOver);
    table13.addEvent("mouseout", mouseOut);
    var table14 = $("table14");
    table14.addEvent("mouseover", mouseOver);
    table14.addEvent("mouseout", mouseOut);
    var table15 = $("table15");
    table15.addEvent("mouseover", mouseOver);
    table15.addEvent("mouseout", mouseOut); 
    var table16 = $("table16");
    table16.addEvent("mouseover", mouseOver);
    table16.addEvent("mouseout", mouseOut);
    var table17 = $("table17");
    table17.addEvent("mouseover", mouseOver);
    table17.addEvent("mouseout", mouseOut);
    var table18 = $("table18");
    table18.addEvent("mouseover", mouseOver);
    table18.addEvent("mouseout", mouseOut);            
    var table19 = $("table19");
    table19.addEvent("mouseover", mouseOver);
    table19.addEvent("mouseout", mouseOut); 
    var table20 = $("table20");
    table20.addEvent("mouseover", mouseOver);
    table20.addEvent("mouseout", mouseOut);
    var table21 = $("table21");
    table21.addEvent("mouseover", mouseOver);
    table21.addEvent("mouseout", mouseOut);
    var table22 = $("table22");
    table22.addEvent("mouseover", mouseOver);
    table22.addEvent("mouseout", mouseOut);
    var table23 = $("table23");
    table23.addEvent("mouseover", mouseOver);
    table23.addEvent("mouseout", mouseOut);
    var table24 = $("table24");
    table24.addEvent("mouseover", mouseOver);
    table24.addEvent("mouseout", mouseOut);
    var table25 = $("table25");
    table25.addEvent("mouseover", mouseOver);
    table25.addEvent("mouseout", mouseOut);
                                     
}) //window.addEvent('domready', function() {
</script>

</head>
<%
    //是否支持关联多表单，
    int iRelateMult = SzProperties.SYS_FORM_RELATEMULT;
    String moduleName = SzConvert.strWriteData(request.getParameter("moduleName"));
    String formName = SzConvert.strWriteData(request.getParameter("formName"));

    BdForm bdForm = new BdForm();
    //获取表单的名称
    BdFormInfo bdFormInfo = null;
    bdFormInfo = bdForm.getFormInfo(moduleName, formName);

    //获取表的名称
    String tableName = bdForm.getTableStr(moduleName, formName);
    String prefix = bdFormInfo.getPrefix();

    //读取表格
    Collection collTable = null;
    //读取HTML文件
    Collection collField = null;
    String sHtml = "";
    if (moduleName != "" && formName != "") {
        sHtml = bdForm.getHtml(moduleName, formName);
        //获取表格arrayLit
        collTable = bdForm.getTableList(moduleName, formName);

        //获取字段arraList
        collField = bdForm.getFieldList(moduleName, formName);
    }
    
    BdFormControl formControl = new BdFormControl();
		boolean isFormEngine = formControl.isFormEngine(moduleName);    
%>
<form name="formUpdate" method="post" action="formSave.jsp">
<input type="hidden" name="OPERATOR" value="">
<input type="hidden" name="prefix" value="<%=prefix%>">
<div id="divFlow" style="position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:1100;">
  <!-- divProperties 放属性 -->
  <div id="divProperties" style="position:absolute; top:0px; left:0px; width:320px; z-index:5"> 
      <table border=0 cellpadding=0 cellspacing=0 height="30" id="divPropertiesHandle"  onmouseover="this.style.cursor='move'">  
        <tr><td class="tool_01"></td>
        <td class="tool_02" style="width:240;" valign="middle">
          <table border="0" width="100%" cellpadding="1" cellspacing="0">
            <tr>
              <td><img src="../../images/share2/form/prop.gif">&nbsp;属性</td>
              <td  align="right">
                <img src="../../images/share2/form/prop.gif"  id="p_open1" title="打开属性窗体">
                <img src="../../images/share2/form/table.gif" id="t_open1" title="打开表格操作窗体">
                <img src="../../images/share2/form/tool2.gif"  id="o_open1" title="打开控件操作窗体">
              	<img src="../../images/share2/form/close.gif" id="p_close" onmouseover="this.style.cursor='hand'">                                    
              </td>
            </tr>
          </table> 
        </td>
        <td class="tool_03"></td></tr>
      </table>
      
      <table border=0 cellpadding=0 cellspacing=0 height="50">  
        <tr><td class="tool_11"></td>
        <td class="tool_12" style="width:240;" valign="top">
          <table border="0" width="100%">
            <tr><td colspan="2" align="center">
   <div id="divHidden"  style="display:none;">
  表格数量：<input type="text" name="tableCount" value="0">
  行数量：<input type="text" name="rowCount" value="<%=bdFormInfo.getRowCount()%>">
  列数量：<input type="text" name="cellCount" value="<%=bdFormInfo.getCellCount()%>">
  控件数量：<input type="text" name="objectCount" value="0">
  表ID：<input type="text" name="tableId" value="0">  
  行ID：<input type="text" name="rowId" value="0">
  列ID：<input type="text" name="cellId" value="0">
  测试：<input type="text" name="test" value="">
  表单内容<textarea name="formHtml"></textarea>
  表单控件<div id="formObjectName">

  </div>
  </div>
  <input type="button" class="btnClass100" value="保存表单内容" onClick="SaveTable();">
  <input type="button" class="btnClass100" value="关闭" onClick="CloseWindow();"> 
               </td>
             </tr>
             <tr>
               <td colspan="2">  
  				模块名称<input type="text" size="23" class="readClass" name="moduleName" value="<%=moduleName%>" readonly>
               </td>
             </tr>
             <tr>
               <td colspan="2">    
  				表单名称<input type="text" size="23" class="readClass" name="formName" value="<%=formName%>" readonly>
               </td>
             </tr>
             <tr>
               <td colspan="2">    
  表格类型<input type="text" size="13" name="tableType" value="" class="readClass" readonly>
  <% if (iRelateMult == 1) { %>
        <input type="checkbox" name="tableMain" value="1" title="当表单拆分为两张数据表存储的时候，才需要选上">主表
  <% } else { %>
        <input type="hidden" name="tableMain" value="0"  title="当表单拆分为两张数据表存储的时候，才需要选上">
  <% } %>
               </td>
             </tr>             
             <tr>
               <td colspan="2"><img src="../../images/share2/form/line1.gif" class="line_img" width="220"></td>
             </tr>  
             
                       
             <tr <% if (!isFormEngine) { out.println("style='display:none;'"); }%>>
               <td colspan="2">
  数据表名<input type="text" size="22" name="tableName" value="" onChange="javascript:SetTableProperty2();">
               </td>
             </tr>

             <tr <% if (!isFormEngine) { out.println("style='display:none;'"); }%>>
               <td colspan="2">    
  主键名称<input type="text" size="8" name="keyName" value="" class="readClass"  readonly>
  外键<input type="text" size="8" name="foreignName" value="" class="readClass"  readonly>
               </td>
             </tr>
             <tr <% if (!isFormEngine) { out.println("style='display:none;'"); }%>>
               <td colspan="2" align="center"> 
 <input type="button" value="保存数据表设置" onClick="SetTableProperty();"; class="btnClassLong" style="display:none;"> 
                </td>
             </tr>
             <tr <% if (!isFormEngine) { out.println("style='display:none;'"); }%>>
               <td colspan="2"><img src="../../images/share2/form/line1.gif" class="line_img" width="220"></td>
             </tr> 
             <tr <% if (!isFormEngine) { out.println("style='display:none;'"); }%>>
               <td colspan="2">   
      字段类型<%
     String type_str[] = {"int","nvarchar","numeric","ntext"};
     out.println(SzPageHelp.idSelectArrayFunc(type_str,type_str,"objectFieldType","","selectClass","javascript:SetObjectProperty();")); 
     %>                
      控件ID<input type="text" name="objectId"   value=""  size="5" class="readClass" readonly>    

               </td>
             </tr>
             <tr <% if (!isFormEngine) { out.println("style='display:none;'"); }%>>
               <td colspan="2">             
      字段名称<input type="text" name="objectField" value="" size="22" onChange="javascript:SetObjectProperty();">
               </td>
             </tr>
      
             <tr>
               <td colspan="2">       
      字段说明<input type="text" name="objectName"  value="" size="22" onChange="javascript:SetObjectProperty();">      
               </td>
             </tr>
             <tr>
               <td colspan="2">   
      控件名称<input type="text" name="objectType"  value="" size="8" class="readClass" readonly>               
       <select name="objectClass" style="width:90;" onChange="javascript:SetObjectProperty();">
            <option value="">控件样式</option>
            <option value="0">去掉样式</option>
            <option value="greyClass">greyClass</option>
            <option value="txtClassPage">txtPage30px</option>
            <option value="txtClass50">txt50px</option>
            <option value="txtClass80">txt80px</option>
            <option value="txtClass100">txt100px</option>
            <option value="txtClass120">txt120px</option>
            <option value="txtClass140">txt140px</option>            
            <option value="txtClass1">txt1-150px</option>
            <option value="txtClass200">txt200px</option>   
            <option value="txtClass250">txt250px</option>  
            <option value="txtClass300">txt300px</option>  
            <option value="txtClass350">txt350px</option>                                               
            <option value="txtClass2">txt2-450px</option>
            <option value="areaClass50">area50px</option>
            <option value="areaClass80">area80px</option>
            <option value="areaClass100">area100px</option>
            <option value="areaClass120">area120px</option>
            <option value="areaClass140">area140px</option>
            <option value="areaClass200">area200px</option>   
            <option value="areaClass250">area250px</option>  
            <option value="areaClass300">area300px</option>  
            <option value="areaClass350">area350px</option>             
            <option value="areaClass1">area1-150px</option>
            <option value="areaClass2">area2-450px</option>
          </select>  

               </td>
             </tr>             
             <tr>
               <td colspan="2">       
       红色星号[<a href="#" OnClick="javascript:AddRedStart();">追加</a>
       <a href="#" OnClick="javascript:RemoveRedStart();">去掉</a>]
		</td>
	     </tr>
             <tr>
               <td colspan="2">   
       背景颜色       
	<select name="backcolor" style="width:60;" OnChange="javascript:SetBackColor();">
	  <option value="">====</option>
	  <option value="#FFFFFF">默认白色</option>
	  <option value="#000000">黑色</option>
	  <option value="#EEEAEA">灰色</option>
	  <option value="blue">蓝色</option>
	  <option value="red">红色</option>
        </select>
		</td>
	     </tr>
             <tr>
               <td colspan="2">   
       字体颜色
	<select name="fontcolor" style="width:60;" OnChange="javascript:SetFontColor();">
		<option value="">====</option>
	  <option value="#211C1A">默认黑色</option>
	  <option value="#FFFFFF">白色</option>
	  <option value="#EEEAEA">灰色</option>
	  <option value="blue">蓝色</option>
	  <option value="red">红色</option>
	</select>
			</td>
	</tr>
  <tr>
      <td colspan="2">   
       字体大小	
	<select name="fontsize" style="width:60;" OnChange="javascript:SetFontSize();">
	  <option value="">====</option>
	  <option value="13">默认13</option>
	  <option value="10">10</option>
	  <option value="16">16</option>
	  <option value="20">20</option>
	  <option value="23">23</option>
        </select>
      加粗
	<select name="fontbold" style="width:60;" OnChange="javascript:SetFontBold();">
	  <option value="">====</option>
	  <option value="yes">粗体</option>
	  <option value="no">普通</option>
        </select>      
		</td>
	</tr>
  <tr>	
     <td colspan="2"> 
       <% if (isFormEngine) { %>
       [<a href="#" OnClick="javascript:History();">表单修改的历史记录</a>]
       <% } %>       
               </td>
             </tr>             
             <tr>
               <td colspan="2" align="center">
      <input type="button" value="保存控件设置" onClick="SetObjectProperty();";  class="btnClassLong" style="display:none;">                                               
			   </td>
             </tr> 
             <tr>
               <td colspan="2"><img src="../../images/share2/form/line1.gif" class="line_img" width="220"></td>
             </tr>                
             <tr>
               <td height="24">
               <img src="../../images/share2/form/table_20.gif" onClick="UserAlignLeft();" id="table20"></td>

               <td height="24">
               <img src="../../images/share2/form/table_21.gif" onClick="UserAlignCenter();" id="table21"></td>
             </tr>
             <tr>
               <td height="24">
               <img src="../../images/share2/form/table_22.gif" onClick="UserAlignRight();" id="table22"></td>

               <td height="24">
               <img src="../../images/share2/form/table_23.gif" onClick="UserValignTop();" id="table23"></td>
             </tr>
             <tr>
               <td height="24">
               <img src="../../images/share2/form/table_24.gif" onClick="UserValignMiddle();" id="table24"></td>

               <td height="24">
               <img src="../../images/share2/form/table_25.gif" onClick="UserValignBottom();" id="table25"></td>
             </tr>                                                                       
                                                                                                         
           </table>
        </td>
        <td class="tool_13"></td></tr>
      </table>   
      <table border=0 cellpadding=0 cellspacing=0>  
        <tr><td class="tool_21"></td>
        <td class="tool_22"  style="width:240;">&nbsp;</td>  
        <td class="tool_23"></td></tr>
      </table>              
  </div>
  
  <div id="divMain" style="position:absolute; top:0px; left:270px;  z-index:2">  
      <table border=0 cellpadding=0 cellspacing=0 height="30" id="divMainHandle"  onmouseover="this.style.cursor='move'">  
        <tr><td class="tool_01"></td>
        <td class="tool_02" style="width:770;" valign="middle">
          <table border="0" width="100%" cellpadding="1" cellspacing="0">
            <tr>
              <td><b>表单设计主窗体</b></td>
              <td  align="right">
                <img src="../../images/share2/form/prop.gif"  id="p_open" title="打开属性窗体">
                <img src="../../images/share2/form/table.gif" id="t_open" title="打开表格操作窗体">
                <img src="../../images/share2/form/tool2.gif"  id="o_open" title="打开控件操作窗体">             
              </td>
            </tr>
          </table> 
        </td>
        <td class="tool_03"></td></tr>
      </table>
      
      <table border=0 cellpadding=0 cellspacing=0 height="600">  
        <tr><td class="tool_11"></td>
        <td class="tool_12" style="width:770;" valign="top">
          <table border="0" width="100%">
     	    <tr>
              <td height="600" id="idHtml" valign="top" bgcolor="#FFFFFF"><%=sHtml%></td>
            </tr>                                                                                                                 
           </table>
        </td>
        <td class="tool_13"></td></tr>
      </table>   
      <table border=0 cellpadding=0 cellspacing=0>  
        <tr><td class="tool_21"></td>
        <td class="tool_22"  style="width:770;">&nbsp;</td>
 
        <td class="tool_23"></td></tr>
      </table>  
  </div>   
  <div id="divTableTools" style="position:absolute; top:0px; left:0px; width:320px; z-index:6">
      <table border=0 cellpadding=0 cellspacing=0 height="30" id="divTableToolsHandle"  onmouseover="this.style.cursor='move'">  
        <tr><td class="tool_01"></td>
        <td class="tool_02" style="width:240;" valign="middle">
          <table border="0" width="100%" cellpadding="1" cellspacing="0">
            <tr>
              <td><img src="../../images/share2/form/table.gif">&nbsp;表格操作</td>
              <td  align="right">
                <img src="../../images/share2/form/prop.gif"  id="p_open2" title="打开属性窗体">
                <img src="../../images/share2/form/table.gif" id="t_open2" title="打开表格操作窗体">
                <img src="../../images/share2/form/tool2.gif"  id="o_open2" title="打开控件操作窗体">             
              	<img src="../../images/share2/form/close.gif" id="t_close" onmouseover="this.style.cursor='hand'"></td>
            </tr>
          </table> 
        </td>
        <td class="tool_03"></td></tr>
      </table>
      
      <table border=0 cellpadding=0 cellspacing=0 height="384">  
        <tr><td class="tool_11"></td>
        <td class="tool_12" style="width:240;" valign="top">
          <table border="0" width="100%">
             <tr>
               <td  align="left">指定表格的行列数</td>
               <td align="left">
                   <input type="text" name="TableRows" size="3" value="4">行
     			   <input type="text" name="TableCells" size="3" value="4">列
     		   </td>
             </tr>     
             <tr>
               <td align="left" height="24">
                <img src="../../images/share2/form/table_01.gif" onClick="AddTable();" id="table01">  
			  			 </td>
               <td  align="left" height="24">
                <img src="../../images/share2/form/table_02.gif" onClick="AddTableDetail();" id="table02">	   
			   </td>
             </tr>                
             <tr>
               <td colspan="2" align="left" height="24">
                <img src="../../images/share2/form/table_03.gif" onClick="DeleteTable();" id="table03">	   
			   </td>
             </tr> 
             <tr>
               <td colspan="2"><img src="../../images/share2/form/line1.gif" class="line_img" width="220"></td>
             </tr>                                    
             <tr>
               <td  height="24">
                <img src="../../images/share2/form/table_11.gif" onClick="UserInsertRow();" id="table11">
               </td>
               <td height="24">
               <img src="../../images/share2/form/table_12.gif" onClick="UserAddRow();" id="table12">
               </td>
             </tr> 
             <tr>
               <td  height="24">
               <img src="../../images/share2/form/table_13.gif" onClick="UserInsertCell();" id="table13"></td>
               <td  height="24">
               <img src="../../images/share2/form/table_14.gif" onClick="UserAddCell();" id="table14"></td>
             </tr>             
             <tr>
               <td  height="24">
               <img src="../../images/share2/form/table_15.gif" onClick="UserInsertLeftCell();" id="table15"></td>
               <td  height="24">
               <img src="../../images/share2/form/table_16.gif" onClick="UserInsertRightCell();" id="table16"></td>
             </tr>  
             <tr>
               <td colspan="2" height="24">
               <img src="../../images/share2/form/table_19.gif" onClick="UserDeleteRow();" id="table19"></td>
             </tr>              
             <tr>
               <td colspan="2"><img src="../../images/share2/form/line1.gif" class="line_img" width="220"></td>
             </tr>                           
             <tr>
               <td  height="24">
               <img src="../../images/share2/form/table_17.gif" onClick="UserMergeLeft();" id="table17"></td>

               <td height="24">
               <img src="../../images/share2/form/table_18.gif" onClick="UserMergeRight();" id="table18"></td>
             </tr>       
             <tr>
               <td colspan="2">
               <img src="../../images/share2/form/line1.gif" class="line_img" width="220"></td>
             </tr>                          
             
             <tr>
               <td >列&nbsp;宽:<input type="text" name="cellWidth" value="" size="5">%</td>

               <td  height="24"><input type="button" value="调整单元格宽度" onClick="SetCellWidth();" class="btnClass100"></td>
             </tr>   
                                                                                                                       <tr>
               <td colspan="2" align="center" height="24">
								<input type="button" value="自动匹配字段说明" onClick="AutoSetFieldDesc();";  class="btnClassLong">
			   </td>
             </tr> 
           </table>
        </td>
        <td class="tool_13"></td></tr>
      </table>   
      <table border=0 cellpadding=0 cellspacing=0>  
        <tr><td class="tool_21"></td>
        <td class="tool_22"  style="width:240;">&nbsp;</td>
  
        <td class="tool_23"></td></tr>
      </table>    
  </div>
 
  <div id="divObjectTools" style="position:absolute; top:0px; left:0px; width:320px; z-index:5">  
      <table border=0 cellpadding=0 cellspacing=0 height="30" id="divObjectToolsHandle"  onmouseover="this.style.cursor='move'">  
        <tr><td class="tool_01"></td>
        <td class="tool_02" style="width:240;" valign="middle">
          <table border="0" width="100%" cellpadding="1" cellspacing="0">
            <tr>
              <td><img src="../../images/share2/form/tool2.gif">&nbsp;控件操作</td>
              <td  align="right">
                <img src="../../images/share2/form/prop.gif"  id="p_open3" title="打开属性窗体">
                <img src="../../images/share2/form/table.gif" id="t_open3" title="打开表格操作窗体">
                <img src="../../images/share2/form/tool2.gif"  id="o_open3" title="打开控件操作窗体">        
              <img src="../../images/share2/form/close.gif" id="o_close" onmouseover="this.style.cursor='hand'"></td>
            </tr>
          </table> 
        </td>
        <td class="tool_03"></td></tr>
      </table>
      
      <table border=0 cellpadding=0 cellspacing=0 height="384">  
        <tr><td class="tool_11"></td>
        <td class="tool_12" style="width:240;" valign="top">
          <table border="0" width="100%">   
             <tr>
               <td colspan="4" align="center" height="24">               
     			文字<input type="text" value="" name="textName" size="13" OnKeyDown="javascript:currentTextKeyDown();">
			   </td>
			   			 
             </tr>    
              <tr>
               <td colspan="2" align="center" height="24">     			
     			<img src="../../images/share2/form/object_01.gif" onClick="AddText();" id="object01">
			   </td>
               <td colspan="2" align="center" height="24">
     			<img src="../../images/share2/form/object_15.gif" onClick="AddHiddenKey();" id="object15">
			   </td>
             </tr> 
             <tr>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_02.gif" onClick="AddInput();" id="object02">
			   </td>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_14.gif" onClick="AddTextArea();" id="object14">     			
			   </td>
             </tr> 
             <tr>
               <td colspan="4"><img src="../../images/share2/form/line1.gif" class="line_img" width="200"></td>
             </tr>              
             <tr>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_03.gif" onClick="AddTime();" id="object03">  
			   </td>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_04.gif" onClick="AddCurrentTime();" id="object04">  
			   </td>
             </tr> 
             <tr>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_05.gif" onClick="AddDateObject();" id="object05">  
			   </td>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_06.gif" onClick="AddTimeObject();" id="object06">  
			   </td>
             </tr> 
             <tr>
               <td colspan="4"><img src="../../images/share2/form/line1.gif" class="line_img" width="200"></td>
             </tr>              
             <tr>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_07.gif" onClick="AddUserName();" id="object07">  
			   </td>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_17.gif" onClick="AddDepartName();" id="object17"> 
			   </td>
             </tr>   
             <!--                                                                                                                    
             <tr>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_18.gif" onClick="AddDepartID();" id="object18"><br>
                </td>
             </tr> 

             <tr>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_19.gif" onClick="AddDepartID();" id="object19"><br>
                </td>
             </tr>  
             <tr>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_20.gif" onClick="AddDepartID();" id="object20"><br>
                </td>
             </tr>  
             <tr>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_21.gif" onClick="AddDepartID();" id="object21"><br>
                </td>
             </tr>  
             -->  
             <!-- 
             <tr>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_16.gif" onClick="AddUserID();" id="object16"> 
			   </td>
             </tr>
              -->                         
             <tr>
               <td colspan="4"><img src="../../images/share2/form/line1.gif" class="line_img" width="200"></td>
             </tr>             
             <tr>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_11.gif" onClick="AddRadio();" id="object11"> 
			   </td>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_12.gif" onClick="AddCheck();" id="object12"> 
			   </td>
             </tr>
             <tr>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_10.gif" onClick="AddSelect();" id="object10"> 
			   </td>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_08.gif" onClick="AddWin();" id="object08"> 
			   </td>
             </tr>
             <tr>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_09.gif" onClick="AddWin2();" id="object09"> 
			   </td>
							<td colspan="2" align="center" height="24">&nbsp;</td>			   
             </tr>
                          
             <tr>
               <td colspan="4"><img src="../../images/share2/form/line1.gif" class="line_img" width="200"></td>
             </tr>              
             <tr>
               <td colspan="2" align="center" height="24">
                <img src="../../images/share2/form/object_13.gif" onClick="RemoveAll();" id="object13"> 
			   </td>
               <td colspan="2" align="center" height="24">
     			<input type="button" value="改变只读属性" onClick="javascript:SetObjectReadOnly()";  class="btnClass100">
			   </td>
             </tr>  
                                                                                                                                                                     
           </table>
        </td>
        <td class="tool_13"></td></tr>
      </table>   
      <table border=0 cellpadding=0 cellspacing=0>  
        <tr><td class="tool_21"></td>
        <td class="tool_22"  style="width:240;">&nbsp;</td>
  
        <td class="tool_23"></td></tr>
      </table>   
  </div> 

</div>
</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript">
  //监控是否已经修改
  var editFlag = "false";

  //将控件的ID自动加一。
  //增加一个数组，记录obj的数量，名字
  var objectArray = new Array();
  //控件ID，字段名称，字段说明，所属表名，控件类型(数字，表示控件类型)，字段类型
  objectArray[0] = new Array("","","","","","");

  //初始化的时候使用。
  function addObject(vObjectId, vField, vName, vTableId, vType, vFieldType) {
    if (vType == "") {
      vType = "";
    }
    var vObjectCount = formUpdate.objectCount.value;
    if (vObjectCount == "") {
      vObjectCount = "0";
    }
    var iObjectCount = parseInt(vObjectCount) + 1;
    formUpdate.objectCount.value = iObjectCount;
    objectArray[iObjectCount] = new Array(vObjectId, vField, vName, vTableId, vType, vFieldType);
  }
  //
  function getObjectTypeName(vType) {
  	var vName = "";
  	var iType = parseInt(vType);
	switch(iType) {
		case 0:
			vName = "普通text";
			break; 
		case 1:
			vName = "普通hidden";
			break;
		case 2:
			vName = "本人姓名";
			break;
		case 3:
			vName = "本人ID";
			break;	
		case 51:
			vName = "自动流水编号";
			break;	
		case 33:
			vName = "本人部门名称";
			break;
		case 34:
			vName = "本人部门ID";
			break;
		case 4:
			vName = "创建时间";
			break;	
		case 44:
			vName = "当前时间";
			break;
		case 42:
			vName = "日期控件";
			break;
		case 43:
			vName = "时间控件";
			break;
		case 7:
			vName = "textarea";
			break;
		case 31:
			vName = "radio单选";
			break;
		case 32:
			vName = "check多选";
			break;	
		case 133:
			vName = "select单选";
			break;						
	}
	return vName;
  }

  function getNewObjectCount(vType) {
    var prefix = formUpdate.prefix.value;
    if (vType == "") {
      vType = "0";
    }

    var vObjectCount = formUpdate.objectCount.value;
    if (vObjectCount == "") {
      vObjectCount = "0";
    }
    var iObjectCount = parseInt(vObjectCount) + 1;
    formUpdate.objectCount.value = iObjectCount;

	//控件ID
    var vId    = prefix + "XXID" + iObjectCount;
    //字段名称
    var vField = prefix + "XXMC" + iObjectCount; 
    //字段说明
    var vDesc  = prefix + "XXSM" + iObjectCount;
    
    if (vType == "2") {
      vDesc = "本人姓名";
    } else if (vType == "3") {
      vDesc = "本人ID";
    } else if (vType == "33") {
      vDesc = "本人部门";
    } else if (vType == "34") {
      vDesc = "本人部门ID";    
    } else if (vType == "4") {
      vDesc = "创建时间";
    } else if (vType == "44") {
      vDesc = "当前时间";    
    } else if (vType == "42") {
      vDesc = "日期选择";
    } else if (vType == "43") {
      vDesc = "时间选择";
    }
    
    
    //当增加一个控件的时候，也记录这个表的ID
    var vTableId = formUpdate.tableId.value;
    objectArray[iObjectCount] = new Array(vId, vField, vDesc, vTableId, vType, "");
    formUpdate.objectId.value    = vId;
    formUpdate.objectField.value = vField;
    formUpdate.objectName.value  = vDesc;
    formUpdate.objectType.value  = getObjectTypeName(vType);
    formUpdate.objectFieldType.value = "";
    return vId;
  }
  //取得在数组中的index
  function getObjectIndex(vId) {
    var vIndex = -1;
    var vCount = objectArray.length;
    for (var i = 0; i< vCount; i++ ) {
      if (objectArray[i] == null) {
        continue;
      }
      if (objectArray[i][0] == vId) {
        vIndex = i;
        break;
      }
    }
    return vIndex;  
  }
  //根据控件ID取得字段中文名
  function getObjectName(vId) {
    var vName = "";
    var vIndex = getObjectIndex(vId);
    if (vIndex >-1) {
      vName = objectArray[vIndex][2];
    }
    return vName;
  }
  //根据控件ID取得字段名称
  function getObjectField(vId) {
    var vName = "";
    var vIndex = getObjectIndex(vId);
    if (vIndex >-1) {
      vName = objectArray[vIndex][1];
    }
    return vName;
  }
  //根据控件ID取得字段类型
  function getObjectType(vId) {
    var vType = "";
    var vIndex = getObjectIndex(vId);
    if (vIndex >-1) {
      vType = objectArray[vIndex][4];
    }
    //根据vType
    var vName = getObjectTypeName(vType);
    return vName;  
  }
  //根据控件ID取得字段类型
  function getObjectFieldType(vId) {
    var vType = "";
    var vIndex = getObjectIndex(vId);
    if (vIndex >-1) {
      vType = objectArray[vIndex][5];
    }
    return vType;  
  }  
  
  //改变数组里字段名、中文名、
  function setObjectName(vId, vField, vName) {
    var vCount = objectArray.length;
    var iIndex = 0;

    for (var i = 0; i< vCount; i++ ) {
      if (objectArray[i] == null) {
        continue;
      }
      //已经存在字段名，返回
      if (objectArray[i][0] != vId && objectArray[i][1] == vField) {
          iIndex = "-1";
          break;
      }
      if (objectArray[i][0] == vId) {
        iIndex = i;
      }
    }
    if (iIndex == -1) {
      alert("字段名称已经存在，请重新设置");
      return false;
    } else {
      objectArray[iIndex][1] = vField;
      objectArray[iIndex][2] = vName;
      return true;
    } // if else
  } //function setObjectName()

  //改变数组里字段名
  function setObjectNameOnly(vId, vName) {
    var vCount = objectArray.length;
    var iIndex = 0;

    for (var i = 0; i< vCount; i++ ) {
      if (objectArray[i] == null) {
        continue;
      }
      if (objectArray[i][0] == vId) {
        iIndex = i;
        break;
      }
    }
    if (iIndex == -1) {
      return false;
    } else {
      objectArray[iIndex][2] = vName;
      return true;
    } // if else
  } //function setObjectName()

  function removeObject(vId) {
    editFlag = "true";  
    var vCount = objectArray.length;
    for (var i = 0; i< vCount; i++ ) {
      if (objectArray[i] == null) {
        continue;
      }
      if (objectArray[i][0] == vId) {
        objectArray[i][0] = vId;  //
        objectArray[i][1] = "";
        objectArray[i][2] = "";
        objectArray[i][3] = "";
        objectArray[i][4] = "";
        objectArray[i][5] = "";
        objectArray[i][6] = "";
        break;
      }
    }
  }

  //表格的数组
  var tableArray = new Array();
  tableArray[0] = new Array("","","","","","",""); //tableId，表名，主键，外键，类名，类型（0普通表；1多行明细表）, （0为普通表；1为主表） 
  var v = "";
  function addTableArray(vTableId, vTableName, vKey, vForeign, vTableClass, vType, vMain) {
    var vTableCount = formUpdate.tableCount.value;
    if (vTableCount == "") {
      vTableCount = "0";
    }
    var iTableCount = parseInt(vTableCount) + 1;
    formUpdate.tableCount.value = iTableCount;
    tableArray[iTableCount] = new Array(vTableId, vTableName, vKey, vForeign, vTableClass, vType, vMain);
  }
  
  //2008-12-04,用AJAX获取最新的表名
  function getNewTableName() { 
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	var checkresult=null; 
	var vMessageWin = null;  
	xmlhttp.open("POST", "getTable_action.jsp", false); 
	//xmlhttp.onreadystatechange = updatePage; 
		xmlhttp.send(null); 
		
	var response = xmlhttp.responseText;
	var vIndex = response.indexOf("SZFORMtable");	
	var vTable = "SZFORMtable"; 
	if (vIndex >0) {
	    var vIndex1 = response.indexOf("SzEnd");
	    vTable = response.substring(vIndex, vIndex1);
	}
	xmlhttp.abort();
	return vTable;
  }  
  
  //2009-08-27增加，获得表的名称
  function getNewTableName2(vType, vTableId) { 
    var moduleName = formUpdate.moduleName.value;
    var vLen = moduleName.length;
    //moduleName = moduleName.substring(vLen - 4, vLen);
    if (vLen > 4 && moduleName.substring(vLen - 4, vLen) == ".xml") {
	    moduleName = moduleName.substring(0, vLen - 4);
    }
    var formName = formUpdate.formName.value;
      
	var vTable = "BD_" + moduleName + "_" + formName;
	if (vType == "1") {
		vTable += "_DETAIL" + "_" + vTableId;
	} 	
	//2010-02-01增加转大写，相应XML表名也转大写。
	vTable = vTable.toUpperCase();
	return vTable;
  }    

  //当增加一个表格的时候，调用这个方法，返回表格table的ID
  function getNewTableId(vType) {
    editFlag = "true";  
    var vTableCount = formUpdate.tableCount.value;
    if (vTableCount == "") {
      vTableCount = "0";
    }
    var iTableCount = parseInt(vTableCount) + 1;
    //var vTableId = "SZFORMtable" + iTableCount;
    var vTableId = getNewTableName();
    //2009-10-05可以增加多个明细表格
    //之前的算法：只有一个主表、一个明细表；所以根据类型取得表名
    //表名不存在，就调用getNewTableName2生成新的表名
    var vTableName = getMainTableName(vTableId, vType);  
    if (vType == "1" && vTableName != "") {
      //明细表单已经存在一个
      return "";
    }  
    if (vTableName == "") {
		//vTableName = vTableId;
		vTableName = getNewTableName2(vType, vTableId);
    } 
    
    var vTableClass = "";

    formUpdate.tableCount.value = iTableCount;
    formUpdate.tableId.value = vTableId;
    tableArray[iTableCount] = new Array(vTableId, vTableName, "", "", vTableClass, vType, "0");

    return vTableId;
  }
  
  //从数组里取已经设置好的表名
  function getMainTableName(vId, vType) {
	var vCount = tableArray.length;
	var vName = "";
    for (var i = 0; i< vCount; i++ ) {    
      if (tableArray[i] == null) {
        continue;
      }
      //如果是主表就直接取，如果是明细表同时判断ID
      
      if (vType == "0" && tableArray[i][5] == vType) {
        vName = tableArray[i][1];
        break;
      } else if (vType == "1" && tableArray[i][5] == vType && tableArray[i][0] == vId) {
        vName = tableArray[i][1];
        break;
      }      
	} //for	
	return vName;
  }
  
  //根据tableid获取在数组中的index
  function getTableIndex(vId) {
    var vCount = tableArray.length;
    var iIndex = -1;
    //检查table name是否已经存在
    for (var i = 0; i< vCount; i++ ) {
      if (tableArray[i] == null) {
        continue;
      }
      if (tableArray[i][0] == vId) {
        iIndex = i;
        break;
      }
	}	
	return iIndex;
  }  
  
  //根据tableid获取名称
  function getTableName(vId) {
    var vName = "";
    var vIndex = getTableIndex(vId);
    if (vIndex >=0) {
	  vName = tableArray[vIndex][1];
    }
    return vName;
  }
  //根据tableid获取类
  function getTableClass(vId) {
    var vName = "";
    var vIndex = getTableIndex(vId);
    if (vIndex >=0) {
	  vName = tableArray[vIndex][4];
    }
    return vName;
  }
  //表类型
  function getTableType(vId) {
    var vName = "";
    var vIndex = getTableIndex(vId);
    if (vIndex >=0) {
	  vName = tableArray[vIndex][5];
    }
    return vName;
  }
  //表类型名称
  function getTableTypeName(vType) {
    var vName = "";
    if (vType == "0") {
      vName = "普通表单";
    } else if (vType == "1") {
      vName = "明细表单";
    }
    return vName;
  }
  //主键
  function getTableKey(vId) {
    var vName = "";
    var vIndex = getTableIndex(vId);
    if (vIndex >=0) {
	  vName = tableArray[vIndex][2];
    }
    return vName;
  }
  //外键
  function getTableForeign(vId) {
    var vName = "";
    var vIndex = getTableIndex(vId);
    if (vIndex >=0) {
	  vName = tableArray[vIndex][3];
    }
    return vName;
  }
  //根据tableId，设置属性
  function setTableInfo(vId) {
    var vIndex = getTableIndex(vId);
    
    if (vIndex >=0) {
      formUpdate.tableName.value = tableArray[vIndex][1];
      //formUpdate.tableClass.value = getTableClass(eleTemp.id);
      formUpdate.tableType.value = getTableTypeName(tableArray[vIndex][5]);
      formUpdate.keyName.value = tableArray[vIndex][2];
      formUpdate.foreignName.value = tableArray[vIndex][3];
      if ( tableArray[vIndex][5] == 1) {
        //明细表
        formUpdate.tableMain.checked = false;
        formUpdate.tableMain.disabled = true;
      } else {
        formUpdate.tableMain.disabled = false;
        if (tableArray[vIndex][6] == "1") {
          formUpdate.tableMain.checked = true;
        } else {
          formUpdate.tableMain.checked = false;
        }
      }
    }
  }

  function setTableName(vId, vName) {
    editFlag = "true";  
    //tableId，表名，主键，外键，类名，类型0主表；1多行明细表
    var vType = getTableType(vId);
    var vCount = tableArray.length;
    var iIndex = 0;
    //检查table name是否已经存在
    for (var i = 0; i< vCount; i++ ) {
      if (tableArray[i] == null) {
        continue;
      }
      if (tableArray[i][5] != vType && tableArray[i][1] == vName) {
        alert("表名已经存在");
        iIndex = "-1";
        break;
      }
    }
    if (iIndex == "-1") {
    	return;
    }
    for (var i = 0; i< vCount; i++ ) {
      if (tableArray[i] == null) {
        continue;
      }  
      if (tableArray[i][5] == vType) {
        tableArray[i][1] = vName;
      }        
    }        
  }
  
  //修改vMain一样的数据表
  function setTableName2(vId, vName, vMain) {
    editFlag = "true";  
    //tableId，表名，主键，外键，类名，类型0主表；1多行明细表
    var vType = getTableType(vId);
    //如果是明细表，则类型一定不是主表
    if (vType == "1") {
      vMain = "0";      
    }
    var vCount = tableArray.length;
    var iIndex = 0;
    //检查table name是否已经存在
    for (var i = 0; i< vCount; i++ ) {
      if (tableArray[i] == null) {
        continue;
      }
      //判断明细表和普通表不能同名
      if (tableArray[i][5] != vType && tableArray[i][1] == vName) {
        alert("表名已经存在");
        iIndex = "-1";
        break;
      }
    }
    if (iIndex == "-1") {
    	return;
    }    
    for (var i = 0; i< vCount; i++ ) {
      if (tableArray[i] == null) {
        continue;
      }
      //修改ID一样的表名
      if (tableArray[i][0] == vId) {
        tableArray[i][1] = vName;
        tableArray[i][6] = vMain;
      }             
      //修改类型一样，而且vMain一样的表。
      if (tableArray[i][5] == vType && tableArray[i][6] == vMain) {
        tableArray[i][1] = vName;
        tableArray[i][6] = vMain;
      }        
    }        
  }  
    
  //将关键字ID加进table数组中
  function AddTableKey(vTableId, vKey) {
  	//获取tableIndex
  	var vIndex = getTableIndex(vTableId);  	
  	//设置//tableId，表名，主键，外键，类名，类型0主表；1多行明细表
  	if (vIndex > -1) {
		tableArray[vIndex][2] = vKey;
  	}
  }

  //将外键ID加进table数组中
  function AddTableForeign(vTableId, vKey) {
  	//获取tableIndex
  	var vIndex = getTableIndex(vTableId);  	
  	//设置//tableId，表名，主键，外键，类名，类型0主表；1多行明细表
  	if (vIndex > -1) {
		tableArray[vIndex][3] = vKey;
  	}
  }

  function removeTableArray(vId) {
    editFlag = "true";  
    var vCount = tableArray.length;
    for (var i = 0; i< vCount; i++ ) {
      if (tableArray[i] == null) {
        continue;
      }
      if (tableArray[i][0] == vId) {
        tableArray[i][0] = vId; //保留这个信息，可以在保存XML时删除这个table
        tableArray[i][1] = "";
        tableArray[i][2] = "";
        tableArray[i][3] = "";
        tableArray[i][4] = "";
        tableArray[i][5] = "";
        tableArray[i][6] = "";
        break;
      }
    }
  }
  //需要对tableArray进行初始化

  //自动匹配字段中文;
  function AutoSetFieldDesc() {
    editFlag = "true";  
    //每一行检查table,读取第一个列的文本意思，写到第二个列控件的中文意思。
    //表格循环,tableId，表名，主键，外键，类名，类型0主表；1多行明细表
    var vCount = tableArray.length;
    var oTable = null;
    var vRowCount = 0;
    var oRow = null;
    var vCellCount = "";
    var oCell = null;
    var vObject = "";
    var i = 0;
    var j = 0;
    var k = 0;
    var m = 0;
    var iLenObject = 0;
    //先做普通表单
    for (i = 0; i< vCount; i++ ) {
      if (tableArray[i] == null) {
        continue;
      }
      if (tableArray[i][0] == "" || tableArray[i][5] == 1) {
        continue;
      }
    
      //获取表格
      oTable = document.getElementById(tableArray[i][0]);
      if (oTable == null) {
        continue;
      }
    
      //获取该table的行
      vRowCount = oTable.rows.length;
      
      for (j=0; j < vRowCount; j++) {
        oRow = oTable.rows[j];
        //该行有多少列；
        vCellCount = oRow.cells.length;
        
        //20080902增加判断k < vCellCount - 1，否则单列的时候会出错
        for (k=0; k < vCellCount && k < vCellCount - 1; k = k + 2) {
          oCell = oRow.cells[k];
          //取的文字
          vText = oCell.innerText;
          //取得控件
          
          oCell = oRow.cells[k + 1];
          iLenObject = oCell.childNodes.length;
          //20080902修改，当一行里有checkbox,radio时，需要做循环才能获取控件ID
          for (m = 0; m<iLenObject; m++ ) {
            vObject = oCell.childNodes[m];
            if (vObject != null && vObject.id != null && vObject.id.indexOf("XXID") != -1) {
          		setObjectNameOnly(vObject.id, vText);  
          		break;      
        	} 
          }//for m

        } //for k
      } //for j
    } //for i
    
    //检查明细表单
    for (i = 0; i< vCount; i++ ) {   
      if (tableArray[i] == null) {
        continue;
      }
      if (tableArray[i][0] == "" || tableArray[i][5] == 0) {
        continue;
      }
    
      //获取表格
      oTable = document.getElementById(tableArray[i][0]);
      if (oTable == null) {
        continue;
      }
      
      //明细表单只有3行
      vRowCount = oTable.rows.length;
      if (vRowCount != 2) {
		continue;
      }
      oRow = oTable.rows[0]; 
      vCellCount = oRow.cells.length;
      for (k=0; k < vCellCount; k++) {
        //第一行取得text
		oCell = oTable.rows[0].cells[k];
		vText = oCell.innerText;
		//第二行取得控件
		oCell = oTable.rows[1].cells[k];
		vObject = oCell.childNodes[0];
        if (vObject != null && vObject.id != null && vObject.id.indexOf("XXID") != -1) {
        	setObjectNameOnly(vObject.id, vText);        
        } 
      }  
    } 
  } //function AutoSetFieldDesc() ends
  
  //当点控件的时候，显示出该控件的属性
  function setObjectProperty(vId) {
    if (vId != "") {    
      formUpdate.objectId.value = vId;
      formUpdate.objectField.value = getObjectField(formUpdate.objectId.value);
      formUpdate.objectName.value = getObjectName(formUpdate.objectId.value);
      formUpdate.objectType.value = getObjectType(formUpdate.objectId.value);
      formUpdate.objectFieldType.value = getObjectFieldType(formUpdate.objectId.value);
    } else {
      formUpdate.objectId.value = "";
      formUpdate.objectField.value = "";
      formUpdate.objectName.value = "";
      formUpdate.objectType.value = "";
      formUpdate.objectFieldType.value = "";    
    }  
  }
  
<%
    Iterator iterTable = null;
	Iterator iterField = null;
	BdFormTableInfo bdFormTableInfo = null;
	BdFormFieldInfo bdFormFieldInfo = null;

	if (collTable != null) {
        iterTable = collTable.iterator();
    }    

    String sKey = "";
    String sForeignKey = "";
    while (iterTable != null && iterTable.hasNext()) {
        bdFormTableInfo = (BdFormTableInfo)iterTable.next();
        //找出对应的主键,外健
        sKey = "";
        sForeignKey = "";
        if (collField != null) {
            iterField = collField.iterator();
        }        
       	while (iterField != null && iterField.hasNext()) {
        	bdFormFieldInfo = (BdFormFieldInfo)iterField.next();
        	if (bdFormFieldInfo.getTableName().equals(bdFormTableInfo.getGLBM())) {
        		if (bdFormFieldInfo.getZDZT() == 2) {
        			sKey = bdFormFieldInfo.getZDMC();
        		}
        		if (bdFormFieldInfo.getZDZT() == 4) {
        			sForeignKey = bdFormFieldInfo.getZDMC();
        		}
        	}
       	}
%>
        addTableArray("<%=bdFormTableInfo.getGLID()%>",
                      "<%=bdFormTableInfo.getGLBM()%>",
                      "<%=sKey%>",
                      "<%=sForeignKey%>",
                      "<%=bdFormTableInfo.getGLLM()%>",
                      "<%=bdFormTableInfo.getGLLX()%>",
                      "<%=bdFormTableInfo.getGLZB()%>");
<%
    }
%>
  //使用collField对objectArray进行初始化
<%
	if (collField != null) {
    	iterField = collField.iterator();
	}
    while (iterField != null && iterField.hasNext()) {
        bdFormFieldInfo = (BdFormFieldInfo)iterField.next();
        //System.out.println("bdFormFieldInfo.getZDBJ==" + bdFormFieldInfo.getZDBJ());
%>
        addObject("<%=bdFormFieldInfo.getZDID()%>",
                  "<%=bdFormFieldInfo.getZDMC()%>",
                  "<%=bdFormFieldInfo.getZDSM()%>",
                  "<%=bdFormFieldInfo.getTableId()%>",
                  "<%=bdFormFieldInfo.getZDBJ()%>",
                  "<%=bdFormFieldInfo.getZDLX()%>");
<%
    }
%>
    //要把最大的tableCount,objectCount放进来。
    formUpdate.tableCount.value = "<%=bdFormInfo.getTableCount()%>";
    formUpdate.objectCount.value = "<%=bdFormInfo.getObjectCount()%>";
</script>

<script language="javascript">
//===================鼠标的各种方法
  //===============================一下为鼠标的over,out,down,up方法。
  //鼠标放上去的时候，捕捉table,tr,td的ID
  var elePrioTdOver = null; //记录上一个ele的id


  ///当鼠标在上面的时候,这里获取当前鼠标的坐标。
  //如果按下箭头的时候，先判断坐标是不是在表格上
  var currentX2 = 0;
  var currentY2 = 0;

  function OverElement() {
    currentX2 = 0;
    currentY2 = 0;

    if (event.srcElement.id.indexOf("SZFORM") != -1) {
      event.srcElement.style.cursor = "hand";
      currentX2 = (event.clientX + document.body.scrollLeft);
      currentY2 = (event.clientY + document.body.scrollTop);
    }
    var ele = event.srcElement;
    var eleTemp = null;

    //获取cellId
    eleTemp = ele;
    while (eleTemp.id.indexOf("SZFORMtd") == -1) {
      eleTemp = eleTemp.parentElement;
      if (eleTemp == null) {
        break;
      } //if ends
    } // while ends
    if (elePrioTdOver != null) {
    }
    if (eleTemp != null) {
      elePrioTdOver = eleTemp;
    }


  } //function OverElement end

  var elePrioTableDown = null; //记录table，交换的时候要检查是否在同一个table
  var elePrioTdDown = null; //记录上一个ele的id

	
  //2009-8-29需要修复：当点中单元格的时候，文字不能聚焦。
  function ClickElement() {

    if (event.srcElement.id.indexOf("SZFORM") != -1) {
      event.srcElement.style.cursor = "hand";
    }
    var ele = event.srcElement;
    var eleTemp = null;

    //获取tableID
    eleTemp = ele;
    while (eleTemp.id.indexOf("SZFORMtable") == -1) {
      eleTemp = eleTemp.parentElement;
      if (eleTemp == null) {
        break;
      } //if ends
    } // while ends
    
    if (eleTemp != null && eleTemp.id.indexOf("SZFORMtable") == 0) {      
      //ken，焦点放到text中
      formUpdate.textName.focus();

      formUpdate.tableId.value = eleTemp.id;
      elePrioTableDown = eleTemp;
      //根据表格ID获取表的名称
      /*
      formUpdate.tableName.value = getTableName(eleTemp.id);
      //formUpdate.tableClass.value = getTableClass(eleTemp.id);
      formUpdate.tableType.value = getTableTypeName(getTableType(eleTemp.id));
      formUpdate.keyName.value = getTableKey(eleTemp.id);
      formUpdate.foreignName.value = getTableForeign(eleTemp.id);
      */
      setTableInfo(eleTemp.id);
    }

    //获取rowId
    eleTemp = ele;
    while (eleTemp.id.indexOf("SZFORMtr") == -1) {
      eleTemp = eleTemp.parentElement;
      if (eleTemp == null) {
        break;
      } //if ends
    } // while ends
    if (eleTemp != null) {
      formUpdate.rowId.value = eleTemp.id;
    }

    //增加隐含控件的判断和显示
    //获取cellId
    eleTemp = ele;
    while (eleTemp.id.indexOf("divSZFORMtable") == -1) {
      eleTemp = eleTemp.parentElement;
      
      if (eleTemp == null) {
        break;
      } //if ends
    } // while ends
    //2009-08-27增加，解决选中div隐藏行时，删除不掉表格的问题。
	if (eleTemp != null && eleTemp.id.indexOf("divSZFORMtable") == 0) {
	  //取得对应table的id
	  var vId = eleTemp.id;
	  vId = vId.substring(3, vId.length);
      formUpdate.tableId.value = vId;
      elePrioTableDown = document.getElementById(vId);
      //根据表格ID获取表的名称
      /*
      formUpdate.tableName.value = getTableName(vId);
      //formUpdate.tableClass.value = getTableClass(vId);
      formUpdate.tableType.value = getTableTypeName(getTableType(vId));
      formUpdate.keyName.value = getTableKey(vId);
      formUpdate.foreignName.value = getTableForeign(vId);
      */
      setTableInfo(vId);	  	  
	}
	 
    if (eleTemp != null) {

      if (elePrioTdDown != null) {
        //判断这个td是不是明细的第一行，如果是，就不执行这个out动作
        elePrioTdDown.className = "trMouseOut";
      }
      var vLength = eleTemp.childNodes.length;
      if (vLength == 1) { //只有一个控件，直接显示该控件
        var oChild = eleTemp.childNodes[0];
        if (oChild != null && oChild.id != null && oChild.id.indexOf("XXID") != -1) {
          setObjectProperty(oChild.id);         
        } else {
          setObjectProperty("");
        }
      } else {  //当有多个控件的时候，只有点到该控件才显示
        if (ele != null && ele.id != null && ele.id.indexOf("XXID") != -1) {
          setObjectProperty(ele.id); 
        } else {
          setObjectProperty("");
        }
      }//if (vLength == 1) ends
    } // if (eleTemp != null) ends

    //获取cellId
    eleTemp = ele;
    while (eleTemp.id.indexOf("SZFORMtd") == -1) {
      eleTemp = eleTemp.parentElement;
      if (eleTemp == null) {
        break;
      } //if ends
    } // while ends

    if (eleTemp != null) {
            //ken，焦点放到text中
      
      if (elePrioTdDown != null && elePrioTdDown.id != eleTemp.id) {
        if (elePrioTdDown.parentElement != null && elePrioTdDown.parentElement.id.indexOf("SZFORMtrDetail")  >=0) {
            elePrioTdDown.className = "trClassTitle2";
        } else {     
        	elePrioTdDown.className = "trMouseOut";
        }
      }
      formUpdate.cellId.value = eleTemp.id;
      eleTemp.className = "trMouseDown";

      if( eleTemp.innerText != "" ) {
	    formUpdate.textName.value = eleTemp.innerText;
      }

      elePrioTdDown = eleTemp;
      //显示列宽
      formUpdate.cellWidth.value = eleTemp.width;
      //formUpdate.cellWidth.value = eleTemp.id;

      //获取children;
      var vLength = eleTemp.childNodes.length;
      var oChild  = null;
      setObjectProperty("");
      if (vLength == 1) {
        oChild = eleTemp.childNodes[0];
		if (oChild != null && oChild.id != null && oChild.id.indexOf("XXID") != -1) {
          setObjectProperty(oChild.id);
      	}  
      } else {
        for (var i=0; i<vLength; i++) {
		  oChild = eleTemp.childNodes[i];
		  if (oChild != null && oChild.id != null && oChild.id.indexOf("XXID") != -1) {
          	setObjectProperty(oChild.id);
          	break;
      	  } 		  
        }
      } //if else

    } // if ends
    //显示当前的cellIndex
    //formUpdate.textName.focus(); 
  } //function ClickElement end

  //作用：当拖动鼠标松开鼠标的左键后，检查是否在规定范围内的td，是的话就交换内容
  function UpElement() {
    editFlag = "true";  
    var ele = event.srcElement;
    var eleTemp = null;
    var eleTempTable = null;

    eleTemp = ele;
    while (eleTemp.id.indexOf("SZFORMtable") == -1) {
      eleTemp = eleTemp.parentElement;
      if (eleTemp == null) {
        break;
      } //if ends
    } // while ends
    if (eleTemp != null && eleTemp.id.indexOf("SZFORMtable") == 0) {  
      //if (eleTemp != null) {
      formUpdate.tableId.value = eleTemp.id;
      eleTempTable = eleTemp;
    }

    //获取cellId
    eleTemp = ele;
    while (eleTemp.id.indexOf("SZFORMtd") == -1) {
      eleTemp = eleTemp.parentElement;
      if (eleTemp == null) {
        break;
      } //if ends
    } // while ends

    if (eleTemp != null) {
      formUpdate.textName.focus();
      if (elePrioTdDown != null && elePrioTdDown.id != eleTemp.id) {
        if (eleTempTable.id != elePrioTableDown.id) {
          //alert("不同的表格不能交换内容！");
          //不同的表格变换位置
          if (confirm("确定要变换两个表格的顺序吗?")) {
          	//alert(eleTempTable.outerHTML);
          	elePrioTdDown.className = "trMouseOut";
          	//elePrioTdDown = eleTemp;
          	var vOuterHTML = eleTempTable.outerHTML;
          	eleTempTable.outerHTML =  elePrioTableDown.outerHTML;
          	elePrioTableDown.outerHTML =  vOuterHTML;
          }
          return;
        }
        //拖到其他td里面了，开始交换内容。
        var vTempHtml = eleTemp.innerHTML;
        eleTemp.innerHTML = elePrioTdDown.innerHTML;
        elePrioTdDown.innerHTML = vTempHtml;
      }
    }
    
    //2009-08-31尝试增加交换表格位置.点中隐藏带,拖到其他表格的隐藏带

  }

  //这个作用：当拖动鼠标的时候，不会选中文字。
  function SelectStartElement() {
    var ele = event.srcElement;
    var eleTemp = null;

    eleTemp = ele;
    while (eleTemp.id.indexOf("SZFORMtable") == -1) {
      eleTemp = eleTemp.parentElement;
      if (eleTemp == null) {
        break;
      } //if ends
    } // while ends

    if (elePrioTdDown != null && eleTemp != null) {
      return false;
    }
  }

  ////////增加鼠标的“向左”37，“向上”38，“向右”39,“向下”40，的控制
  ////当按键盘的时候就调用方法
  function tableArrow() {
    /*
    if (currentX2 >0) {
      //判断是否
      if (event.keyCode == 37) {
        moveTableCell(0,-1);
      } else if (event.keyCode == 38) {
        moveTableCell(-1,0);
      } else if (event.keyCode == 39) {
        moveTableCell(0,1);
      } else if (event.keyCode == 40) {
        moveTableCell(1,0);
      } else if (!event.ctrlKey && !event.altKey) {
        form.textName.focus();
      }
      //光标在表格上，又想输入资料的时候，定位到form.currentText.value =

      //alert(event.keyCode);
      //if(event.ctrlKey && event.keyCode == 67)
    }
    //首先判断是否按下当前行
    //shift = 16 ctrl=17

    if (event.ctrlKey && event.altKey) {
       if(event.keyCode ==76) {       //向左合并，
           mergeCellsLeft(tab1);
       } else if(event.keyCode ==82) {//向右合并
           mergeCellsRight(tab1);
       } else if(event.keyCode ==83) {//保存当前属性
           saveProperty();
       } else if(event.keyCode ==73) {//插入一行
           insertRow(tab1);
       } else if(event.keyCode ==68) {//删除一行
           deleteRow(tab1);
       } else if(event.keyCode ==48) {//0不用控件
           form.currentControl[0].checked = true;
       } else if(event.keyCode ==49) {//1文本
           form.currentControl[1].checked = true;
       } else if(event.keyCode ==50) {//2文本域
           form.currentControl[2].checked = true;
       } else if(event.keyCode ==51) {//3下拉列表
           form.currentControl[3].checked = true;
       } else if(event.keyCode ==52) {//4数字
           form.currentControl[4].checked = true;
       } else if(event.keyCode ==53) {//5多选
           form.currentControl[5].checked = true;
       } else if(event.keyCode ==54) {//6单选
           form.currentControl[6].checked = true;
       } else if(event.keyCode ==55) {//7日期
           form.currentControl[7].checked = true;
       }
    }
    */
  }
  //当鼠标放在表格上面的时候，移动上下左右可移动单元格的当前行。
  function moveTableCell(row_1, cell_1) {
    //表
    var oTable = getTableObject();
    if (oTable == null) {
	return;
    }
    var oCell = getCellObject();
    var cellIndex = -1;
    cellIndex = oCell.cellIndex;	//当前列

    //获得当前行
    var oRow = getRowObject();
    var rowIndex = -1;
    rowIndex = oRow.rowIndex;

    //当前行，当前列
    var currentrow  = parseInt(rowIndex) + parseInt(row_1);
    var currentcell = parseInt(cellIndex) + parseInt(cell_1);

    //总行
    var rows = oRow.length;
    var cells = oCell.length;

    if (currentrow >= rows) {
        currentrow = 0;
    }
    if (currentrow < 0) {
        currentrow = rows -1;
    }
    if (currentcell >= cells) {
        currentcell = 0;
    }
    if (currentcell < 0) {
        currentcell = cells -1;
    }

    ////获取当前单元格的id
    var currentcell = oTable.rows[currentrow].cells[currentcell];
    ////
    //tableClick(currentcell.id);
  }

  function currentTextKeyDown() {
     if(event.keyCode ==13) { 
		AddText();
     }
  }

  //当鼠标放在td上的时候，保存table,tr,td的id，并且改变td的颜色。这个暂时没有使用
  document.onmouseover = OverElement;
  //点鼠标点在td上的时候，保存table,tr,td的id，并且改变td的颜色
  document.onmousedown = ClickElement;
  //当鼠标松开左键的时候，检查是否需要交换td内的内容。
  document.onmouseup = UpElement;
  //当拖动鼠标的时候，不让选中文字。因为这里的拖动目的是为了交换内容。
  document.onselectstart = SelectStartElement;
  //document.onmousemove = moveEl;
  //activeEl = document.elementName;
  //当光标在表格上时，
  document.onkeydown=tableArrow;

</script>

<script language="javascript">
  function AddRedStart() {
  	//把单元格取出来
    var oTable = getTableObject();
    //获取表格的类型
    if (oTable == null) {
      return;
    }
    var oRow = getRowObject();
    if (oRow == null) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    oCell.innerHTML = oCell.innerHTML + " <font color='red'>*</font>";      
  }
  
  function RemoveRedStart() {
  	//把单元格取出来
    var oTable = getTableObject();
    //获取表格的类型
    if (oTable == null) {
      return;
    }
    var oRow = getRowObject();
    if (oRow == null) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    var vHTML = oCell.innerHTML;    
    var vIndex = vHTML.indexOf("*");
    if (vIndex > 0){
      vHTML = vHTML.substring(0, vIndex) + vHTML.substring(vIndex + 1, vHTML.length);
    }
    oCell.innerHTML = vHTML;
    //vHTML.substring(	 
  }  
  
  function AddTitleStyle() {
  	//把单元格取出来
    var oTable = getTableObject();
    //获取表格的类型
    if (oTable == null) {
      return;
    }
    var oRow = getRowObject();
    if (oRow == null) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //oCell.innerHTML = oCell.innerHTML + " <font color='red'>*</font>";
    //oCell.style.="BACKGROUND-COLOR: #808080; COLOR: white; CURSOR: hand";
    oCell.style.color="white";
    oCell.style.background="#808080";  	
    //oCell.style.fontSize=18;
  }  

  function SetBackColor() {
  	//把单元格取出来
    var oTable = getTableObject();
    //获取表格的类型
    if (oTable == null) {
      return;
    }
    var oRow = getRowObject();
    if (oRow == null) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    var v = formUpdate.backcolor.value;
    if (v != "") {
    	oCell.style.background=v; 
    }
    //2011-06-07增加，设置后还原成默认颜色
    formUpdate.backcolor.value = ""; 	
  }

  function SetFontColor() {
  	//把单元格取出来
    var oTable = getTableObject();
    //获取表格的类型
    if (oTable == null) {
      return;
    }
    var oRow = getRowObject();
    if (oRow == null) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    var v = formUpdate.fontcolor.value;
    if (v != "") {
    	oCell.style.color=v;
    }  	
    formUpdate.fontcolor.value = "";
  }
  
	//设置字体大小
  function SetFontSize() {
  	//把单元格取出来
    var oTable = getTableObject();
    //获取表格的类型
    if (oTable == null) {
      return;
    }
    var oRow = getRowObject();
    if (oRow == null) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    var v = formUpdate.fontsize.value;
    if (v != "") {
    	oCell.style.fontSize=v;
    } 
    formUpdate.fontsize.value = ""; 	
  }
  
  //设置字体是否粗
  function SetFontBold() {
  	//把单元格取出来
    var oTable = getTableObject();
    //获取表格的类型
    if (oTable == null) {
      return;
    }
    var oRow = getRowObject();
    if (oRow == null) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    var v = formUpdate.fontbold.value;
    if (v == "yes") {
    	oCell.style.fontWeight="bold";
    } else if (v == "no") {
    	oCell.style.fontWeight="";
    }
    formUpdate.fontbold.value = ""; 	
  }  
  
  function RemoveTitleStyle() {
  	//把单元格取出来
    var oTable = getTableObject();
    //获取表格的类型
    if (oTable == null) {
      return;
    }
    var oRow = getRowObject();
    if (oRow == null) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    oCell.style.color="";
    oCell.style.background="";  	
  }  
  
  function AddText() {
    editFlag = "true";  
    var oTable = getTableObject();
    //获取表格的类型
    if (oTable == null) {
      return;
    }
    var vType = getTableType(oTable.id);
    //
    var oRow = getRowObject();
    if (oRow == null) {
      return;
    }
    //获取行号
    var vRowIndex = oRow.rowIndex;  //0第一行，1第二行
    if (vType == "1" && vRowIndex == 1) { //多行的话只能显示在第一行
      alert("明细表单只有第一行才能增加文字");
      return;
    }

    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    var v = formUpdate.textName.value;
    formUpdate.textName.value = "";
    if (v == "") {
      v = " ";
    }
    oCell.innerText = v;
  }

  function RemoveAll() {
    editFlag = "true";  
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //控件数组也要去掉一个
    var vObjectId = formUpdate.objectId.value;
    if (vObjectId != "") {
      removeObject(vObjectId);
    }

    oCell.innerHTML = "";
    oCell.innerText = " ";
  }

  //增加一个hidden字段
  function AddHiddenKey() {
    editFlag = "true";  
    var vObjectType = "1";
    var oTable = getTableObject();
    if (oTable == null) {
      return;
    }
    var id = getNewObjectCount(vObjectType);
    var divId = "div" + oTable.id;
    var oDiv = document.getElementById(divId);
    if (oDiv == null) {
      return "";
    }
    oDiv.innerHTML += "<input type='text' size='10' name='" + id + "' id='" + id + "'>";
    return id;
  }

  function CheckTableType(vObjectType) {
    editFlag = "true";  
    var oTable = getTableObject();
    if (oTable == null) {
      return;
    }
    //获取表格的类型
    var vType = getTableType(oTable.id);
    //
    var oRow = getRowObject();
    if (oRow == null) {
      return;
    }
    //获取行号
    var vRowIndex = oRow.rowIndex;  //0第一行，1第二行
    //101,明细窗口不能添加到普通表单中
    if (vType == "0" && vObjectType == 101) {
	    alert("普通表格不能增加此项");
	    return false;
    }
    //只有hidden,text才能加在明细里，其他的返回false    
    if (vType == "1") {
	  if (vObjectType != 0 && vObjectType != 1 && vObjectType != 101) { //只有hidden,text才能加在明细里
	    alert("明细表格不能增加此项");
	    return false;
	  }
	  if ( vRowIndex == 0) {//多行的话只能显示在第2行
        alert("明细表格只有第二行才能增加控件");
        return false;	  
	  }
    }
    
    return true;
  }

  function AddInput() {
    var vObjectType = "0";
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //原来是否有控件？有控件的话要先remove
    var oObject = getCurrentObject();
    if (oObject != null) {
      removeObject(oObject.id);
    }
    //增加一个input
    //oCell.innerHTML = oCell.innerHTML + "<input type='text' size='10'>";
    var id = getNewObjectCount(vObjectType);
    //取得当前默认的样式
    var vClass = formUpdate.objectClass.value;
    if (vClass == "") {
	  vClass = "txtClass1";
    }
    
    oCell.innerHTML = "<input type='text' class='" + vClass + "' size='10' name='" + id + "' id='" + id + "'>";
  }

  function AddTextArea() {
    var vObjectType = "7";
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }

    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //原来是否有控件？有控件的话要先remove
    var oObject = getCurrentObject();
    if (oObject != null) {
      removeObject(oObject.id);
    }
    //增加一个textarea
    var id = getNewObjectCount(vObjectType);
    //取得当前默认的样式
    var vClass = formUpdate.objectClass.value;
    if (vClass == "") {
	  vClass = "areaClass1";
    }    
    oCell.innerHTML = "<textarea class='" + vClass + "' name='" + id + "' id='" + id + "'></textarea>";
  }

  function AddRadio() {
    var vObjectType = "8";  
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //原来是否有控件？有控件的话要先remove
    var oObject = getCurrentObject();
    if (oObject != null) {
      removeObject(oObject.id);
    }
    //弹出窗口
    var url = "formOption.jsp?type=radio";
    window.showModalDialog(url,window,"status=no;dialogWidth=350px;dialogHeight=370px");    
  }
  
  //被弹出窗口formOption调用。
  function SetHtml(vHtml) {
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //oCell.innerHTML = oCell.innerHTML + vHtml;    
    oCell.innerHTML = vHtml;  
  }
  
  function AddSelectHtml(vHtml) {
    var oCellTemp = getCellObject();
    if (oCellTemp == null) {
      return;
    }
    //判断oCell是否包含type='button' name='btnSelect'
	if (oCellTemp.childNodes != null) {
		iLen = oCellTemp.childNodes.length;

		for (k=0; k<iLen; k++) {
            if (oCellTemp.childNodes[k] != null 
            	&& oCellTemp.childNodes[k] != ""
                && oCellTemp.childNodes[k].nodeName == "INPUT" 
	      		&& oCellTemp.childNodes[k].type == "button" 
	      		&& oCellTemp.childNodes[k].name=="btnSelect") {
			  	oCellTemp.removeChild(oCellTemp.childNodes[k]);
            }
		} // for ends
	} //if ends
    oCellTemp.innerHTML = oCellTemp.innerHTML + vHtml;
    //oCell.innerHTML = vHtml;  
  }  

  function AddCheck() {
    var vObjectType = "9";  
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //原来是否有控件？有控件的话要先remove
    var oObject = getCurrentObject();
    if (oObject != null) {
      removeObject(oObject.id);
    }
    //弹出窗口
    var url = "formOption.jsp?type=check";
    window.showModalDialog(url,window,"status=no;dialogWidth=350px;dialogHeight=370px");  
  }

  function AddSelect() {
    var vObjectType = "10";  
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //原来是否有控件？有控件的话要先remove
    var oObject = getCurrentObject();
    if (oObject != null) {
      removeObject(oObject.id);
    }
    //弹出窗口
    var url = "formOption.jsp?type=select";
    window.showModalDialog(url,window,"status=no;dialogWidth=350px;dialogHeight=370px");  
  }  

  //显示当前时间
  function AddTime() {
    var vObjectType = "4";  
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //原来是否有控件？有控件的话要先remove
    var oObject = getCurrentObject();
    if (oObject != null) {
      removeObject(oObject.id);
    }
    //增加一个input
    //oCell.innerHTML = oCell.innerHTML + "<input type='text' size='10'>";
    var id = getNewObjectCount(vObjectType);
    var v = "yyyy-MM-dd hh:mm";    
    oCell.innerHTML = "<input type='text' class='txtClass1' readonly size='10' name='" + id + "' id='" + id + "' value='" + v + "'>";
  }

  //显示当前时间
  function AddCurrentTime() {
    var vObjectType = "44";  
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //原来是否有控件？有控件的话要先remove
    var oObject = getCurrentObject();
    if (oObject != null) {
      removeObject(oObject.id);
    }
    //增加一个input
    //oCell.innerHTML = oCell.innerHTML + "<input type='text' size='10'>";
    var id = getNewObjectCount(vObjectType);
    oCell.innerHTML = "<input type='text' class='txtClass1' readonly size='10' name='" + id + "' id='" + id + "' value='yyyy-MM-dd hh:mm'>";
  }

  //增加日期控件
  function AddDateObject() {
    var vObjectType = "42";   
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //原来是否有控件？有控件的话要先remove
    var oObject = getCurrentObject();
    if (oObject != null) {
      removeObject(oObject.id);
    }
    //增加一个input
    //oCell.innerHTML = oCell.innerHTML + "<input type='text' size='10'>";
    var id = getNewObjectCount(vObjectType);
    oCell.innerHTML = "<input type='text' class='txtClass1' readonly size='10' name='" + id + "' id='" + id + "' value='yyyy-MM-dd'>"
                    + "<img id='" + id + "' src='../../share/calendar/calbtn.gif' height=22 width=34 align=absBottom>";
  }

  //增加时间控件
  function AddTimeObject() {
    var vObjectType = "43";   
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //原来是否有控件？有控件的话要先remove
    var oObject = getCurrentObject();
    if (oObject != null) {
      removeObject(oObject.id);
    }
    //增加一个input
    //oCell.innerHTML = oCell.innerHTML + "<input type='text' size='10'>";
    var id = getNewObjectCount(vObjectType);
    oCell.innerHTML = "<input type='text' class='txtClass1' readonly size='10' name='" + id + "' id='" + id + "' value='yyyy-MM-dd hh:mm'>"
                    + "<img id='" + id + "' src='../../share/calendar/calbtn.gif' height=22 width=34 align=absBottom>";
  
  }
  
  //
  function AddUserName() {
    var vObjectType = "2";   
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //原来是否有控件？有控件的话要先remove
    var oObject = getCurrentObject();
    if (oObject != null) {
      removeObject(oObject.id);
    }
    var id = getNewObjectCount(vObjectType);
    var v = "本人姓名";
    oCell.innerHTML = "<input type='text' class='txtClass1' readonly size='10' name='" + id + "' id='" + id + "' value='" + v + "'>";  
  }
  
  function AddUserID() {
    var vObjectType = "3";   
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }  
    ////
    var oTable = getTableObject();
    if (oTable == null) {
      return;
    }
    var id = getNewObjectCount(vObjectType);
    var v = "本人ID";    
    var divId = "div" + oTable.id;
    var oDiv = document.getElementById(divId);
    if (oDiv == null) {
      return "";
    }
    oDiv.innerHTML += "<input type='text' class='txtClass1' readonly size='10' name='" + id + "' id='" + id + "' value='" + v + "'>";
    return id;      
  }
  
  //自动增加用户ID。增加时检查是否有表增加过用户ID，如果没有就自动增加用户ID
  function AutoAddUserID() {
    var vObjectType = "3";  
    var vCount = objectArray.length;
    var i = 0;
	var flag = false;
    for (i = 0; i< vCount; i++ ) {
      if (objectArray[i] == null) {
        continue;
      }
      if (objectArray[i][0] != "" && objectArray[i][0] != "0" && objectArray[i][4] == "3") {
		flag = true;
		break;
      }
    }     
    //判断是否有
    if (flag == false) {
      var oTable = null;
      //需要往第一个表增加
      var vCountTable = tableArray.length;
      for (var j=0; j<vCountTable; j++) {
        if (tableArray[j] == null) {
          continue;
        }
        //检查是否有主表
        if (tableArray[j][0] != "" && tableArray[j][5] == "0") {
			oTable = document.getElementById( tableArray[j][0] );
			break;    
        }
      }  //for  
      if (oTable != null) {
        formUpdate.tableId.value = tableArray[j][0];
    	var id = getNewObjectCount(vObjectType);
    	var v = "本人ID";    
    	var divId = "div" + oTable.id;
    	var oDiv = document.getElementById(divId);
    	if (oDiv == null) {
      		return "";
    	}
    	oDiv.innerHTML += "<input type='text' class='txtClass1' readonly size='10' name='" + id + "' id='" + id + "' value='" + v + "'>";
    	return id;  
      }  
    }//if (flag == false) {
    return "";  	
  }
  
  function AddDepartName() {
    var vObjectType = "33";   
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //原来是否有控件？有控件的话要先remove
    var oObject = getCurrentObject();
    if (oObject != null) {
      removeObject(oObject.id);
    }
    var id = getNewObjectCount(vObjectType);
    var v = "部门名称";
    oCell.innerHTML = "<input type='text' class='txtClass1' readonly size='10' name='" + id + "' id='" + id + "' value='" + v + "'>";  
  }
  
  function AddDepartID() {
    var vObjectType = "34";   
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    } 
    var oTable = getTableObject();
    if (oTable == null) {
      return;
    }
    var id = getNewObjectCount(vObjectType);
    var v = "部门ID";
    var divId = "div" + oTable.id;
    var oDiv = document.getElementById(divId);
    if (oDiv == null) {
      return "";
    }
    oDiv.innerHTML += "<input type='text' class='txtClass1' readonly size='10' name='" + id + "' id='" + id + "' value='" + v + "'>";
    return id;      
  }
  
  //自动增加部门ID。增加时检查是否有表增加过用户ID，如果没有就自动增加用户ID
  function AutoAddDepartID() {
    var vObjectType = "34";  
    var vCount = objectArray.length;
    var i = 0;
	var flag = false;
    for (i = 0; i< vCount; i++ ) {
      if (objectArray[i] == null) {
        continue;
      }
      if (objectArray[i][0] != "" && objectArray[i][0] != "0" && objectArray[i][4] == "34") {
		flag = true;
		break;
      }
    }     
    //判断是否有
    if (flag == false) {
      var oTable = null;
      //需要往第一个表增加
      var vCountTable = tableArray.length;
      for (var j=0; j<vCountTable; j++) {
        if (tableArray[j] == null) {
          continue;
        }
        //检查是否有主表
        if (tableArray[j][0] != "" && tableArray[j][5] == "0") {
			oTable = document.getElementById( tableArray[j][0] );
			break;    
        }
      }  //for  
      if (oTable != null) {
        formUpdate.tableId.value = tableArray[j][0];
    	var id = getNewObjectCount(vObjectType);
    	var v = "部门ID";
    	var divId = "div" + oTable.id;
    	var oDiv = document.getElementById(divId);
    	if (oDiv == null) {
      	  return "";
    	}
    	oDiv.innerHTML += "<input type='text' class='txtClass1' readonly size='10' name='" + id + "' id='" + id + "' value='" + v + "'>";    	return id;  
      }  
    }//if (flag == false) {
    return "";  	
  }  
  
  //增加一个hidden字段
  function AutoAddForeignKey() {
    editFlag = "true";  
    //检查是否有两个表,
    var vCountTable = tableArray.length;
    var vTable = null;
    var flag = false;
    var j = 0;
    for (j = 0; j < vCountTable; j++) {
       if (tableArray[j] == null) {
          continue;
       }
       //检查是否有主表
       if (tableArray[j][0] != "" && tableArray[j][5] == "0" && tableArray[j][6] == "1") {
       		flag = true;
			break;    
       }
    }  //for
    //存在主表,才需要检查附属表
    var vKeyId = "";
    if (flag) {
    	for (j = 0; j < vCountTable; j++) {
       		if (tableArray[j] == null) {
          		continue;
       		}
       		//检查是否有主表
       		if (tableArray[j][0] != "" && tableArray[j][5] == "0" && tableArray[j][6] == "0") {
       			flag = true;
				vTable = tableArray[j][0];
				vKeyId = tableArray[j][3];
				break;    
       		}
    	}  //for  
    	//有,而且还没有设置外健
        if (vTable != null && vKeyId == "") {
    		//选中表格
        	formUpdate.tableId.value = vTable;
			//自动增加hidden
        	var vKeyId = AddHiddenKey();
			AddTableForeign(vTable, vKeyId);   
      	}     	  
    }
  }  

  //AddIdSingleWin：弹出窗口ID，单项选择
  function AddWin() {
    var vObjectType = "100";
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }

    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //弹出窗口
    var url = "formSelect.jsp?ObjectType=" + vObjectType;
    //window.showModalDialog(url,window,"status=no;dialogWidth=560px;dialogHeight=670px"); 
    window.open(url, '',"left=200,top=20,scrollbars=yes,resizable=yes,status=no,width=570px,height=670px");      
  }

  function AddWin2() {
    var vObjectType = "101";
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }  
    //检查只有第二行才能增加控件
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    //弹出窗口
    var url = "formSelect.jsp?ObjectType=" + vObjectType;
    //window.showModalDialog(url,window,"status=no;dialogWidth=560px;dialogHeight=670px"); 
    window.open(url, '',"left=200,top=20,scrollbars=yes,resizable=yes,status=no,width=570px,height=670px");      
  }


  //=============================================设置控件属性
  function SetObjectProperty() {
    editFlag = "true";
    var objectId = formUpdate.objectId.value;
    var objectField = formUpdate.objectField.value;
    var objectName = formUpdate.objectName.value;
    if (objectId == "") {
      return;
    }
    var oObject = document.getElementById(objectId);
    if (oObject == null) {
      return;
    }
    if (objectField == "") {
        formUpdate.objectField.focus();
        alert("字段名不能为空");
    }
    //需要检查名称是否已经存在
    var vFlag = setObjectName(objectId, objectField, objectName);
    if (vFlag == false) {
       formUpdate.objectField.focus();
    }
    //设置样式
    var vClass = formUpdate.objectClass.value;

    if (vClass != "") {
      if (vClass == "0") {
        oObject.className = "";
      } else {
        oObject.className = vClass;
      }
      formUpdate.objectClass.value = "";
    }
  }

  //改变已经选中的控件的只读属性
  function SetObjectReadOnly() {
    editFlag = "true";  
    var objectId = formUpdate.objectId.value;
    if (objectId == "") {
      return;
    }
    var oObject = document.getElementById(objectId);
    if (oObject == null) {
      return;
    }
    //background-color: #7F9DB9;
    oObject.readOnly = !oObject.readOnly;
    var vClassName = "";
    if ( oObject.readOnly) {
    	vClassName = oObject.className;
    	//oObject.style.background = "#D5E0E2";
    	oObject.style.background = "#EAF2F3";    	
    } else {
    	oObject.style.background = "#FFFFFF";
    }
  }

  //===============================================设置表格属性
  function SetTableProperty() {
    editFlag = "true";  
    var tableId = formUpdate.tableId.value;
    var tableName = formUpdate.tableName.value;
    var tableClass = "";
    if (tableId == "") {
      return;
    }
    var oTable = document.getElementById(tableId);
    if (oTable == null) {
      return;
    }
    if (tableName == "") {
      formUpdate.tableName.focus();
      alert("表名不能为空");
    }
    //需要检查名称是否已经存在，需要检查类名是否已存在
    var vFlag = setTableName(tableId, tableName);
    if (vFlag == false) {
      formUpdate.tableName.focus();
    }
  }
  
  function SetTableProperty2() {
    editFlag = "true";  
    var tableId = formUpdate.tableId.value;
    var tableName = formUpdate.tableName.value;
    var tableMain = "0";
    if (formUpdate.tableMain.checked == true) {
      tableMain = "1";
    }
    
    var tableClass = "";
    if (tableId == "") {
      return;
    }
    var oTable = document.getElementById(tableId);
    if (oTable == null) {
      return;
    }
    if (tableName == "") {
      formUpdate.tableName.focus();
      alert("表名不能为空");
    }
    //需要检查名称是否已经存在，需要检查类名是否已存在
    var vFlag = setTableName2(tableId, tableName, tableMain);
    if (vFlag == false) {
      formUpdate.tableName.focus();
    }
  }  
</script>

<script language="javascript">
  function Test() {
    var oRow = getRowObject();
    var oCell = getCellObject();

    if (oCell == null) {
      return;
    }
    formUpdate.test.value = oCell.id;
    formUpdate.cellWidth.value = oCell.width;
    //formUpdate.cellWidth.value = oCell.size;
    //oCell = document.getElementById("id2");
    //formUpdate.cellWidth.value = oCell.style.pixelWitdh;
    //当td 的width设置为52的时候，获取的oCell.offsetWidth=60
    //当td 的width设置为52的时候，获取的oCell.clientWidth=58
    //当td 的width设置为52的时候，获取的oCell.scrollWidth=14
    //当td 的width设置为52的时候，获取的oCell.clientLeft=1
    //oCell.style.padding没有显示

  }

  function GetHtml() {
    var html = idHtml.innerHTML;
    alert(html);
  }

  //获取当前行的object
  function getTableObject() {
    var tableId = formUpdate.tableId.value;
    var oTable = null;
    if (tableId != "") {
      oTable = document.getElementById(tableId);
    }
    return oTable;
  }

  function getRowObject() {
    var rowId = formUpdate.rowId.value;
    var oRow = null;
    if (rowId != "") {
      oRow = document.getElementById(rowId);
    }
    return oRow;
  }

  function getCellObject() {
    var cellId = formUpdate.cellId.value;
    var oCell = null;
    if (cellId != "") {
      oCell = document.getElementById(cellId);
    }
    return oCell;
  }

  function getCurrentObject() {
    var objectId = formUpdate.objectId.value;
    var oObject = null;
    if (objectId != "") {
      oObject = document.getElementById(objectId);
    }
    return oObject;
  }

  //计算一行有多少个colspan
  function GetRowCols(oRow) {
    if (oRow == null) {
      return 0;
    }
    var vLen = oRow.cells.length;
    var oCell = null;
    var vCols = 0;
    for (var i=0; i<vLen; i++) {
      oCell = oRow.cells[i];
      vCols = vCols + oCell.colSpan;
    }
    return vCols;
  }

  //===========================================
  //设置当前行的列宽为设置的100%值
  //当没有明确使用cell.width设置的时候，cell.width获取的值为空。
  //检查是否全部为数字
  function isNum_HTML(str) {
      var len = 0;
      len = str.length;
      var i = 0;
      for( i=0; i< len; i++) {
          temp = str.substring(i,i+1);
          if (temp >="0" && temp<="9") {
              continue;
          }
          else {
              return false;
          }
      }
      if (str == "0") {
      	return false;
      }
      return true;
  }

  function SetCellWidth() {
    editFlag = "true";  
    var oRow = getRowObject();
    var oCell = getCellObject();

    var vWidth = formUpdate.cellWidth.value;
    //这里需要判断全部为数字

    //需要判断vWidth为数字，而且
    if (oCell == null || !isNum_HTML(vWidth) || vWidth == "0") {
      return;
    }
    oCell.width = vWidth + "%";
  }

  //===========================================设置对齐方式
  function UserAlignLeft() {
    editFlag = "true";  
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    oCell.align = "left";
  }
  function UserAlignCenter() {
    editFlag = "true";  
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    oCell.align = "center";
  }
  function UserAlignRight() {
    editFlag = "true";  
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    oCell.align = "right";
  }

  function UserValignTop() {
    editFlag = "true";  
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    oCell.vAlign = "top";
  }
  function UserValignMiddle() {
    editFlag = "true";  
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    oCell.vAlign = "middle";
  }
  function UserValignBottom() {
    editFlag = "true";  
    var oCell = getCellObject();
    if (oCell == null) {
      return;
    }
    oCell.vAlign = "bottom";
  }

  //=========================================合并单元格
  //向左边合并，把左边的单元格去掉
  function UserMergeLeft(){
    var vObjectType = "-1";
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }  
    editFlag = "true";  
    var oCell = getCellObject();
    var oRow = getRowObject();
    if (oRow == null || oCell == null) {
      return;
    }
    var cellIndex = -1;
    cellIndex = oCell.cellIndex;
    //左边有没有单元格？
    if (cellIndex <= 0) {
      return;
    }
    //要合并两个单元格的内容

    //本单元格的colspan + 1
    oCell.colSpan = oCell.colSpan + 1;
    //删除左边单元格，
    oRow.deleteCell(cellIndex - 1);
  }
  //向右边合并，把右边的单元格去掉
  function UserMergeRight(){
    var vObjectType = "-1";
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }  
    editFlag = "true";  
    var oCell = getCellObject();
    var oRow = getRowObject();
    if (oRow == null || oCell == null) {
      return;
    }
    var cellIndex = -1;
    cellIndex = oCell.cellIndex;

    //左边有没有单元格？
    if (cellIndex >= oRow.cells.length - 1) {
      return;
    }
    //要合并两个单元格的内容

    //本单元格的colspan + 1
    oCell.colSpan = oCell.colSpan + 1;
    //删除右边单元格，
    oRow.deleteCell(cellIndex + 1);
  }

  //============================================增加、删除单元格
  //在当前格的左边增加一格
  function UserInsertLeftCell() {
    var vObjectType = "-1";
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }
      
    editFlag = "true";  
    //获得当前行
    var oRow = getRowObject();
    var oTable = getTableObject();
    var oCell = getCellObject();
    if (oTable == null || oRow == null || oCell == null) {
      return;
    }

    //每一行都增加一列
    var cellIndex = -1;
    cellIndex = oCell.cellIndex;

    InsertCell(oRow, cellIndex);
  }

  //在当前格的左边增加一格
  function UserInsertRightCell() {
    var vObjectType = "-1";
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }  
    editFlag = "true";  
    //获得当前行
    var oRow = getRowObject();
    var oTable = getTableObject();
    var oCell = getCellObject();
    if (oTable == null || oRow == null || oCell == null) {
      return;
    }

    //每一行都增加一列
    var cellIndex = -1;
    cellIndex = oCell.cellIndex;

    InsertCell(oRow, cellIndex + 1);
  }

  //在当前格右边插入一列，所有行都增加一列
  function UserInsertCell() {
    editFlag = "true";
    //获得当前行
    var oRow = getRowObject();
    var oTable = getTableObject();
    var oCell = getCellObject();
    if (oTable == null || oRow == null || oCell == null) {
      return;
    }

    //每一行都增加一列
    var cellIndex = -1;
    cellIndex = oCell.cellIndex;

    var vLen = oTable.rows.length;
    for (var i=0; i<vLen; i++) {
      oRow = oTable.rows[i];

      InsertCell(oRow, cellIndex + 1);
    }
  }

  //在表格的最后增加一行
  function UserAddCell() {
    editFlag = "true";  
    //获得当前行
    var oRow = getRowObject();
    var oTable = getTableObject();
    if (oTable == null) {
      return;
    }

    //每一行都增加一列
    var vLen = oTable.rows.length;
    for (var i=0; i<vLen; i++) {
      oRow = oTable.rows[i];
      AddCellByRow(oRow);
    }
  }

  //手动插入一行，在当前行下面
  function UserInsertRow() {
    var vObjectType = "-1";
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }
      
    editFlag = "true";  
    //获取当前table
    var tableId = formUpdate.tableId.value;
    //获得当前行
    var oRow = getRowObject();
    var rowIndex = -1;

    var oTable = null;
    if (tableId != "" && oRow != null) {
      rowIndex = oRow.rowIndex;

      InsertRow(tableId, rowIndex);
    }
  }

  //手动追加一行，在表格的最后
  function UserAddRow() {
    var vObjectType = "-1";
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }  
    editFlag = "true";
    //获取当前table
    var tableId = formUpdate.tableId.value;
    AddRow(tableId);
  }

  //手动删除选中的一行
  function UserDeleteRow() {
    var vObjectType = "-1";
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }  
    editFlag = "true";  
    //获取当前table
    var tableId = formUpdate.tableId.value;
    //获得当前行
    var rowId = formUpdate.rowId.value;
    var oRow = getRowObject();
    var rowIndex = -1;

    var oTable = null;
    if (tableId != "" && oRow != null) {
      rowIndex = oRow.rowIndex;

      DeleteRow(tableId, rowIndex);
    }
  }

  //手动删除选中的一格
  function UserDeleteCell() {
  
    editFlag = "true";  
    //获得当前行
    var oRow = getRowObject();
    var oTable = getTableObject();
    var oCell = getCellObject();
    if (oTable == null || oRow == null || oCell == null) {
      return;
    }
    //////////
    var cellIndex = oRow.cellIndex;
    oRow.deleteCell(cellIndex);
  }

  function DeleteRow(tableId, rowIndex) {
    var vObjectType = "-1";
    //检查只有第二行才能增加控件
    if (CheckTableType(vObjectType) == false) {
      return;
    }  
    editFlag = "true";  
    var oTable = null;
    if (tableId != "") {
      oTable = document.getElementById(tableId);
      oTable.deleteRow(rowIndex);
    }
  }

  //删除表格
  function DeleteTable() {
  	//2009-09-02增加提醒
  	if (confirm("将同时删除所有控件，是否继续？")) {
    	editFlag = "true";
    
    	var oTable = getTableObject();
    	if (oTable == null) {
      		return;
    	}

    	removeTableArray(formUpdate.tableId.value);
    	formUpdate.tableId.value    = "";
    	formUpdate.tableName.value  = "";

		//是否是明细表格，是的话还要删除明细统计表
		var oTableTotal = document.getElementById(oTable.id + "Total");
		if (oTableTotal != null) {
			oTable.parentNode.removeChild(oTableTotal);
		}

    	//删除表格
    	oTable.parentNode.removeChild(oTable);
    }
  }

  /**
   * 增加一个table
   * @return
   */
  function AddTable() {
    //增加table
    var vTableRows = formUpdate.TableRows.value;
    if (!isNum_HTML(vTableRows)) {
      alert("表格行数只能是大于0的数字");
      formUpdate.TableRows.focus();
      return;
    }
    //增加table
    var vTableCells = formUpdate.TableCells.value;
    if (!isNum_HTML(vTableCells)) {
      alert("表格列数只能是大于0的数字");
      formUpdate.TableCells.focus();
      return;
    }
          
    editFlag = "true";  
    //增加表格前要把前面已经点过的表格、row、cell格设置为空
    if (elePrioTdDown != null) {
      elePrioTdDown.className = "trMouseOut";
      elePrioTdDown = null;
    }
    formUpdate.tableId.value = "";
    formUpdate.rowId.value = "";
    formUpdate.cellId.value = "";
     

    var tableId = getNewTableId("0");
    var html = idHtml.innerHTML;
    var s = "<table width=\"750\" border=\"1\" bordercolorlight=\"#C0C0C0\"";
    s += " bordercolordark=\"#FFFFFF\" cellpadding=\"3\" cellspacing=\"0\"";
    s += " id=\"" + tableId + "\">";
    s += "<div style='background:#C0C0C0;height:20;' id=\"div" + tableId + "\"></div></table>";
    var v = html + s;
    idHtml.innerHTML = v;

    var iTableRows = parseInt(vTableRows);
    for (var i=0; i<iTableRows; i++) {
      AddRow(tableId);
    }
    //增加一个关键字字段
    var vKeyId = AddHiddenKey();   
    AddTableKey(tableId, vKeyId);
  }
  

  function AddTableDetail() {   
    //增加table
    var vTableCells = formUpdate.TableCells.value;
    if (!isNum_HTML(vTableCells)) {
      alert("表格列数只能是大于0的数字");
      formUpdate.TableCells.focus();
      return;
    }  
    editFlag = "true";  
    //增加表格前要把前面已经点过的表格、row、cell格设置为空
    if (elePrioTdDown != null) {
        elePrioTdDown.className = "trMouseOut";
        elePrioTdDown = null;
    }
    formUpdate.tableId.value = "";
    formUpdate.rowId.value = "";
    formUpdate.cellId.value = "";

    var tableId = getNewTableId("1");
    if (tableId == "") {
		//表单已经存在
		alert("明细表单只能存在一个");
		return;
    }
    var html = idHtml.innerHTML;
    var s = "<table width=\"750\" border=\"1\" bordercolorlight=\"#C0C0C0\"";
    s += " bordercolordark=\"#FFFFFF\" cellpadding=\"3\" cellspacing=\"0\"";
    s += " id=\"" + tableId + "\">";
    s += "<div style='background:#C0C0C0' id=\"div" + tableId + "\"></div></table>";
    
    //增加统计行的表格
    var tableIdTotal = tableId + "Total";
	s += "<table width=\"750\" border=\"1\" bordercolorlight=\"#C0C0C0\"";
    s += " bordercolordark=\"#FFFFFF\" cellpadding=\"3\" cellspacing=\"0\"";
    s += " id=\"" + tableIdTotal + "\"><tr class='trClassTitle2'><td>&nbsp;</td></tr>";
    s += "</table>";   
     
    var v = html + s;        
    idHtml.innerHTML = v;


    //增加table
    //明细表，只能显示两行
    AddRowDetail(tableId);
    AddRow(tableId);
    //增加一个关键字字段
    var vKeyId = AddHiddenKey();
    AddTableKey(tableId, vKeyId);
    //增加一个外部关联字段
    vKeyId = AddHiddenKey();
    AddTableForeign(tableId, vKeyId);
    
  }

  /**
    * 在表格的最后增加一行。
    * @return
  */
  function AddRow(tableId) {
    editFlag = "true";  
    var oTable = null;
    if (tableId != "") {
      oTable = document.getElementById(tableId);
      var vRowLeng = oTable.rows.length;
      InsertRow(tableId, vRowLeng -1);
    }
  }
  
  function AddRowDetail(tableId) {
    editFlag = "true";  
    var oTable = null;
    if (tableId != "") {
      oTable = document.getElementById(tableId);
      var vRowLeng = oTable.rows.length;
      InsertRowDetail(tableId, vRowLeng -1);
    }
  }  
  
  function InsertRowDetail(tableId, rowIndex) {
    editFlag = "true";  
    if (tableId == "") {
      return ;
    }
    var oTable = document.getElementById(tableId);
    //选中检查第一行有多少个td和span
    var oRow = null;
    oRow = oTable.rows[0];
    var vCols = GetRowCols(oRow);
    //默认多少列？
    if (vCols == 0) {
      var vTableCells = formUpdate.TableCells.value;
      if (!isNum_HTML(vTableCells)) {
        alert("表格行数只能是数字");
        formUpdate.TableCells.focus();
        return;
      }
      var iTableCells = parseInt(vTableCells);
      vCols = iTableCells;
    }

    var rowCount = parseInt(formUpdate.rowCount.value);
    rowCount = rowCount + 1;
    formUpdate.rowCount.value = rowCount;

    oRow = oTable.insertRow(rowIndex + 1);
    var id = "SZFORMtrDetail" + rowCount;
    oRow.id = id;
    oRow.className = "trClassTitle2";

    for (var i =0; i<vCols; i++) {
      AddCell(id);
    }

  }  

  function InsertRow(tableId, rowIndex) {
    editFlag = "true";  
    if (tableId == "") {
      return ;
    }
    var oTable = document.getElementById(tableId);
    //选中检查第一行有多少个td和span
    var oRow = null;
    oRow = oTable.rows[0];
    var vCols = GetRowCols(oRow);
    //默认多少列？
    if (vCols == 0) {
      var vTableCells = formUpdate.TableCells.value;
      if (!isNum_HTML(vTableCells)) {
        alert("表格行数只能是数字");
        formUpdate.TableCells.focus();
        return;
      }
      var iTableCells = parseInt(vTableCells);
      vCols = iTableCells;
    }

    var rowCount = parseInt(formUpdate.rowCount.value);
    rowCount = rowCount + 1;
    formUpdate.rowCount.value = rowCount;

    oRow = oTable.insertRow(rowIndex + 1);
    var id = "SZFORMtr" + rowCount;
    oRow.id = id;

    for (var i =0; i<vCols; i++) {
      AddCell(id);
    }

  }

  function AddCell(rowId) {
    editFlag = "true";  
    if (rowId == "") {
      return;
    }
    var oRow = document.getElementById(rowId);
    AddCellByRow(oRow);
  }

  function AddCellByRow(oRow) {
    editFlag = "true";  
    if (oRow == null) {
      return;
    }
    var cellIndex = oRow.cells.length;
    InsertCell(oRow, cellIndex);
  }

  function InsertCell(oRow, cellIndex){
    editFlag = "true";  
    if (oRow == null) {
      return;
    }
    var cellCount = parseInt(formUpdate.cellCount.value);
    cellCount = cellCount + 1;
    formUpdate.cellCount.value = cellCount;

    var oCell = null;
    if (oRow.cells.length < cellIndex) {
      oCell = oRow.insertCell(oRow.cells.length);
    } else {
      oCell = oRow.insertCell(cellIndex);
    }


    oCell.innerText = " ";
    var id = "SZFORMtd" + cellCount;
    oCell.id = id;
    //oCell.width = "50";
    //计算一列的宽度
    //获取一列的colspan
    var vRowCols = GetRowCols(oRow);
    //var vWidth = 100 / vRowCols;   //这里用100%
    //oCell.width = vWidth + "%";
    //oCell.attachEvent("onmouseover",new Function("mouseOver('" + id + "');"));
    //oCell.attachEvent("onmouseout",new Function("mouseOut('" + id + "');"));
    //临时放内容
    //oCell.innerText = id;
    //oCell.height="250";
  }

  //================================增加td的两个方法，用来改变td的样式
  function mouseOver(id) {
     document.getElementById(id).className = "trMouseOver";
  }

  function mouseOut(id) {
     document.getElementById(id).className = "trMouseOut";
  }

  //===============================保存表单内容
  function ReplaceAll(vStr, v1, v2) {
    while (vStr.indexOf(v1) != -1) {
      vStr = vStr.replace(v1, v2);
    }
    return vStr;
  }
  function HtmlToText(vHTML) {
    var html = vHTML;
    //html = ReplaceAll(html, "&", "&amp;");
    html = ReplaceAll(html, "<", "&lt;");
    html = ReplaceAll(html, ">", "&gt;");
    //html = ReplaceAll(html, "\r\n", "\n");
    //html = ReplaceAll(html, "\n", "<br>\n");
    //html = ReplaceAll(html, "\t", "    ");
    //html = ReplaceAll(html, "  ", " &nbsp;");
    return html;
  }

  //================================以下是针对XML的辅助操作
  //保存表单内容
  function SaveTable() {
    if (formUpdate.moduleName.value == "" || formUpdate.formName.value == "") {
      alert("没有指定XML和form");
      return;
    }
    /*
    if (formUpdate.tableName.value == "") {
      formUpdate.tableName.focus();
      alert("xml表名不能为空");
      return;
    }
    */
    //保存的时候默认选中第一个普通table,自动增加AddUserId();
    AutoAddUserID();
    AutoAddDepartID();
    AutoAddForeignKey();
    
    //保存前把已经选中的td的颜色改成不选中
    if (elePrioTdDown != null) {
        elePrioTdDown.className = "trMouseOut";
    }
    
    var vCount = objectArray.length;
    var vHTML = "";
    var i = 0;
    for (i = 0; i< vCount; i++ ) {
      if (objectArray[i] == null) {
        continue;
      }
      if (objectArray[i][0] != "" && objectArray[i][0] != "0") {
        //formObjectName
        //vObjectStr += "," objectArray[i][1];
        vHTML += "<input type='hidden' name='objectId" + i + "' value='" + objectArray[i][0] + "'>";
        vHTML += "<input type='hidden' name='field" + i + "' value='" + objectArray[i][1] + "'>";
        vHTML += "<input type='hidden' name='name"  + i + "' value='" + objectArray[i][2] + "'>";
        vHTML += "<input type='hidden' name='type"  + i + "' value='" + objectArray[i][4] + "'>";
        vHTML += "<input type='hidden' name='ZDZT"  + i + "' value='1'>";
        vHTML += "<input type='hidden' name='ZDLX"  + i + "' value='" + objectArray[i][5] + "'>";
      }
    }
    //用了多少个表格
    vCountTable = tableArray.length;
    var vObjectStr = "0";
    var oDiv = null;
    var bFlag = false;
    for (var j=0; j<vCountTable; j++) {
      if (tableArray[j] == null) {
        continue;
      }
      if (tableArray[j][0] != "") {
        //检查是否有主表
        if (tableArray[j][5] == "0") {
		  bFlag = true;
        }
        //保存前把div隐藏起来
        /*
        oDiv = document.getElementById("div" + tableArray[j][0]);
        if (oDiv != null) {
          oDiv.style.display = "none";
        }
        */
        //把表格下的控件ID记录起来
        vObjectStr = "";
        for (i = 0; i< vCount; i++ ) {
            if (objectArray[i] == null) {
                continue;
            }
            if (objectArray[i][3] == tableArray[j][0]) {
              vObjectStr += "," + objectArray[i][0];
            }
        }
        vHTML += "<input type='hidden' name='tableId" + j + "' value='" + tableArray[j][0] + "'>";
        vHTML += "<input type='hidden' name='table" + j + "' value='" + tableArray[j][1] + "'>";
        vHTML += "<input type='hidden' name='tableClass" + j + "' value='" + tableArray[j][4] + "'>";
        vHTML += "<input type='hidden' name='object" + j + "' value='" + vObjectStr + "'>";
        vHTML += "<input type='hidden' name='tableType" + j + "' value='" + tableArray[j][5] + "'>";
        vHTML += "<input type='hidden' name='tableKey" + j + "' value='" + tableArray[j][2] + "'>";
        vHTML += "<input type='hidden' name='tableForeign" + j + "' value='" + tableArray[j][3] + "'>";
        vHTML += "<input type='hidden' name='tableMain" + j + "' value='" + tableArray[j][6] + "'>";
      }
    }
    if (bFlag == false) {
	  alert("请增加表格");
	  return false;
    }
    
    formUpdate.formHtml.value =idHtml.innerHTML;
    formObjectName.innerHTML = formObjectName.innerHTML + vHTML;

    //formObject
    formUpdate.OPERATOR.value = "XMLFORM";
    formUpdate.action = "formControl.jsp";
    formUpdate.submit();
  }

  //初始化的时候
  if (formUpdate.moduleName.value != "" && formUpdate.formName.value != "") {
    var vHtml = formUpdate.formHtml.value;
    //idHtml.innerHTML = vHtml;
  }
  
  function CloseWindow() {
    /*
    alert(editFlag);
    //关闭窗口
    if (editFlag == "true") {
	  if (confirm("已经修改了表单，是否不保存就退出?")) {
		window.close();
	  }
    } else {
      window.close();
    } 
    */
    if (confirm("确定要退出?")) {
      window.close();
    }    
  }
  
  function History() {
    var url = "formHistory.jsp";
		window.showModalDialog(url,window,"status=no;dialogWidth=680px;dialogHeight=450px");
		//
		//window.open(url, '',"left=200,top=20,scrollbars=yes,resizable=yes,status=no,width=680px,height=670px");
		//window.close();
  }
  
</script>

<script language="javascript">
  divPropertiesTop = parseInt(document.getElementById("divProperties").style.top);
  divTableToolsTop = parseInt(document.getElementById("divTableTools").style.top);
  divObjectToolsTop = parseInt(document.getElementById("divObjectTools").style.top);
  //当拖动Drag.Move的时候，改变这几个top的值
  function scall(){
    var vScrollTop = parseInt(document.body.scrollTop);
    document.getElementById("divObjectTools").style.top  = divObjectToolsTop + vScrollTop;
    document.getElementById("divTableTools").style.top   = divTableToolsTop + vScrollTop;
    document.getElementById("divProperties").style.top  = divPropertiesTop + vScrollTop;
  }

  window.onscroll=scall;
  window.onresize=scall;
  window.onload=scall;

</script>
</body>
</html>
<%
    out.println(SzPageHelp.calendarFrame2());
%>