﻿// JScript File

/*
***********************************
Javascript 标准库
Bob
2006-04-13
2009-08-24

* For Base
LTrim(str)
RTrim(str)
Trim(str)
CheckString(value, compare)
CheckNumberic(value, min, max)
GetDate(separator)
DateToString(date, separator)
CheckDate(value, separator, checkType) checkType:0=Default, 3=YMD, 2=YM, 1=Y
GetFileName(url)
GetUnSuffixFileName(filename)
GetSuffix(url)
ParseDate(cDate, cSeparator)
CheckDate2(cDate, cSeparator, nMinAge, nMaxAge)

* For WEB
GetTextWidth(str, fontName, fontSize)
GetTextHeight(str, fontName, fontSize)
AppendParameter(url, parameter)
GetCurrentPageName()

* For WEB Object
TreeView_NodeMouseOver(o)
TreeView_NodeMouseOut(o)
TreeView_NodeESControl(o, mustExtend, imageExtend, imageShrink, imageActiveHasChild, imageInactiveHasChild)
TreeView_NodeClick(o, url, urlTarget, imageExtend, imageShrink, imageActiveHasChild, imageInactiveHasChild)
Cell_SetColor(cell, backgroundColor, borderColor)
Row_SetColor(row, backgroundColor, borderColor, start, len)
CheckValueString(oObjects)
CheckValueNumberic(oObjects)
CheckValueDate(oObjects)
InitPageControl(oTable, tdClass, divClass)

***********************************
*/

// For Base
  function LTrim(str){
    if(str==null||str=="") return "";
    var left=0;
    for(; left<str.length; left++) if(str.charAt(left)!=" ") break;
    return str.substring(left);
  }
  
  function RTrim(str){
    if(str==null||str=="") return "";
    var right=str.length-1;
    for(; right>=0; right--) if(str.charAt(right)!=" ") break;
    return str.substring(0, right+1);
  }

  function Trim(str){
    return RTrim(LTrim(str));
  }

  function GetDate(separator){
    if(separator==null) separator="-";
    return DateToString(new Date(), separator);
  }

  function DateToString(date, separator){
    if(separator==null) separator="-";
    var nMonth=date.getMonth();
    var nDate=date.getDate();
    if(nMonth<9) nMonth="0"+(nMonth+1);
    if(nDate<9) nDate="0"+nDate;
    return date.getFullYear()+separator+nMonth+separator+nDate;
  }

  function CheckString(value, compare){
    if(compare==null) compare="";
    return Trim(value)==compare;
  }

  function CheckNumberic(value, min, max){
    if(isNaN(value)) return false;
    if(!isNaN(min)) if(value==Math.min(value, min)&&value!=min) return false;
    if(!isNaN(max)) if(value==Math.max(value, max)&&value!=max) return false;
    return true;
  }

  function CheckDate(value, separator, checkType){
    if(Trim(value)=="") return false;
    if(separator==null) separator="-";
    var aValue=value.split(separator);
    var cNow=GetDate(separator);
    var aNow=cNow.split(separator);
    var nLen=aValue.length;
    var i=0;
    if(nLen>3) nLen=3;
    for(i=0; i<nLen; i++){
      aValue[i]=Trim(aValue[i]);
      if(!isNaN(aValue[i])) aNow[i]=aValue[i];
    }
    var dTest=new Date(Date.UTC(parseInt(aNow[0], 10), parseInt(aNow[1], 10)-1, parseInt(aNow[2], 10)));
    cNow=DateToString(dTest);
    aNow=cNow.split(separator);
    var bPass=false;
    var nLen=aValue.length;
    if(!isNaN(checkType)){
      nLen=parseInt(checkType, 10);
      if(nLen<=0||nLen>3||nLen>aValue.length) nLen=aValue.length;
    }
    if(!isNaN(dTest)){
      for(i=0; i<aValue.length; i++){
        if(parseInt(aValue[i], 10)!=parseInt(aNow[i], 10)){
          return false;
        }
      }
      bPass=true;
    }
    return bPass;
  }

  // 将字符串转换成日期
  function ParseDate(cDate, cSeparator){
    try{
      var aDate=cDate.split(cSeparator);
      if(aDate[0].length<4) aDate[0]="1999".substring(0, 4-aDate[0].length)+aDate[0];
      aDate[0]=parseInt(aDate[0], 10);
      aDate[1]=parseInt(aDate[1], 10)-1;
      aDate[2]=parseInt(aDate[2], 10);
      var dDate=new Date();
      dDate.setFullYear(aDate[0], aDate[1], aDate[2]);
      if(dDate=="NaN") return null;
      else{
        if(aDate[1]!=dDate.getMonth()||aDate[2]!=dDate.getDate()) return null;
        return dDate;
      }
    }catch(e){
      return null;
    }
  }

  // 判断日期是否在制定年限内
  function CheckDate2(cDate, cSeparator, nMinAge, nMaxAge){
    try{
      var dDate=ParseDate(cDate, cSeparator);
      if(dDate==null) return false;
      var subT=(new Date()-dDate)/(365*24*60*60*1000);
      if(subT>=nMinAge && subT<=nMaxAge) return true;
    }catch(e){
    }
    return false;
  }


  function GetFileName(url){
    if(url==null) return "";
    var nPos=Math.max(url.lastIndexOf("/"), url.lastIndexOf("\\"));
    if(nPos>=0) url=url.substring(nPos+1);
    nPos=url.indexOf("?");
    if(nPos>=0) url=url.substring(0, nPos);
    return url;
  }

  function GetUnSuffixFileName(url){
    var filename=GetFileName(url);
    var nPos=filename.indexOf(".");
    if(nPos>=0) return filename.substring(0, nPos);
    else return filename;
  }

  function GetSuffix(url){
    var filename=GetFileName(url);
    var nPos=filename.indexOf(".");
    if(nPos>=0) return filename.substring(nPos+1, filename.length);
    else return "";
  }

  function ParseInt2(str){
    try{
      var result=parseInt(str, 10);
      if(isNaN(result)) return 0;
      return result;
    }catch(e){
      return 0;
    }
  }

