/*var showFlag=0;
window.onerror=function err(){
	if(document.all){
		alert("系统运行有误,请参照贴子进行处理!若问题仍然存在,请与客服联系。");
		if(showFlag!=1)window.open("http://bangpai.taobao.com/group/thread/514193-6320049.htm","ecPppWin","");
		showFlag=1;
		return true;
	}
}*/

  /**
   * 为与jquery标签进行区别,并提供快捷的调用标签
   */
function $e(element) {
  if (arguments.length > 1) {
    for (var i = 0, elements = [], length = arguments.length; i < length; i++)
      elements.push(Document.getObject(arguments[i]));
    return elements;
  }
  if (typeof element == 'string')
    element = document.getElementById(element);
  return element;
}

var floatFlag=1;
var Document = {
  /**
   * 回车切换
   */
  enterSwitch:function(){
    var evt=EventUtil.getEvent();
    var element = evt.srcElement || evt.target;
    var gk = evt.keyCode || evt.which;
    if (gk == 13) {
      if (element.tagName != 'TEXTAREA' &&
          element.type != "submit") {
        if(evt.keyCode)evt.keyCode=9;
        else if(evt.which)evt.which=9;
        return;
      }
    }
  },

	/*
	 最大化最小化窗口
	*/
	maximize:function(targetId){
			Document.width = $("#"+targetId).css("width");
			Document.height = $("#"+targetId).css("height");
			Document.top = $("#"+targetId).css("top");
			Document.left = $("#"+targetId).css("left");
			if(Document.width == '0px'){
				return;
			}
		    $("#"+targetId).animate({
				top: '0px',
				left: '0px',
				width:'100%',
				height:'100%'
			},"slow");
	 },
	 	
	 minimize:function(targetId){
		      $("#"+targetId).animate({
		      	width:Document.width,
		      	height:Document.height,
		      	top:Document.top,
		      	left:Document.left
		      },500);
	 },
	 
	 doMax : function(targetId){ 
	 	if(Document.isMax == null || Document.isMax == false){
	 		Document.maximize(targetId);
	 		Document.isMax = true;
	 	}
	 },
	 
	 doMin : function(targetId){
	 	if(Document.isMax == true){
	 		Document.minimize(targetId);
	 		Document.isMax = false;
	 	}
	 },
	 
	 doClose:function(allScreen,targetId){
	 	Document.isMax = null;
		var col = document.getElementById(targetId);
		if(Document.width != null && Document.height != null && Document.top != null && Document.left != null){
			col.style.width = '455px';
			col.style.height = '355px';
	        col.style.top=Document.top;   
	        col.style.left=Document.left;   
		}
		col.style.display = 'none';
	    $("#"+allScreen).hide();
		if(window.frames["CommonFrame"]){
			window.frames["CommonFrame"].document.selection.empty();
			window.frames["CommonFrame"].document.body.innerHTML="";
		}
	 },

	showAllScreen:function(parentElementID){
		var parentElement = Document.getObject(parentElementID);
		var scrollElement = Document.getScrollParent(parentElement);
		parentElement.style.width = scrollElement.offsetWidth + "px";
  		parentElement.style.height = scrollElement.offsetHeight + "px";
  		parentElement.style.display = "block";
  		 
	},
	
/**
 * 将浮动对象在窗口中居中显示
 * floatElementID:浮动对象ID
 */
    showCenter:function(floatElementID) {
        var floatElement = Document.getObject(floatElementID);
        var scrollElement = Document.getScrollParent(floatElement);
        var scrollWidth = parseInt(scrollElement.offsetWidth);
        var scrollHeight = parseInt(scrollElement.offsetHeight);
        var scrollTop = parseInt(scrollElement.scrollTop);
        var scrollLeft = parseInt(scrollElement.scrollLeft);

        var elementWidth = parseInt(floatElement.style.width);
        var elementHeight = parseInt(floatElement.style.height);
        /*    alert("offsetWidth="+floatElement.offsetWidth);
        alert("clientWidth="+floatElement.clientWidth);
        alert("currentStyle.width="+parseInt(floatElement.currentStyle.width));
        alert("runtimeStyle.width="+floatElement.runtimeStyle.width);
        alert("style.width="+floatElement.style.width);*/

        var left = (scrollWidth - elementWidth) / 2;
        if (left < 0) left = 0;
        var top = (scrollHeight - elementHeight) / 2;
        if (top < 0) top = 0;
        floatElement.style.top = scrollTop + top;
		floatElement.style.left = scrollLeft + left;
        floatElement.style.display = "inline";
    },

/**
 * 将浮动对象定位到指定对象下面
 * targetElement:目标对象
 * floatElement:浮动对象
 */
    snapElement:function(targetElement, floatElement) {
        floatElement.style.display = "inline";
        var pos = Document.adjustPosition(targetElement, floatElement);
        floatElement.style.left = pos.left;
        floatElement.style.top = pos.top;
		
		/*
		$(document).ready(function(){
        	if(floatFlag == 1){
        		$(floatElement).fadeIn("slow");
        		floatFlag = 0;
        	}else{
        		$(floatElement).fadeOut("slow");
        		floatFlag = 1;
        	}
        });
        */

    },
	
/**
 * 将浮动对象定位到指定对象下面
 * floatElement:浮动对象
 * destElement:目标对象
 */
    snapElementById:function(targetElement, floatElementId) {
    	var floatElement = Document.getObject(floatElementId);
        //floatElement.style.display = "inline";
        var pos = Document.adjustPosition(targetElement, floatElement);

        floatElement.style.left = pos.left;

        floatElement.style.top = pos.top;

        $(document).ready(function(){
        	if(floatFlag == 1){
        		$(floatElement).fadeIn("slow");
        		floatFlag = 0;
        	}else{
        		$(floatElement).fadeOut("slow");
        		floatFlag = 1;
        	}
        });
    },


/**
 * 调整浮动的层和对象的位置
 * targetElement:目标对象
 * floatElement:浮动的层对象
 */
    adjustPosition:function(targetElement, floatElement) {
        var scrollElement = Document.getScrollParent(targetElement);
        var top = targetElement.offsetTop;
        var left = targetElement.offsetLeft;
        var element = targetElement.offsetParent;
		
        //    var offLeft,offTop;
        while (element != scrollElement) {
            top += element.offsetTop;
            left += element.offsetLeft;
            element = element.offsetParent;
        }

        var targetWidth = targetElement.offsetWidth;
        //目标对象宽度
        var targetHeigth = targetElement.offsetHeight;
        //目标对象高度
        var floatWidth = floatElement.offsetWidth;
        //浮动层的宽度
        var floatHeight = floatElement.offsetHeight;
        //浮动层的高度
        var scrollWidth = scrollElement.clientWidth;
        //滚动条容器宽度(不计算任何边距、边框、滚动条)
        var scrollHeight = scrollElement.clientHeight;
        //滚动条容器高度(不计算任何边距、边框、滚动条)
        var scrollLeft = scrollElement.scrollLeft;
        //滚动条左边距
        var scrollTop = scrollElement.scrollTop;
        //滚动条上边距
        // alert(scrollLeft);
        // alert(scrollTop);

        if ((left + floatWidth > scrollLeft + scrollWidth) && (left + targetWidth - floatWidth > scrollLeft)) {
            left = left + targetWidth - floatWidth;
        }
        else {
            //      left+=1;
        }
        if ((top + targetHeigth + floatHeight > scrollTop + scrollHeight) && (top - floatHeight > scrollTop)) {
            top = top - floatHeight + 1;
        }
        else {
            top = top + targetHeigth;
        }
        return {"top":top,"left":left};
    },

/**
 * 获得对象所在的滚动条容器对象
 * element 对象
 */
    getScrollParent:function(element) {
		if(!isIE){
			return window.document.body;
		}else{
	        if (element == null) return null;
	        var elmt = element.offsetParent;
	        while (elmt != window.document.body) {
	            if (elmt.currentStyle.position == 'absolute' || elmt.currentStyle.position == 'relative' ||
	                (elmt.currentStyle.overflow != 'visible' && elmt.currentStyle.overflow != '' )) {
	                return elmt;
	            }
	            elmt = elmt.offsetParent;
	        }
	        return elmt;
		}
    },

/**
 * 获得对象
 * elementID:对象的id
 * objWindow:window对象
 * 
 */
    getObject: function (elementID, objWindow) {
        var obj;
        if (objWindow == null) {
            obj = window.document.getElementById(elementID);
        }
        else {
            obj = objWindow.document.getElementById(elementID);
        }
        return obj;
    },

/**
 * 获得对象数组
 * elementName:对象数组的名字
 * objWindow:window对象
 * 
 */
    getObjects: function (elementName, objWindow) {
        var objs;
        if (objWindow == null) {
            objs = window.document.getElementsByName(elementName);
        }
        else {
            objs = objWindow.document.getElementsByName(elementName);
        }
        return objs;
    },



/**
 * 通过Ajax提交表单数据
 * formName:表单名称
 * progressTitle:进度条显示文字
 * disponseFunction:请求完成后的处理函数
 * 
 */
    submitByAjax: function(formName, action, progressTitle, disponseFunction) {
        var objForm = Document.getObject(formName);
        var param = Form.serialize(formName).concat("&timeSerial=").concat(new Date().getTime());
        var url = (action == null) ? objForm.action : action;
        if (updateElement == null) updateElement = "bodyContent";
        var options = {
            method: "post",
            parameters: param,
            asynchronous:true,
            onCreate:Document.showTitle(progressTitle),
            onComplete: function(request) {
                window.Window.destroyProgress();
                disponseFunction(request);
            },
            onFailure:function(request) {
                if (progressTitle != null) {
                    window.Window.destroyProgress();
                }
                alert("系统出现错误!");
            }
        };
        var ajax = new Ajax.Request(url, options);
    },

/**
 * 通过Ajax触发链接请求
 * updateElement:请求完成后ajax局部更新的对象id
 * url:连接的jsp页面或action动作
 * 
 */
    linkByAjax:function (updateElement, url) {
		var param = ("timeSerial=").concat(new Date().getTime());
		var myAjax = new Ajax.Updater(
	        updateElement,
	        url, 
	        {
	            method: 'get',
				parameters: param,
	            evalScripts: true,
	            onCreate: function() {
	                $(updateElement).innerHTML="<img height=22 align=absmiddle src='/images/loading.gif'>loading.."; // 当创建Ajax请求时，显示loading
	            },
				onFailure:function(response) {
	                alert("读取数据出现错误！");
	            }
	        }
	    );
    },

/**
 * 响应完成
 * request:ajax的请求对象
 * updateElement:请求完成后ajax局部更新的对象id
 */
    responseComplete:function(request, updateElement) {
        var html = request.responseText;
        var upElement = Document.getObject(updateElement);
        window.setTimeout(
                function () {
                    window.Window.destroyProgress();
                    if (upElement == null) {
                        document.body.innerHTML = html.stripScripts();
                    }
                    else {
                        upElement.innerHTML = html.stripScripts();
                    }
                    window.setTimeout(
                            function() {
                                html.evalScripts()
                            }, 10);

                }, 10);
        window.top.Document.refreshStatus();
    },


/**
 * 执行一个ajax请求
 * url 请求动作
 * parameterObject 参数对象 如: {"name":"张三","sex":"男"}
 * disposeFunction ajax调用完成后的处理函数
 * progressTitle 进度条文本
 */
  requestByAjax:function (url, parameterObject, disposeFunction, progressTitle) {
    var topWin = window.top;
    var frameWindow = topWin.frames[Menu.frameContent];
    var _win = null;
    if (frameWindow)   _win = frameWindow;
    else _win = topWin;
    var showTitle = function() {
      if (progressTitle != null) {
        if(isIE)_win.Window.createProgress(progressTitle);
      }
    }
    var hash = $H(parameterObject);
    var param = hash.toQueryString();
    if (StringUtil.isEmpty(param)) {
      param = ("timeSerial=").concat(new Date().getTime());
    }
    else {
      param = param.concat("&timeSerial=").concat(new Date().getTime());
    }
    var options = {
      method: 'get',
      parameters: param,
      asynchronous:true,
      onCreate: showTitle(),
      onComplete: function(request) {
        if (progressTitle != null) {
          _win.Window.destroyProgress();
        }
        disposeFunction(request);
      },
      onFailure:function(request) {
        if (progressTitle != null) {
          _win.Window.destroyProgress();
        }
        alert("系统出现错误！");
      }
    }
    var ajax = new Ajax.Request(url, options);
  },



  /**post
 * 执行一个ajax请求
 * url 请求动作
 * parameterObject 参数对象 如: {"name":"张三","sex":"男"}
 * disposeFunction ajax调用完成后的处理函数
 * progressTitle 进度条文本
 */
    executeAjaxRequestPost:function (url, parameterObject, disposeFunction, progressTitle) {
      var topWin = window.top;
      var frameWindow = topWin.frames[Menu.frameContent];
      var _win = null;
      if (frameWindow)   _win = frameWindow;
      else _win = topWin;
      var showTitle = function() {
        if (progressTitle != null) {
          if(isIE)_win.Window.createProgress(progressTitle);
        }
      }
        var param = parameterObject;
        if (StringUtil.isEmpty(param)) {
            param = ("timeSerial=").concat(new Date().getTime());
        }
        else {
            param = param.concat("&timeSerial=").concat(new Date().getTime());
        }
        var options = {
            method: 'post',
            parameters: param,
            asynchronous:true,
            onCreate: showTitle(),
            onComplete: function(request) {
                if (progressTitle != null) {
                    _win.Window.destroyProgress();
                }
                disposeFunction(request);
            },
            onFailure:function(request) {
                if (progressTitle != null) {
                    _win.Window.destroyProgress();
                }
                alert("系统出现错误！");
            }
        }
        var ajax = new Ajax.Request(url, options);
    },

/**
 * 提交表单到新开窗口 普通
 * formName:表单名字
 * url:请求动作
 * progressTitle:进度条
 */
  submitNewWindow:function(formName, progressTitle, action) {
    var oForm = Document.getObject(formName);
    var oldUrl = oForm.action ;
    var oldTarget = oForm.target ;
    if (action != null) oForm.action = action;
    var resizablebar = "yes"
    var width = 800;
    var height = 600;
    var sFeatures = "scrollbars=no, status=no, resizable=" + resizablebar + ","
        + "toolbar=no, menubar=no, location=no, titlebar=no,width="+width+",height="+height;
    var left = (screen.availWidth - width) / 2;
    var top = (screen.availHeight - height) / 2;
    sFeatures += ",top=" + top + ",left=" + left;
    var postform = function() {
      oForm.target = oWin.name;
      oForm.submit();
      oForm.action = oldUrl;
      oForm.target = oldTarget;
    }

    var oWin = window.open("about:blank", 'openNoBar' + StringUtil.randomChar(20), sFeatures);
    oWin.resizeTo(width, height);
    if (progressTitle != null) {
      Window.writeProgress(progressTitle,oWin);
      postform();
    }
    else {
      postform();
    }
  },
  
  open:function (title,url,w,h){
        var pop=new Popup({ contentType:1,isReloadOnClose:false,width:w,height:h});
		pop.setContent("contentUrl",url);
		pop.setContent("title",title);
		pop.build();
		pop.show();
   },

/**
 * 设置链接,当前页面 普通
 * url:连接的jsp页面或action动作
 * parameterObject:参数对象
 * progressTitle:进度条文字
 * frameName:frame的名称
 * 
 */
    link:function (url, progressTitle, frameName) {
        var topWin = window.top;
        var frameWindow = window.top.frames[Menu.frameContent];
        var _win = null;
        if (frameWindow)_win = frameWindow;
        else _win = topWin;
        var win = (frameName == null) ? window : window.frames[frameName];
        if (progressTitle == null) {
            win.location = url;
        }
        else {
            if (_win.Window) {
                if(isIE)_win.Window.createProgress(progressTitle);
                win.location = url;
//                if (_win.Window) _win.Window.listenWindowState(win);
            }
            else {
             	Window.writeProgress(progressTitle,_win);
             	win.location = url;
            }
        }
    },
	
	appendCommonDiv:function(){
		if(!Document.getObject("FullScreenDiv")){
			var FullScreenDiv=document.createElement("div");
			FullScreenDiv.id="FullScreenDiv";
			FullScreenDiv.name="FullScreenDiv";
			window.document.body.appendChild(FullScreenDiv);
		}
		if(!Document.getObject("CommonDiv")){
				var innerHTML = '	<iframe width="100%" height="100%" frameborder="0" src="about:blank"';
				innerHTML += '		style="position: absolute; top: 0; left: 0; filter: progid : DXImageTransform . Microsoft . Shadow(Color = #555555, Direction = 120, strength = 5);"></iframe>';
				innerHTML += '	<table class="table" width="100%" height="100%" cellpadding="0"';
				innerHTML += '		cellspacing="1" style="position: absolute; top: 0; left: 0;">';
				innerHTML += '		<tr class="title">';
				innerHTML += '			<td valign=middle >';
				innerHTML += '				<div style="font-size:13px;float:left;" id="CommonDivTitle" ></div>';
				innerHTML += '				<div style="float: right;">';
				innerHTML += '				<a href="#" onClick="Document.doMin(\'CommonDiv\');return false;"';
				innerHTML += '					style="vertical-align: bottom; cursor: pointer; text-decoration: underline;"><img src="/images/min.png" border=0></a>';
				innerHTML += '				<a href="#" onClick="Document.doMax(\'CommonDiv\');return false;"';
				innerHTML += '					style="vertical-align: bottom; cursor: pointer; text-decoration: underline;"><img src="/images/max.png" border=0></a>';
				innerHTML += '				<a href="#" onClick="Document.doClose(\'FullScreenDiv\',\'CommonDiv\');"';
				innerHTML += '					style="vertical-align: bottom; cursor: pointer; text-decoration: underline;"><img src="/images/close.png" border=0></a>';
				innerHTML += '				</div>';
				innerHTML += '			</td>';
				innerHTML += '		</tr>';
				innerHTML += '		<tr>';
				innerHTML += '			<td style="height: 100%">';
				innerHTML += '				<iframe width="100%" height="100%" frameborder="0"';
				innerHTML += '					id="CommonFrame" name="CommonFrame"></iframe>';
				innerHTML += '			</td>';
				innerHTML += '		</tr>';
				innerHTML += '	</table>';

				var CommonDiv=document.createElement("div");
				CommonDiv.id="CommonDiv";
				CommonDiv.name="CommonDiv";
				CommonDiv.style.width="450px";
				CommonDiv.style.height="300px";
				CommonDiv.style.top="0px";
				CommonDiv.style.left="0px";
				//CommonDiv.style.zIndex=alldivnum+100;
				CommonDiv.style.zIndex=999;
				CommonDiv.style.position="absolute";
				CommonDiv.style.cursor="move";
				CommonDiv.style.display="none";
			
				CommonDiv.onmousedown=function(){Drag.down(this);}
				CommonDiv.onmousemove=function(){Drag.move(this);}
				CommonDiv.onmouseup=function(){Drag.up(this);}
			
				CommonDiv.innerHTML=innerHTML;
				window.document.body.appendChild(CommonDiv);
		}
	},

/**
 * url:连接的jsp页面或action动作
 * title:功能标题
 * progressTitle:进度条文字
 * width:div的宽
 * height:div的高
 */
    commonFrameLink:function(url, title, progressTitle, width, height, doMax){
		  	Document.appendCommonDiv();
		  	if (width != null)Document.getObject("CommonDiv").style.width=width+"px";
		  	if (height != null)Document.getObject("CommonDiv").style.height=height+"px";
			Document.showCenter("CommonDiv");
			if (doMax!=null && doMax=="1"){
				Document.doMax('CommonDiv');
			}
			Document.showAllScreen('FullScreenDiv');
		    window.frames["CommonFrame"].location="about:blank";
			
		    Document.getObject("CommonDivTitle").innerHTML = "&nbsp;"+title;
		    Document.link(url,progressTitle,"CommonFrame");
	},
		  
	/**
	   * 关闭层
	   */
	closeCommonLayer:function(){
		if(window.frames["CommonFrame"])window.frames["CommonFrame"].document.body.innerHTML="";
	    Document.showHiddenObject('CommonDiv',false);
		if($("#FullScreenDiv"))$("#FullScreenDiv").hide();
	},
	
   /**
   * 关闭父窗口的层
   */
    closeParentCommonLayer:function(){
	    window.location="about:blank";
	    parent.Document.showHiddenObject('CommonDiv',false);
		if(parent.$("#FullScreenDiv"))parent.$("#FullScreenDiv").hide();
   },
   
   /**
   * 刷新窗口
   */
    refresh:function(progressTitle){
	    Window.writeProgress(progressTitle,window);
	    window.location.reload(1);
   },
	
   /**
   * 删除记录
   * IDName:checkbox框id或name
   * formName:表单名称
   * msg:提示信息
   * progressTitle:进度条文字
   * eg:commonDelete("id","commonDeleteForm","请选择要删除的项","数据删除中");
   */
  commonDelete:function(IDName, formName, msg, progressTitle){
    if(CheckUtil.isUnSelected(IDName,msg)) return;
    if(confirm('确实要删除选中的项吗？')){
		Document.appendCommonDiv();
		
		window.frames["CommonFrame"].location="about:blank";
		Document.showHiddenObject("CommonDiv",false);
      	Document.submit(formName,progressTitle, null, "CommonFrame");
    }
  },

/**
 * 提交当前页面的表单
 * formName:表单名称
 * progressTitle:进度条文字
 * action:表单提交动作
 * frameName:表单提交窗口
 */
    submit:function (formName, progressTitle, action, frameName) {
      var topWin = window.top;
      var frameWindow = topWin.frames[Menu.frameContent];
      var _win = null;
      if (frameWindow)   _win = frameWindow;
      else _win = topWin;

        var oForm = Document.getObject(formName);
        var oldTarget = oForm.target;
        var oldAction = oForm.action;
        var win = (frameName == null) ? window : window.frames[frameName];

        var formSubmit = function() {
            if (action != null) oForm.action = action;
            if (frameName != null) oForm.target = frameName;
            oForm.submit();
            if (action != null) oForm.action = oldAction;
            if (frameName != null) oForm.target = oldTarget;
        }
        if (progressTitle == null) {
            formSubmit();
        }
        else {
            if (_win.Window) {
                if(isIE)_win.Window.createProgress(progressTitle);
                formSubmit();
//              if (_win.Window) _win.Window.listenWindowState(win);
            }
            else {
              Window.writeProgress(progressTitle,_win);
              formSubmit();
            }
        }

    },

/**
 * 触发动作的对象必须是inupt,button等
 * 清除表单上的非隐藏域输入框的值
 * formName: 表单名
 * clearHidden: 是否清空隐藏域 true or false
 * 
 */
    clearForm:function (formName, clearHidden) {
        var objForm = Document.getObject(formName);
        for (var i = 0; i < objForm.elements.length; i++) {
            var object = objForm.elements[i]
            if (object.tagName == "INPUT") {
                if (object.type == "file" || object.type == "password" || object.type == "text") {
                    object.value = "";
                }
                /*if(object.type=="checkbox" || object.type=="radio"){
                  object.checked=false;
                }*/
                if (object.type == "hidden") {
                    if (clearHidden != null && clearHidden) {
                        object.value = "";
                    }
                }
            }
            if (object.tagName == "SELECT") {
                object.value = "";
            }
            if (object.tagName == "TEXTAREA") {
                object.value = "";
            }
        }
    },


/**
 * 显示和隐藏对象
 * IDName:对象ID
 * status:根据状态来显示和隐藏(可选) true or false
 * 
 */
    showHiddenObject: function (IDName, status) {
        try {

           var obj = (IDName.constructor==String ) ? Document.getObject(IDName) : IDName;
            if (status != null) {
                obj.style.display = (status) ? "inline" : "none";
				floatFlag = (status) ? 0 : 1;
            }
            else {
                obj.style.display = (obj.style.display == "none") ? "inline" : "none";
				floatFlag = (obj.style.display == "none") ? 0 : 1;
            }
        }
        catch(e) {
        }
    },

/**
 * 复选框的状态选择
 * IDName:checkbox框id或name
 * status:选中状态 true or false
 */
    statusChecked:function (IDName, status) {
        var objCheckBoxs = Document.getObjects(IDName);
        if (objCheckBoxs != null) {
            for (var i = 0; i < objCheckBoxs.length; i++) {
            	if(objCheckBoxs[i].disabled!=true){
                	objCheckBoxs[i].checked = (status != null) ? status : (!objCheckBoxs[i].checked);
            	}
            }
        }
    },

/**
 * 分页取码窗口的复选框状态选中函数()
 * parentHiddenName:opener窗口中的隐藏域名称(数组)
 * selfCheckBoxName:当前窗口中的复选框名(数组)
 */
    statusCheckedById:function (parentHiddenName, selfCheckBoxName) {
        var objHiddens = window.top.opener.document.getElementsByName(parentHiddenName);
        var objCheckBoxs = window.document.getElementsByName(selfCheckBoxName);
        if (objHiddens == null) return;
        if (objCheckBoxs == null) return;
        var checkBoxValue;
        var hiddenValue;
        for (var i = 0; i < objCheckBoxs.length; i++) {
            checkBoxValue = objCheckBoxs[i].value;
            for (var j = 0; j < objHiddens.length; j++) {
                hiddenValue = objHiddens[j].value;
                if (checkBoxValue == hiddenValue) {
                    objCheckBoxs[i].checked = true;
                    break;
                }
            }
        }
    },

/**
 * 分页取码窗口的复选框状态选中函数(单个输入框中值以逗号分割)
 * parentInputName:opener窗口中的输入框名称
 * selfCheckBoxName:当前窗口中的复选框名(数组)
 */
    statusCheckedByName:function (parentInputName, selfCheckBoxName) {
        var objInput = window.top.opener.document.getElementById(parentInputName);
        var objCheckBoxs = window.document.getElementsByName(selfCheckBoxName);
        if (objInput == null) return;
        if (objCheckBoxs == null) return;
        var inputValue = objInput.value;
        var checkBoxValue;
        for (var i = 0; i < objCheckBoxs.length; i++) {
            checkBoxValue = objCheckBoxs[i].value;
            if (inputValue.indexOf(checkBoxValue) != -1) {
                objCheckBoxs[i].checked = true;
            }
        }
    },

/**
 * 所有子复选框被选中后，父复选框自动被选中；反之，则未选中
 * cellsBoxName 子复选框名称
 * mainBoxName全选父复选框名称
 * written by Clark Fan
 */
    superStatusAutoChecked:function(cellsBoxName, mainBoxName) {
        var objLen = 0;
        var objs = Document.getObjects(cellsBoxName);
        for (var i = 0; i < objs.length; i++) {
            if (objs[i].checked) {
                objLen += 1;
            }
        }
        Document.getObject(mainBoxName).checked = objs.length == objLen;
    },

/**
 * 刷新状态栏的进度
 */
    refreshStatus:function() {
        var objIFrame = window.document.createElement("<IFRAME name='refreshWindowStatus'></IFRAME>");
        objIFrame.style.display = "none";
        window.document.body.appendChild(objIFrame);
        var iframeDoc = window.frames["refreshWindowStatus"].document.open("text/html", "replace");
        with (iframeDoc) {
            writeln("<html>");
            writeln("<body>");
            writeln("<script>");
            writeln("window.top.status='完成';");
            writeln("<\/script>");
            writeln("<\/body>");
            writeln("<\/html>");
        }
        iframeDoc.close();
        window.document.body.removeChild(objIFrame)
    }  ,

/**
 * 回车代替tab
 * 
 */
    handleKey:function () {
        var evt=EventUtil.getEvent();
	    var element = evt.srcElement || evt.target;
	    var gk = evt.keyCode || evt.which;
        if (gk == 13) {
            if (element.tagName != 'TEXTAREA') {
                if(evt.keyCode)evt.keyCode=9;
          		else if(evt.which)evt.which=9;
            }
        }
    },

/*
* 点击iframe窗口时关闭主菜单
* 
*/
    hiddenMenu:function() {
        if (window.top != window) {
            if (Document.getObject('menuBar', window.top) != null) {
                window.top.document.body.click();
            }
        }
    },


/**
 * 像radio一样的复选框
 */
    statusCheckedAsRadio:function(object) {
        var name = object.name;
        var objCheckBoxs = Document.getObjects(name);
        if (objCheckBoxs != null) {
            for (var i = 0; i < objCheckBoxs.length; i++) {
                if (objCheckBoxs[i] != object) {
                    objCheckBoxs[i].checked = false;
                }
            }
        }
    },

    exportExcel:function(elementID, filename) {
        var iframe = Document.getObject("exportExcelFrame");
        var form = Document.getObject("exportExcelForm");
        if (!iframe) {
            iframe = window.document.createElement("<iframe name='exportExcelFrame' style='display:none'></iframe>");
            document.body.appendChild(iframe);
        }
        if (!form) {
            form = window.document.createElement("<form name='exportExcelForm' target='exportExcelFrame' style='display:none' method='post'></form>")
            form.action = "pageExportExcel.system";
            var input = window.document.createElement("<input type='hidden' name='filename'>");
            var textarea = window.document.createElement("<textarea name='content' style='display:none'></textarea>")
            form.appendChild(input);
            form.appendChild(textarea);
            document.body.appendChild(form);
        }
        form.elements("filename").value = filename;
        form.elements("content").value = Document.getObject(elementID).outerHTML;
        form.submit();
    },
    exportDoc:function(ElementId, filename) {
        var iframe = Document.getObject("exportExcelFrame");
        var form = Document.getObject("exportExcelForm");
        if (!iframe) {
            iframe = window.document.createElement("<iframe name='exportExcelFrame' style='display:none'></iframe>");
            document.body.appendChild(iframe);
        }
        if (!form) {
            form = window.document.createElement("<form name='exportExcelForm' target='exportExcelFrame' style='display:none' method='post'></form>")
            form.action = "pageExportDoc.system";
            var input = window.document.createElement("<input type='hidden' name='filename'>");
            var textarea = window.document.createElement("<textarea name='content' style='display:none'></textarea>")
            form.appendChild(input);
            form.appendChild(textarea);
            document.body.appendChild(form);
        }
        form.elements("filename").value = filename;
        form.elements("content").value = Document.getObject(ElementId).innerHTML;
        form.submit();
    }
}