// For WEB
  function GetTextWidth(str, fontName, fontSize){
    if(str==null) return 0;
    var myTestObjectName="__fc_testTextWidth";
    var otts=null;
    if(document.getElementById(myTestObjectName)==null){
      otts=document.createElement("div");
      otts.id=myTestObjectName;
      otts.style.overflow="auto";
      otts.style.width="0px";
      otts.style.height="0px";
      otts.noWrap=true;
      document.body.appendChild(otts);
    }else otts=document.getElementById(myTestObjectName);
    if(otts!=null){
      if(fontName!=null) otts.style.fontFamily=fontName;
      if(fontSize!=null) otts.style.fontSize=fontSize;
      otts.innerText=str;
      return otts.scrollWidth;
    }else return 0;
  }

  function GetTextHeight(str, fontName, fontSize){
    if(str==null) return 0;
    var myTestObjectName="__fc_testTextHeight";
    var otts=null;
    if(document.getElementById(myTestObjectName)==null){
      otts=document.createElement("div");
      otts.id=myTestObjectName;
      otts.style.overflow="auto";
      otts.style.width="0px";
      otts.style.height="0px";
      otts.noWrap=true;
      document.body.appendChild(otts);
    }else otts=document.getElementById(myTestObjectName);
    if(otts!=null){
      if(fontName!=null) otts.style.fontFamily=fontName;
      if(fontSize!=null) otts.style.fontSize=fontSize;
      otts.innerText=str;
      return otts.scrollHeight;
    }else return 0;
  }

  function AppendParameter(url, parameter){
    if(url==null) url="";
    if(parameter==null) parameter="";
    var nPos=url.indexOf("?");
    var cLinkKey="?";
    if(nPos>=0) cLinkKey="&";
    return url+cLinkKey+parameter;
  }

  function GetCurrentPageName(){
    return GetFileName(window.location.href);
  }

// For WEB Object

  function ClearOptions(oSelect){
    while(oSelect.options.length) oSelect.options.removeChild(oSelect.options[0]);
  }
  
  function AddOption(oSelect, cText, cValue){
    var oOption=document.createElement("OPTION");
    oSelect.options.add(oOption);
    oOption.innerText=cText;
    oOption.value=cValue;
  }

  function TreeView_NodeMouseOver(o){
    while(o!=null&&o.tagName!="SPAN") o=o.nextSibling;
    if(o==null) return;
    o.style.textDecoration="underline";
    o.style.color="#000000";
    o.previousSibling.style.cursor="hand";
    o.style.cursor="hand";
  }

  function TreeView_NodeMouseOut(o){
    while(o!=null&&o.tagName!="SPAN") o=o.nextSibling;
    if(o==null) return;
    o.style.textDecoration="";
    o.style.color="";
    o.previousSibling.style.cursor="default";
    o.style.cursor="default";
  }

  function TreeView_NodeESControl(o, mustExtend, imageExtend, imageShrink, imageActiveHasChild, imageInactiveHasChild){
    var oParentDiv=o.parentElement;
    if(mustExtend||oParentDiv.nextSibling.style.display=="none"){
      o.src=imageShrink;
      o.nextSibling.src=imageActiveHasChild;
      oParentDiv.nextSibling.style.display="";
    }else{
      o.src=imageExtend;
      o.nextSibling.src=imageInactiveHasChild;
      oParentDiv.nextSibling.style.display="none";
    }
  }

  function TreeView_NodeClick(o, url, urlTarget, imageExtend, imageShrink, imageActiveHasChild, imageInactiveHasChild){
    var oFolderControl=o;
    while(oFolderControl!=null&&oFolderControl.FolderControlMark!="true") oFolderControl=oFolderControl.previousSibling;
    if(oFolderControl!=null) TreeView_NodeESControl(oFolderControl, true, imageExtend, imageShrink, imageActiveHasChild, imageInactiveHasChild);
    DoAction(url, urlTarget);
  }

  function Cell_SetColor(cell, backgroundColor, borderColor){
    if(backgroundColor!=null){
      cell.bgColor=backgroundColor;
      cell.borderColor=backgroundColor;
    }
    if(borderColor!=null){
      cell.style.borderLeft=borderColor;
      cell.style.borderRight=borderColor;
      cell.style.borderTop=borderColor;
      cell.style.borderBottom=borderColor;
    }
  }

  function Row_SetColor(row, backgroundColor, borderColor, start, len){
    if(row==null) row=event.srcElement;
    while(row!=null && row.tagName!="TR") row=row.parentNode;
    
    if(row==null) return false;
    var i=0;
    var ocell=null;
    for(i=start;i<len;i++){
      ocell=row.cells(i);
      if(backgroundColor!=null){
        ocell.bgColor=backgroundColor;
        ocell.borderColor=backgroundColor;
      }
      if(borderColor!=null){
        if(i==start) ocell.style.borderLeft=borderColor;
        if(i+1==len) ocell.style.borderRight=borderColor;
        ocell.style.borderTop=borderColor;
        ocell.style.borderBottom=borderColor;
      }
    }
  }

  function CheckValueString(oObjects){
    for(var i=0; i<oObjects.length; i++){
      if(CheckString(oObjects[i].value)){
        var oLabel=Trim(oObjects[i].parentElement.parentElement.innerText);
        if(oLabel!="") oLabel=oLabel.substring(0, oLabel.length-1);
        alert("["+oLabel+"]不能为空，请选择或输入数据！");
        oObjects[i].focus();
        return false;
      }
    }
    return true;
  }

  function CheckValueNumberic(oObjects){
    for(var i=0; i<oObjects.length; i++){
      if(!CheckNumberic(oObjects[i].value)){
        var oLabel=Trim(oObjects[i].parentElement.parentElement.innerText);
        if(oLabel!="") oLabel=oLabel.substring(0, oLabel.length-1);
        alert("["+oLabel+"]无效数字，请重新输入数据！");
        oObjects[i].value="0";
        oObjects[i].focus();
        return false;
      }
    }
    return true;
  }

  function CheckValueDate(oObjects){
    for(var i=0; i<oObjects.length; i++){
      if(!CheckDate(oObjects[i].value)){
        var oLabel=Trim(oObjects[i].parentElement.parentElement.innerText);
        if(oLabel!="") oLabel=oLabel.substring(0, oLabel.length-1);
        alert("["+oLabel+"]无效日期，请重新输入数据！");
        oObjects[i].value="";
        oObjects[i].focus();
        return false;
      }
    }
    return true;
  }

  function InitPageControl(oTable, tdClass, divClass){
    if(oTable==null) return;
    if(tdClass==null) tdClass="PageControl_TD";
    if(divClass==null) divClass="PageControl_DIV";
    var row=null;
    var cell=null;
    var child=null;
    var o=null
    for(var i=0; i<oTable.rows.length; i++){
      row=oTable.rows(i);
      for(var j=0; j<row.cells.length; j++){
        cell=row.cells(j);
        if(cell.className==tdClass){
          for(var n=0; n<cell.children.length; n++){
            child=cell.children(n);
            if(child.className==divClass){
              for(var m=0; m<child.children.length; m++){
                o=child.children(m);
                nSW=0;
                nNS=0;
                switch(o.tagName){
                  case "SPAN":
                    child.style.width=ParseInt2(child.currentStyle.width)+GetTextWidth(o.innerText)+"px";
                    break;
                  case "IMG":
                    child.style.width=ParseInt2(child.currentStyle.width)+ParseInt2(o.width)+"px"
                    break;
                }
              }
            }
          }
        }
      }
    }
  }

// 获取对象
function GetHiddenObj(name){
  var obj=null;
  var objs=document.getElementsByTagName("input"); 
  for(var i=0; i<objs.length; i++){
    if (objs[i].type=="hidden" && objs[i].id.indexOf(name, 0)>=0){
      obj=objs[i];
      break;
    }
  }
  return obj;
}

// 自动设置父IFrame的高度
function SetIFrameHeight(testHeightObjID, iframeID){
  var _testObj=document.getElementById(testHeightObjID);
  var _iframe=parent.document.getElementById(iframeID);
  if(_testObj!=null){
    var _iframeHeight=_testObj.scrollHeight;
    _iframeHeight=_iframeHeight+60;
    _testObj.style.height=_iframeHeight;
    if (_iframe!=null) _iframe.height=_iframeHeight;
  }
}

// End

// JScript File
// 包含XML提示对象操作函数，在body onload中设置 InitHintControl()，TextBox.url指定xml来源url， TextBox.UrlPara指定附加条件，使用内容检测功能必须让checkValue=yes，如果不使用前缀必须设置onlyMe=yes
// 2008-09-26

var colorDown='#8592B5';
var colorOver='#b5bdd6';

// XML读取对象
var XMLLoader = new ActiveXObject("MSXML2.DOMDocument.3.0");
XMLLoader.async=false;
// 提示框中项目的数量
var hintListCount=0;
// 提示框中最后一次被选中的项目
var hintListOldRow=null;
// 输入框中上次的值
var hintInputOldValue="";

// Row_SetColor2 XML Hint 专用
  function Row_SetColor2(row, backgroundColor, borderColor, start, len){
    if(hintListOldRow!=null) Row_SetColor(hintListOldRow, '', borderColor, start, len);
    Row_SetColor(row, backgroundColor, borderColor, start, len);
    hintListOldRow=row;
  }
//

  // 将空格、大于、小于等字符转换成HTML可以显示的类型
  function HttpEncode(s){
    s=s.replace(/ /g, "&nbsp;");
    s=s.replace(/</g, "&lt;");
    s=s.replace(/>/g, "&gt;");
    return s;
  }

  // 将字符串限制在制定宽度内（s 字符串， maxWidth 最大宽度（数字）， fontSize 字体大小， fontName 字体名）
  function ConvertViewString(s, maxWidth, fontSize, fontName){
    if(typeof fontSize=="undefined") fontSize="9pt";
    if(typeof fontName=="undefined") fontName="宋体";
    var obj=document.getElementById("__testViewString");
    if(document.getElementById("test")==null){
      obj=document.createElement("<div>");
      obj.id="__testViewString";
      obj.style.overflowX="scroll";
      obj.style.overflowY="hidden";
      obj.style.height="1px";
      obj.style.width="1px";
      obj.style.fontSize=fontSize;
      obj.style.fontFamily=fontName;
      obj.style.top="-1px";
      obj.style.left="0px";
      obj.style.position="absolute";
      obj.style.zIndex="-1";
      obj.noWrap=true;
      document.body.insertBefore(obj);
    }else obj.style.display="";
    obj.innerText=s;
    if(obj.scrollWidth>maxWidth){
      var len=Math.floor(s.length*maxWidth/obj.scrollWidth);
      obj.innerText=s.substring(0, len-2)+"...";
      while(maxWidth>obj.scrollWidth){
        len=len+1;
        obj.innerText=s.substring(0, len-2)+"...";
      }
      while(obj.scrollWidth>maxWidth){
        len=len-1;
        obj.innerText=s.substring(0, len-2)+"...";
      }
    }
    obj.style.display="none";
    return obj.innerText;
  }

  // 将字符串转换成数字
  function ToNumber(s){
    var result="";
    var cs="";
    var pos=-1;
    var doted=false;
    if(isNaN(s)){
      for(var i=0; i<s.length; i++){
        cs=s.charAt(i);
        pos="+-.01234567890".indexOf(cs);
        if(pos>=0){
          if(pos<2&&result=="") result=cs;
          else{
            if(pos==2&&!doted){
              result=result+cs;
              doted=true;
            }else if(pos>2) result=result+cs;
          }
        }
      }
    }else result=s;
    var nResult=0;
    try{
      nResult=result*1;
    }catch(e){
    }
    return nResult;
  }

  // XML Hint 对象操作段    
  // 隐藏提示框
  function doHintPanelHidden(hintPanel){
    var obj=null;
    if(typeof hintPanel == "object") obj=hintPanel;
    else obj=document.getElementById(hintPanel);
    obj.style.display="none";
    hintListOldRow=null;
    hintListCount=0;
    hintInputOldValue="";
  }
    
  // 输入动作
  function doHintPanelShow(objHintInput, hintListName){
    var url=objHintInput.Url;
    var urlPara=objHintInput.UrlPara;
    var checkValue=objHintInput.CheckValue=="True";
    var valueField=objHintInput.DataValueField;
    var textField=objHintInput.DataTextField;
    var objHintPanel=document.getElementById(hintListName);
    var hintTableName="hintTable_"+objHintInput.id;

    objHintInput.valueChanged=false;
    
    // 设置HintPanel的位置和宽度
    if(objHintPanel.style.left==""){
      objHintPanel.style.left=GetWindowLeft(objHintInput);
      objHintPanel.style.top=GetWindowTop(objHintInput)+objHintInput.offsetHeight;
      objHintPanel.style.width=ToNumber(objHintInput.style.width);
    }
    
    // 按方向键（37左，39右）
    if(event.keyCode==37 || event.keyCode==39) return;
      
    // 按ESC键
    if(event.keyCode==27){
      doHintPanelHidden(objHintPanel);
      return;
    }
      
    // 按回车键
    if(event.keyCode==13 && hintListOldRow!=null){
      doHintSelected(objHintInput, hintListOldRow, objHintPanel);
      return;
    }
      
    // 按方向键（40向下，38向上）
    if(event.keyCode==40 || event.keyCode==38){
      if(hintListCount>0 && objHintPanel.style.display=="inline"){
        var currentRow=null;
        if(event.keyCode==40){
          if(hintListOldRow!=null) currentRow=hintListOldRow.nextSibling;
          if(currentRow==null) currentRow=document.getElementById(hintTableName).rows(0);
        }else{
          if(hintListOldRow!=null) currentRow=hintListOldRow.previousSibling;
          if(currentRow==null) currentRow=document.getElementById(hintTableName).rows(hintListCount-1);
        }
        Row_SetColor2(currentRow, colorOver, null, 0, 1);
      }
    }else{  // 正常输入
      // 内容无变化直接跳出
      if(hintInputOldValue==objHintInput.value) return;
      
      // 无内容关闭跳出
      if(objHintInput.value == ""){
        doHintPanelHidden(objHintPanel);
        return;
      }

      objHintInput.valueChanged=true;
      
      // 获得最大字符串长度
      var maxWidth=ToNumber(objHintInput.style.width);

      // 提示窗口处理
      hintListCount=0;
      XMLLoader.abort();

      // 获得url
      url=AppendParameter(url, objHintInput.SearchTextParaName+"="+escape(objHintInput.value));

      // 附加参数
      if(urlPara!="") url=AppendParameter(url, urlPara);
      try{
        XMLLoader.load(url);
        var items=XMLLoader.selectNodes("/Items/Item");
        var s="<table width=\"100%\" id=\""+hintTableName+"\" cellpadding=0 cellspacing=0 style=\"cursor: hand; z-index: 1\">";
        for(var i=0; i<items.length; i++){
          var node=items[i];
          var id=node.getAttribute(valueField);
          var name=node.getAttribute(textField);
          //var name2=HttpEncode(ConvertViewString(name, maxWidth));
          var name2=HttpEncode(name);
          s=s+"<tr title=\""+name+"\" itemID=\""+id+"\" onclick=\"doHintSelected(document.getElementById('"+objHintInput.id+"'), this, '"+objHintPanel.id+"');\" onmouseout=\"hintListOldRow=this;\" onmouseover=\"Row_SetColor2(this, colorOver, null, 0, 1);\"><td align=\"left\" style=\"height: 16px\"><span style=\"width: "+maxWidth+"; overflow:hidden; white-space:nowrap; text-overflow:ellipsis\">"+name2+"</span></td></tr>";
        }
        s=s+"</table>";
        hintListCount=items.length;
        if(items.length==0){
          doHintPanelHidden(objHintPanel);
          return;
        }
        hintListOldRow=null;
        hintInputOldValue=objHintInput.value;
        objHintPanel.innerHTML=s;
        objHintPanel.style.height=hintListCount*16;
        objHintPanel.style.display="inline";
      }catch(e){
        doHintPanelHidden(objHintPanel);
      }
    }
  }
    
  // 获得XML节点
  function GetXMLNode(xpath) {
    var value = XMLLoader.documentElement.selectSingleNode(xpath);
    return value;
  }

  // 获得XML节点的值
  function GetXMLNodeValue(xpath){
    var result = "";
    var node = GetXMLNode(xpath);
    if (node) result = node.text;
    return result;
  }
  
  // 获得XML节点属性的值
  function GetXMLNodeAttValue(xpath, xattribute){
    var result = "";
    var node = GetXMLNode(xpath);
    if (node) result = node.getAttribute(xattribute);
    return result;
  }
    
  // 内容被选中
  function doHintSelected(objHintInput, objTr, hintPanelName){
    var objValue=document.getElementById(objHintInput.AssistedTextValueObjName);
    if(objValue!=null) objValue.value=objTr.itemID;
    objHintInput.value=objTr.title;
    doHintPanelHidden(hintPanelName);
  }
    
  // 当输入框失去焦点， 使用内容检测功能必须让checkValue=true
  function doHintInputBlur(objHintInput, hintListName){
    var url=objHintInput.Url;
    var urlPara=objHintInput.UrlPara;
    var checkValue=objHintInput.CheckValue=="True";
    var valueField=objHintInput.DataValueField;
    var textField=objHintInput.DataTextField;
    var objHintPanel=document.getElementById(hintListName);
    
    if(typeof objHintInput.valueChanged=="undefined") objHintInput.valueChanged=false;
    
    if(!objHintPanel.contains(document.activeElement)){
      doHintPanelHidden(objHintPanel);
      
      var objValue=document.getElementById(objHintInput.AssistedTextValueObjName);
      if(checkValue&&objHintInput.value!=""&&objHintInput.valueChanged){
        url=AppendParameter(url, objHintInput.SearchTextParaName+"="+escape(objHintInput.value));
        if(urlPara!="") url=AppendParameter(url, urlPara);
        try{
          XMLLoader.load(url);
          var items=XMLLoader.selectNodes("/Items/Item");
          if(items.length>0){
            var node=items[0];
            if(objValue!=null) objValue.value=node.getAttribute(valueField);
            objHintInput.value=node.getAttribute(textField);
          }else{
            if(objValue!=null) objValue.value="";
            objHintInput.value="";
          }
        }catch(e){
        }
      }else if(checkValue&&objHintInput.value==""&&objValue!=null) objValue.value="";
    }
    objHintInput.valueChanged=false;
  }

  // 在某个对象前插入新对象
  function InsertAfter(newElement,targetElement) {
    var parent=targetElement.parentNode;
    if (parent.lastChild==targetElement) parent.appendChild(newElement);
    else parent.insertBefore(newElement,targetElement.nextSibling);
  }

  // 获得对象在窗口中的位置Left
  function GetWindowLeft(obj, endTag){
    if(typeof endTag=="undefined") endTag;
    var result=obj.offsetLeft;
    while(obj.parentElement!=null){
      if(endTag==obj.tagName) break;
      obj=obj.parentElement;
      result=result+obj.offsetLeft;
    }
    return result;
  }

  // 获得对象在窗口中的位置Top
  function GetWindowTop(obj, endTag){
    if(typeof endTag=="undefined") endTag;
    var result=obj.offsetTop;
    while(obj.parentElement!=null){
      if(endTag==obj.tagName) break;
      obj=obj.parentElement;
      if(obj.tagName=="TD" && endTag!=obj.tagName) continue;
      result=result+obj.offsetTop;
    }
    return result;
  }

// AssistedText 内容清除专用
function DoClearAT(objTextName, objValueName){
  var objText=document.getElementById(objTextName);
  var objValue=document.getElementById(objValueName);
  objText.value="";
  objValue.value="";
}

// 开关对象
function TurnObject(objName){
  var _obj=document.getElementById(objName);
  if(_obj!=null){
    if(_obj.style.display=="") _obj.style.display="none";
    else _obj.style.display="";
  }
}

// 打开日期选择
function OpenCal(objName){
  var _obj=document.getElementById(objName);
  if(_obj!=null){
    var windowName=objName.replace(/\$/g, "_");
    var w=window.open("CalendarDialog.aspx?ObjName="+objName+"&InitDateTime="+_obj.value,windowName,"height=200,width=350,top=240,left=240,resizable=no,status=no,toolbar=no,menubar=no,location=no,alwaysRaised=yes"); 
    w.focus();
  }
}