var navLoad = function(){
	try{
//		if(parent.list_top == window){
//			Show_MiddleAll();
////			setTimeout("Show_MiddleAll()",10);
//		}
	}catch(e){
//		alert(e)
	}
	try{
//		var box = document.getElementById("contentBox");//修改页面自适应外围框
//	  	var rightFra = window.parent.document.getElementById("yangxh");//父框架
//		var boxHeight = window.screen.height-106-230;//屏幕高度-顶部框架高度-调整宽度
//		if(rightFra != null){
//		    var a=parseInt(rightFra.getAttribute("rows").split(",")[0]);      
//		    var b=parseInt(rightFra.getAttribute("rows").split(",")[1]);
//			boxHeight = boxHeight-a-b;               //-上部框架高度-中部框架高度
//		}
//		if(box != null){
//			box.style.height = boxHeight;
//		}
	}catch(e){
//		alert(e)
	}
	try{
		//IE6兼容性适配
		  if(window.dialogArguments == null){
		    return; //忽略非模态窗口
		  }
		  var ua = navigator.userAgent;
		  var height = document.body.offsetHeight;
		  if(ua.lastIndexOf("MSIE 6.0") != -1){
		  	var height = document.body.offsetHeight;
		    window.dialogHeight=(height+40)+"px";
		  }
	}catch(e){
	
	}
};
// DOM2
if ( typeof window.addEventListener != "undefined" )
	window.addEventListener( "load", navLoad, false );

// IE 
else if ( typeof window.attachEvent != "undefined" ) {
	window.attachEvent( "onload", navLoad );
}

else {
	if ( window.onload != null ) {
		var oldOnload = window.onload;
		window.onload = function ( e ) {
			oldOnload( e );
			navLoad();
		};
	}
	else 
		window.onload = navLoad;
}

////正式部署时启用以下代码，避免页面上脚步错误
//window.onerror = function(){return true;};

//*********************************************************
// 装载公用设置
//*********************************************************
//window.onerror=function(){return true;};
String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.ltrim = function() {
    return this.replace(/(^\s*)/g, "");
}
String.prototype.rtrim = function() {
    return this.replace(/(\s*$)/g, "");
}
/**
 * 按照dwr重的$函数进行定义，以便普通页面中要使用prototype的$函数时不需要包含prototype.js文件
 */
var $;
if (!$) {
    $ = function(){
        if (document.getElementById) {
            var elements = new Array();
            for (var i = 0; i < arguments.length; i++) {
                var element = arguments[i];
                if (typeof element == 'string') {
                    element = document.getElementById(element);
                }
                if (arguments.length == 1) {
                    return element;
                }
                elements.push(element);
            }
            return elements;
        }
        else if (document.all) {
            var elements = new Array();
            for (var i = 0; i < arguments.length; i++) {
                var element = arguments[i];
                if (typeof element == 'string') {
                    element = document.all[element];
                }
                if (arguments.length == 1) {
                    return element;
                }
                elements.push(element);
            }
            return elements;
        }
    }
};
var WWUtils = {
	/**
	 * 说明：设置输入框表单只能录入数字
	 * 用法：
	 */
	setInputNumber : function(input) {
		if (input) {
			input.onkeyup = function(){this.value = this.value.replace(/\D/g,'')};
			input.onafterpaste = function(){this.value = this.value.replace(/\D/g,'')};
			input.onchange = function(){this.value = this.value.replace(/\D/g,'');};
			input.onblur = function(){this.value = this.value.replace(/\D/g,'')};
		}
	},
	/**
	 * 获取当前web路径
	 * @param {Object} jsName 传入当前js的文件名称
	 */
	getCurrentServletPath : function(jsName) {
		var i, base, src = jsName, scripts = document.getElementsByTagName("script");
		for (i=0; i<scripts.length; i++){
			if (scripts[i].src.match(src)){ 
				var reg=new RegExp(src);
				base = scripts[i].src.replace(reg, "");
				break;
			}
		}
		return base;
	}
};
//*********************************************************
// 图片装载
//*********************************************************
function imgLoad() {
  var img = new Array();
  for(var i = 0; i < imgLoad.arguments.length; i++) {
    img[i] = new Image();
    img[i].src = imgLoad.arguments[i];
  }
}

//*********************************************************
// 准确的获得页面和窗口的高和宽，返回类型为new Array(页面宽度,页面高度,窗口宽度,窗口高度)
//*********************************************************
function getPageSize(){ 
	var xScroll, yScroll; 
	if (window.innerHeight && window.scrollMaxY) { 
		xScroll = document.body.scrollWidth; 
		yScroll = window.innerHeight + window.scrollMaxY; 
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac 
		xScroll = document.body.scrollWidth; 
		yScroll = document.body.scrollHeight; 
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari 
		xScroll = document.body.offsetWidth; 
		yScroll = document.body.offsetHeight; 
	}

	var windowWidth, windowHeight; 
	if (self.innerHeight) { // all except Explorer 
		windowWidth = self.innerWidth; 
		windowHeight = self.innerHeight; 
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode 
		windowWidth = document.documentElement.clientWidth; 
		windowHeight = document.documentElement.clientHeight; 
	} else if (document.body) { // other Explorers 
		windowWidth = document.body.clientWidth; 
		windowHeight = document.body.clientHeight; 
	}
	
	// for small pages with total height less then height of the viewport 
	if(yScroll < windowHeight){ 
		pageHeight = windowHeight; 
	} else { 
		pageHeight = yScroll; 
	} 
	// for small pages with total width less then width of the viewport 
	if(xScroll < windowWidth){ 
		pageWidth = windowWidth; 
	} else { 
		pageWidth = xScroll; 
	} 
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize; 
}

//*********************************************************
// 目的：    AJAX类
// 输入：    无
// 返回：    返回XMLHttp对象
// 例子：    var myConn = new XHConn();
//
//           if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
//
//           var fnWhenDone = function (oXML) { alert(oXML.responseText); };
//
//           myConn.connect("mypage.php", "POST", "foo=bar&baz=qux", fnWhenDone);
//
//*********************************************************
function XHConn(sync)
{
  var xmlhttp = false, bComplete = false;
  if (arguments.length > 0) {
	if (typeof arguments[0] == "boolean" ) {
        this.sync = arguments[0];
    }
  } else this.sync = true;
  
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sVars = (sVars == '') ? Math.random() : sVars + "&" + Math.random( );
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, this.sync);
        xmlhttp.setRequestHeader("Content-Type", "text/html;charset=GBK");
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, this.sync);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type", 
          "application/x-www-form-urlencoded");
        xmlhttp.setRequestHeader("Content-Type", "text/html;charset=GBK");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
        }};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}

function createXMLHttpRequest() {
    var xmlhttp;
    try {
        xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
    } catch(e) {
        try {
            xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
        } catch(e) {
            try {
                xmlhttp = new XMLHttpRequest();
            } catch(e) {
                alert("创建XMLHttpRequest对象失败！");
            }
        }
    }
    this.connect = function(sURL, sMethod,sType){
    	if (!xmlhttp) return false;
    	xmlhttp.open(sMethod, sURL, sType);　//传递数据的方法同样有GET和POST两种,但是当方法为POST时下面的一句话就必须写
	 	xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.send(null) 
    }
    this.xmlhttp = 	xmlhttp;
    return this;
}
//*********************************************************
// 包含文件
//*********************************************************
function $import(path, type){
	var i, base, src = "common\\.js", scripts = document.getElementsByTagName("script");
	for (i=0; i<scripts.length; i++){if (scripts[i].src.match(src)){var reg=new RegExp(src);base = scripts[i].src.replace(reg, "");break;}}
	if (type == "css") {
    document.write("<" + "link href=\"" + base + path + "\" rel=\"stylesheet\" type=\"text/css\"></" + "link>");
  } else {
    document.write("<" + "script src=\"" + base + path + "\"></" + "script>");
  }
}

//*********************************************************
// 判断类型
//*********************************************************
function isAlien(a) {
  return isObject(a) && typeof a.constructor != 'function';
}

function isArray(a) {
  return isObject(a) && a.constructor == Array;
}

function isBoolean(a) {
  return typeof a == 'boolean';
}

function isEmpty(o) {
  var i, v;
  if (isObject(o)) {
    for (i in o) {
      v = o[i];
      if (isUndefined(v) && isFunction(v)) {
        return false;
      }
    }
  }
  return true;
}

function isFunction(a) {
  return typeof a == 'function';
}

function isNull(a) {
  return typeof a == 'object' && !a;
}

function isNumber(a) {
  return typeof a == 'number' && isFinite(a);
}

function isObject(a) {
  return (a && typeof a == 'object') || isFunction(a);
}

function isString(a) {
  return typeof a == 'string';
}

function isUndefined(a) {
  return typeof a == 'undefined';
}

//*********************************************************
// 装载公共功能
//*********************************************************
//$import("prototype.js");

//*********************************************************
// 在DOM后面插入对象
//*********************************************************
function insertAfter(parent, node, referenceNode) {
	parent.insertBefore(node, referenceNode.nextSibling);
}

//*********************************************************
// 创建一个新的DOM对象
/**
 * document.createElement convenience wrapper
 *
 * The data parameter is an object that must have the "tag" key, containing
 * a string with the tagname of the element to create.  It can optionally have
 * a "children" key which can be: a string, "data" object, or an array of "data"
 * objects to append to this element as children.  Any other key is taken as an
 * attribute to be applied to this tag.
 *
 * Available under an MIT license:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * @param {Object} data The data representing the element to create
 * @return {Element} The element created.
 */
//*********************************************************
function $E(data) {
    var el;
    if ('string'==typeof data) {
        el=document.createTextNode(data);
    } else {
        //create the element
        el=document.createElement(data.tag);
        delete(data.tag);

        //append the children
        if ('undefined'!=typeof data.children) {
            if ('string'==typeof data.children ||
                'undefined'==typeof data.children.length
            ) {
                //strings and single elements
                el.appendChild($E(data.children));
            } else {
                //arrays of elements
                for (var i=0, child=null; 'undefined'!=typeof (child=data.children[i]); i++) {
                    el.appendChild($E(child));
                }
            }
            delete(data.children);
        }

        //any other data is attributes
        for (attr in data) {
            el[attr]=data[attr];
        }
    }

    return el;
}

//*********************************************************
// cookie操作
//*********************************************************
var Cookies = {};
/**//**
 * 设置Cookies
 */
Cookies.set = function(name, value){
     var argv = arguments;
     var argc = arguments.length;
     var expires = (argc > 2) ? argv[2] : null;
     var path = (argc > 3) ? argv[3] : '/';
     var domain = (argc > 4) ? argv[4] : null;
     var secure = (argc > 5) ? argv[5] : false;
     document.cookie = name + "=" + escape (value) +
       ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
       ((path == null) ? "" : ("; path=" + path)) +
       ((domain == null) ? "" : ("; domain=" + domain)) +
       ((secure == true) ? "; secure" : "");
};
/**//**
 * 读取Cookies
 */
Cookies.get = function(name){
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    var j = 0;
    while(i < clen){
        j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return Cookies.getCookieVal(j);
        i = document.cookie.indexOf(" ", i) + 1;
        if(i == 0)
            break;
    }
    return null;
};
/**//**
 * 清除Cookies
 */
Cookies.clear = function(name) {
  if(Cookies.get(name)){
    var expdate = new Date(); 
    expdate.setTime(expdate.getTime() - (86400 * 1000 * 1)); 
    Cookies.set(name, "", expdate); 
  }
};

Cookies.getCookieVal = function(offset){
   var endstr = document.cookie.indexOf(";", offset);
   if(endstr == -1){
       endstr = document.cookie.length;
   }
   return unescape(document.cookie.substring(offset, endstr));
};
var __currDate = new Date();
Cookies.ONE_DAY = new Date(__currDate.getFullYear(), __currDate.getMonth() + 1, __currDate.getDay() + 1);		/*1天*/
Cookies.ONE_WEEK = new Date(__currDate.getFullYear(), __currDate.getMonth() + 1, __currDate.getDay() + 7);		/*1周*/
Cookies.ONE_MONTH = new Date(__currDate.getFullYear(), __currDate.getMonth() + 2, __currDate.getDay());			/*1月*/
Cookies.ONE_YEAR = new Date(__currDate.getFullYear() + 1, __currDate.getMonth() + 1, __currDate.getDay());		/*1年*/
Cookies.NO_EXPIRSE = new Date(__currDate.getFullYear() + 100, __currDate.getMonth() + 1, __currDate.getDay());	/*不过期(100年)*/
Cookies.getAnyDate = function(days) {	/*任意天数，输入为number型的数字*/
	return new Date(__currDate.getFullYear(), __currDate.getMonth() + 1, __currDate.getDay() + (parseInt(days) == NaN ? 1 : days));
}
//多选
function selectCheckbox(obj) {
  var chks = document.getElementsByName('flag_id');
  for (var i = 0; i < chks.length; i++) {
  	if (chks[i].disabled) {
  		continue;
  	}
    chks[i].checked = obj.checked;
    chkRow(chks[i]);
  }
}
function del(form) {
    var d = document.getElementsByName('flag_id');
    var sel = [];
    for (var i = 0; i < d.length; i++) {
        if (d[i].checked) {
            sel[sel.length] = d;
        }
    }
	if (form) {
	    if (sel.length > 0) {
	        if (window.confirm('您确定要删除选中的项目吗？')) {
	            document.forms[form].submit();
	    	}
	    } else {
	    	alert('请先选择要删除的项目！');
	        return;
	    }
	} else {
		if (sel.length > 0) {
	        if (window.confirm('您确定要删除选中的项目吗？')) {
	            return true;
	    	} else return false;
	    } else {
	    	alert('请先选择要删除的项目！');
	        return false;
	    }
	}
}

function edit(url) {
    var d = document.getElementsByName('flag_id');
    var sel = [];
    for (var i = 0; i < d.length; i++) {
        if (d[i].checked) {
            sel[sel.length] = d[i];
        }
    }
    if (sel.length > 1) {
        alert('一次只能对一条数据进行修改！');
        return;
    } else if (sel.length == 0) {
    	  alert('请选择您要修改的数据！');
        return;
    } else if (sel.length == 1) {
        location.href = url + sel[0].value;
    }
}
//启动流程发送一条发文
function startflow(url) {
    var d = document.getElementsByName('flag_id');
    var sel = [];
    for (var i = 0; i < d.length; i++) {
        if (d[i].checked) {
            sel[sel.length] = d[i];
        }
    }
    if (sel.length > 1) {
        alert('一次只能发送一条数据！');
        return false;
    } else if (sel.length == 0) {
    	  alert('请选择您要发送的数据！');
        return false;
    } else if (sel.length == 1) {
        location.href = url + sel[0].value;
    }
}
function toggle(tb) {
	var rows = $(tb).rows;
	for (var i = 1; i < rows.length; i++) {
		Element.toggle(rows[i]);
	}
}
function resetForm(form) {
	if (form) {
		var eles = form.elements;
		for (var i = 0; i < eles.length; i++) {
			if (eles[i].tagName == 'INPUT') {
				if (eles[i].type == 'text' || eles[i].type == 'textarea')
					eles[i].value = '';
				if(eles[i].type == 'checkbox'){
					eles[i].checked = false;
				}
			} else if (eles[i].tagName == 'SELECT') {
				eles[i].selectedIndex = 0;
			}
		}
	}
}
/*===========================小马的comm.js===========================*/
//复选
function selectAll(chk) {
	var chk = document.form2.chkAll.checked;
	for (i = 0; i < document.all.length; i++) {
		if (document.all[i].name == "flag_id") {
			document.all[i].checked = chk;
			chkRow(document.all[i]);
		}
	}
}

//复选后单元格变色
function chkRow(obj) {
	var r = obj.parentElement.parentElement;
	if (obj.checked) {
		r.style.backgroundColor = "#ffffcc";
		r.setAttribute("isCheck", true);
	} else {
		r.setAttribute("isCheck", false);
		if (r.rowIndex % 2 == 1) {
			r.style.backgroundColor = "";
		} else {
			r.style.backgroundColor = "";
		}
	}
}

//form触发效果
function suckerfish(type, tag, parentId) {
	if (window.attachEvent) {
		window.attachEvent("onload", function () {
			var sfEls = (parentId == null) ? document.getElementsByTagName(tag) : document.getElementById(parentId).getElementsByTagName(tag);
			type(sfEls);
		});
	}
}
sfFocus = function (sfEls) {
	for (var i = 0; i < sfEls.length; i++) {
		sfEls[i].setAttribute('oldFocus', sfEls[i].onfocus);
		sfEls[i].onfocus = function (e) {
			this.className += " sffocus";
			var oldFocus = this.getAttribute('oldFocus');
			if(oldFocus) oldFocus(e);
		};
		sfEls[i].setAttribute('oldBlur', sfEls[i].onblur);
		sfEls[i].onblur = function (e) {
			this.className = this.className.replace(new RegExp(" sffocus\\b"), "");
			var oldBlur = this.getAttribute('oldBlur');
			if (oldBlur) oldBlur(e);
		};
	}
};

//限定输入长度
function limitLength(value, byteLength, title, attribute) {    
       var newvalue = value.replace(/[^\x00-\xff]/g, "**");    
       var length = newvalue.length;    
       //当填写的字节数小于设置的字节数    
      if (length * 1 <=byteLength * 1){    
            return;    
      }    
      var limitDate = newvalue.substr(0, byteLength);    
      var count = 0;    
      var limitvalue = "";    
     for (var i = 0; i < limitDate.length; i++) {    
             var flat = limitDate.substr(i, 1);    
            if (flat == "*") {    
                  count++;    
            }    
     }    
     var size = 0;    
     var istar = newvalue.substr(byteLength * 1 - 1, 1);//校验点是否为“×”    
    //if 基点是×; 判断在基点内有×为偶数还是奇数     
     if (count % 2 == 0) {    
              //当为偶数时    
            size = count / 2 + (byteLength * 1 - count);    
            limitvalue = value.substr(0, size);    
    } else {    
            //当为奇数时    
            size = (count - 1) / 2 + (byteLength * 1 - count);    
            limitvalue = value.substr(0, size);    
    }    
   alert(title + "输入不能超过" + byteLength + "个字节（相当于"+byteLength /2+"个汉字）！");    
   document.getElementById(attribute).value = limitvalue; 
   //document.getElementByName(attribute).value = limitvalue;       
   return;    
}   
//suckerfish(sfFocus, "INPUT");
//suckerfish(sfFocus, "TEXTAREA");

/*===========================小马的comm.js end=======================*/

function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;
  var objColl = (strTag == '*' && document.all) ? document.all : objContElm.getElementsByTagName(strTag);
  var arr = new Array();
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
  var arrClass = strClass.split(delim);
  for (var i = 0, j = objColl.length; i < j; i++) {
    var arrObjClass = objColl[i].className.split(' ');
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (k = 0, l = arrObjClass.length; k < l; k++) {
      for (m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]);
          break comparisonLoop;
        }
      }
    }
  }
  return arr;
}

initTableList = function() {
	var tb = getElementsByClassName('tableList', 'table', document.body);
	for (var j = 0; j < tb.length; j++) {
		for (var i = 1; i < tb[j].rows.length; i++) {
			tb[j].rows[i].onmouseover = function() {
				this.style.backgroundColor='#ffc';
			};
			tb[j].rows[i].onmouseout = function() {
				this.style.backgroundColor=(this.getAttribute('isCheck')?'#ffc':'');
			};
		}
	}
}

function __init() {
	try{
		initTableList();
		getElementsByClassName('limitWidth').each(function(div){
//			if(div.parentNode.style.width){
//				div.style.width = div.parentNode.style.width - 5 + 'px';
//			}else{
				div.style.width = (div.parentNode.clientWidth - 20) + 'px';
//			}
		});
	}catch(e){
	}
}

function openSelect(values, texts, options) {
	var sURL			= '../sys/selectUser.do';
	var nDialogWidth	= 600;
	var nDialogHeight	= 560;
	var nLeft			= (window.screen.availWidth-nDialogWidth)/2;
	var nTop			= (window.screen.availHeight-nDialogHeight)/2;
	var sFeatures		= "dialogLeft:"+nLeft+"px;dialogTop:"+nTop+"px;dialogHeight:"+nDialogHeight+"px;dialogWidth:"+nDialogWidth+"px;help:no;status:no;scroll:no;";
	
	if (options && options.isGroup) {
		sURL += '?isGroup=1&' + Math.random();
	} else {
		sURL += '?' + Math.random();
	}

	var obj = new Object();
	obj.selectObj = values.area;
  
	obj.fnUpdate = function() {
		var list = obj.list;
		var s = '';
		values.area.innerHTML = '';
		for (var i = 0; i < list.options.length; i++) {
			if (values) {
				values.area.appendChild($E({tag:'input',type:'hidden',id:list.options[i].text,name:values.name,value:list.options[i].value}));
			}
			if (texts) {
				s += list.options[i].text + ' ';
			}
		}
		texts.text.value = s;
	}
	var sReturnVal		= window.showModalDialog (sURL, obj, sFeatures) ;
}

function openSelect2(values) {
	var sURL			= '../sys/selectUser.do?type=00B&' + Math.random();
	var nDialogWidth	= 600;
	var nDialogHeight	= 560;
	var nLeft			= (window.screen.availWidth-nDialogWidth)/2;
	var nTop			= (window.screen.availHeight-nDialogHeight)/2;
	var sFeatures		= "dialogLeft:"+nLeft+"px;dialogTop:"+nTop+"px;dialogHeight:"+nDialogHeight+"px;dialogWidth:"+nDialogWidth+"px;help:no;status:no;scroll:no;";
	
	if (values && values.isGroup) {
		sURL += '&isGroup=1';
	}
	if (values && values.deptName) sURL += '&deptName=' + values.deptName;
	if (values && values.userName) sURL += '&userName=' + values.userName;

	var obj = new Object();
	obj.selectObj = values.area;
  
	obj.fnUpdate = function() {
		var list = obj.list;
		var s = '';
		values.area.innerHTML = '';
		var hiddNname;
		for (var i = 0; i < list.options.length; i++) {
			if (values) {
				hiddNname = list.options[i].id;
				values.area.appendChild($E({tag:'input',type:'hidden',id:list.options[i].text,name:hiddNname,value:list.options[i].value}));
			}
			if (values.texts) {
				s += list.options[i].text + ' ';
			}
		}
		if (values.texts) values.texts.value = s;
	}
	return window.showModalDialog (sURL, obj, sFeatures) ;
}

function openAllSelect(values, texts, options) {
	var sURL			= '../sys/selectUser!getAllUserTreeList.do';
	var nDialogWidth	= 600;
	var nDialogHeight	= 560;
	var nLeft			= (window.screen.availWidth-nDialogWidth)/2;
	var nTop			= (window.screen.availHeight-nDialogHeight)/2;
	var sFeatures		= "dialogLeft:"+nLeft+"px;dialogTop:"+nTop+"px;dialogHeight:"+nDialogHeight+"px;dialogWidth:"+nDialogWidth+"px;help:no;status:no;scroll:no;";
	
	if (values && values.isGroup) {
		sURL += '&isGroup=1';
	}
	if (values && values.deptName) sURL += '&deptName=' + values.deptName;
	if (values && values.userName) sURL += '&userName=' + values.userName;

	var obj = new Object();
	obj.selectObj = values.area;
  
	obj.fnUpdate = function() {
		var list = obj.list;
		var s = '';
		values.area.innerHTML = '';
		for (var i = 0; i < list.options.length; i++) {
			if (values) {
				values.area.appendChild($E({tag:'input',type:'hidden',id:list.options[i].text,name:values.name,value:list.options[i].value}));
			}
			if (texts) {
				s += list.options[i].text + ' ';
			}
		}
		texts.text.value = s;
	}
	var sReturnVal	= window.showModalDialog (sURL, obj, sFeatures) ;
}

function onlyInputNumber(isFloat) {
	if (window.event.keyCode == 45||window.event.keyCode == 46) {
		//alert("OK!~!!");
		window.event.keyCode = 0 ;
	}
	if ( !(((window.event.keyCode >= 48) && (window.event.keyCode <= 57)) 
	|| (window.event.keyCode == 13) || (isFloat && window.event.keyCode == 46) 
	|| (window.event.keyCode == 45))) {
		window.event.keyCode = 0 ;
	}
	
} 

function openSelectWindow(param) {
	var obj = new Object();
	var sUrl			= WWUtils.getCurrentServletPath('common\\.js') + '../sys/selectUser2.do?' + Math.random();
	var nDialogWidth	= 600;
	var nDialogHeight	= 505;
	var nLeft			= (window.screen.availWidth-nDialogWidth)/2;
	var nTop			= (window.screen.availHeight-nDialogHeight)/2;
	var sFeatures		= "dialogLeft:"+nLeft+"px;dialogTop:"+nTop+"px;dialogHeight:"+nDialogHeight+"px;dialogWidth:"+nDialogWidth+"px;help:no;status:yes;scroll:no;";
	if (param) {
		obj.openModel		= {hiddenViewer:param.hiddenViewer, selectUser:param.selectUser, selectOrgUser:param.selectOrgUser,selectDept:param.selectDept, selectOrg:param.selectOrg, threeStateCheckbox:param.threeStateCheckbox, descModel:param.descModel};
		if (param.user) obj.userList = $(param.user).value;
		if (param.dept) obj.deptList = $(param.dept).value;
		if (param.post) obj.postList = $(param.post).value;
		if (param.group) obj.groupList = $(param.group).value;
		if (param.org) obj.orgList = $(param.org).value;
		
		window.showModalDialog (sUrl, obj, sFeatures);
		if (obj.isSave) {
			if (param.user) $(param.user).value = obj.userList;
			if (param.userDesc) $(param.userDesc).value = obj.userNames;
			if (param.dept) $(param.dept).value = obj.deptList;
			if (param.deptDesc) $(param.deptDesc).value = obj.deptName;
			if (param.post) $(param.post).value = obj.postList;
			if (param.postDesc) $(param.postDesc).value = obj.postName;
			if (param.group) $(param.group).value = obj.groupList;
			if (param.groupDesc) $(param.groupDesc).value = obj.groupName;
			if (param.org) $(param.org).value = obj.orgList;
			if (param.orgDesc) $(param.orgDesc).value = obj.orgName;
			if (param.desc) $(param.desc).value = obj.runnerDesc;
		}
	}
}


//打开模态窗口 iframe，可以提交表单,二级页面
function openModelWindow(url,title, width, height) {
	var nDialogWidth	= width || 600;
	var nDialogHeight	= height || 560;
	var nLeft			= (window.screen.availWidth-nDialogWidth)/2;
	var nTop			= (window.screen.availHeight-nDialogHeight)/2;
	//var sURL			= '../include/innerIframe.jsp?width='+nDialogWidth+'&height='+nDialogHeight+'&'+Math.random();
	var sURL			= WWUtils.getCurrentServletPath('common\\.js') + '../include/innerIframe.jsp?'+Math.random()+'&width='+nDialogWidth+'&height='+nDialogHeight+'&title='+title;
	var sFeatures		= "dialogLeft:"+nLeft+"px;dialogTop:"+nTop+"px;dialogHeight:"+nDialogHeight+"px;dialogWidth:"+nDialogWidth+"px;help:no;status:yes;scroll:no";
	var obj = {};
	obj.url = url;
	obj.width = width;
	obj.height = height;
	obj.title =title;
	obj.fa = window;
	
	var val=window.showModalDialog (sURL, obj, sFeatures) ;
	return val;
}

//打开模态窗口 iframe，可以提交表单
function openModelWindow1(url,title, width, height) {
	var nDialogWidth	= width || 600;
	var nDialogHeight	= height || 560;
	var nLeft			= (window.screen.availWidth-nDialogWidth)/2;
	var nTop			= (window.screen.availHeight-nDialogHeight)/2;
	//var sURL			= 'include/innerIframe.jsp?width='+nDialogWidth+'&height='+nDialogHeight+'&'+Math.random();
	var sURL			= 'include/innerIframe.jsp?'+Math.random()+'&width='+nDialogWidth+'&height='+nDialogHeight+'&title='+title;
	var sFeatures		= "dialogLeft:"+nLeft+"px;dialogTop:"+nTop+"px;dialogHeight:"+nDialogHeight+"px;dialogWidth:"+nDialogWidth+"px;help:no;status:no;scroll:no";
	var obj = {};
	obj.url = url;
	obj.width = width;
	obj.height = height;
	obj.fa = window;
	
	window.showModalDialog (sURL, obj, sFeatures) ;
}
function openModelWindow2(url, width, height) {
	var nDialogWidth	= width || 600;
	var nDialogHeight	= height || 560;
	var nLeft			= (window.screen.availWidth-nDialogWidth)/2;
	var nTop			= (window.screen.availHeight-nDialogHeight)/2;
	var sFeatures		= "dialogLeft:"+nLeft+"px;dialogTop:"+nTop+"px;dialogHeight:"+nDialogHeight+"px;dialogWidth:"+nDialogWidth+"px;help:no;status:yes;scroll:no";
	var obj = {};
	obj.url = url;
	obj.width = width;
	obj.height = height;
	obj.fa = window;
	
	var val=window.showModalDialog (url, obj, sFeatures) ;
	return val;
}

//流程提交办理窗口 分支类型、 下环节节点json对象、  原回退环节json、 当前环节名称、false
//流程回退办理窗口 “”，回退环节节点json对象、""、 环节名称 、true
//arguObj = {split : splitType, activities : nextActivity, beback : beback, stepName : stepName, isBack : false};
function openWorkFlowDealDialog(arguObj){
	var obj = new Object();
	obj.isSubmit = false;
	obj.parentWindow = window;
	var url = "../workflow/workflowTemplate!workflowDeal.do?workflowId="+arguObj.workflowId+"&taskId="+arguObj.taskId;
	
	if(arguObj.isBack){
		url = "../workflow/workflowTemplate!workflowBack.do?workflowId="+arguObj.workflowId+"&taskId="+arguObj.taskId;
	}
	
	var path = WWUtils.getCurrentServletPath('common\\.js');
	
	window.showModalDialog(path + url ,obj,"dialogWidth=580px;dialogHeight=420px;help:no;status:yes;scroll:no");
	return obj.isSubmit;
}
/**
 * 下面两个方法是将list_bottom转到默认的描述页面
 */
function toListBottom(param){
	try{
		var path = WWUtils.getCurrentServletPath('common\\.js');
		parent.list_bottom.location.href = path+"../sysForward!getMessage.do"+param;
	}catch(e){}
}
//描述页面
function toDetail(){
	var parUrl = window.parent.location.toString();
	var param = parUrl.substring(parUrl.indexOf("?"),parUrl.length)
//	if(parent.list_bottom != window){
		setTimeout("toListBottom('"+param+"')",10);
//	}
}


//打开档案类别选择对话框 
function chooseArchivesType(id,docType){
	var obj = new Object();
	obj.parentWindow = window;
	window.showModalDialog("../../archives/chooseArchivesType.jsp?docId="+id+"&docType="+docType,obj,"dialogWidth=450px;dialogHeight=200px;help:no;status:yes;scroll:no");
}
//json对象转成字符串
var JSON = function(sJSON){
    this.objType = (typeof sJSON);
    this.self = [];
    (function(s,o){for(var i in o){o.hasOwnProperty(i)&&(s[i]=o[i],s.self[i]=o[i])};})(this,(this.objType=='string')?eval('0,'+sJSON):sJSON);
}
JSON.prototype = {
    toString:function(){
        return this.getString();
    },
    valueOf:function(){
        return this.getString();
    },
    getString:function(){
        var sA = [];
        (function(o){
            var oo = null;
            sA.push('{');
            for(var i in o){
                if(o.hasOwnProperty(i) && i!='prototype'){
                    oo = o[i];
                    if(oo instanceof Array){
                        sA.push(i+':[');
                        for(var b in oo){
                            if(oo.hasOwnProperty(b) && b!='prototype'){
                                sA.push(oo[b]+',');
                                if(typeof oo[b]=='object') arguments.callee(oo[b]);
                            }
                        }
                        sA.push('],');
                        continue;
                    }else{
                        sA.push(i+':\''+oo+'\',');
                    }
                    if(typeof oo=='object') arguments.callee(oo);
                }
            }
            sA.push('},');
        })(this.self);
        return sA.slice(0).join('').replace(/\[object object\],/ig,'').replace(/,\}/g,'}').replace(/,\]/g,']').slice(0,-1);
    },
    push:function(sName,sValue){
        this.self[sName] = sValue;
        this[sName] = sValue;
    }
}

//删除数组元素
Array.prototype.del=function(n) {   
//prototype为对象原型，注意这里为对象增加自定义方法的方法。
  if(n<0)  //如果n<0，则不进行任何操作。
    return this;
  else
    return this.slice(0,n).concat(this.slice(n+1,this.length));
    /*
      concat方法：返回一个新数组，这个新数组是由两个或更多数组组合而成的。
      　　　　　　这里就是返回this.slice(0,n)/this.slice(n+1,this.length)
     　　　　　　组成的新数组，这中间，刚好少了第n项。
      slice方法： 返回一个数组的一段，两个参数，分别指定开始和结束的位置。
    */
}


//使用超链接提交表单
function linkSubmit(formName,mehtodUrl,isDel)
{
	//isDel 表示是否调用删除方法del()
	var tempForm = document.forms[formName];
	if(tempForm)
	{
		tempForm.action = mehtodUrl;
		if(isDel && !del())
		{
			return;
		}
		tempForm.submit();
	}
}
/**
 * 跳转到框架页
 */
function showListFrame(_url){
	var basepath = WWUtils.getCurrentServletPath('common\\.js');
	var path = window.location.toString();
	var base = path.substring(0,path.lastIndexOf("/")+1);
	var url = base + _url;
	parent.location.href = basepath+'../include/listFrame.jsp?resourcePath='+encodeURI(url);
}

/**
 * 附件栏展开关闭 zby
 */
function showAttach(){
	var basepath = WWUtils.getCurrentServletPath('common\\.js');
	try{
		if(document.getElementById('attachmentTR').style.display=='none'){
			document.getElementById('attachmentTR').style.display = 'block';
			$('showAttachImg').src = basepath+"../images/show.gif";
		}else{
			document.getElementById('attachmentTR').style.display = 'none';
			$('showAttachImg').src = basepath+"../images/hide.gif";
		}
	}catch(e){}
}

/**
 * 按钮事件 添加附件
 */
function insertAttachment(objectId){
	var uploadURL = WWUtils.getCurrentServletPath('common\\.js')+"../sysfile/fileUploadWin.jsp";
	var rv = openModelWindow(uploadURL + "?objectId=" + objectId, '上传附件', 400, 220);
	if(rv&&rv=='ok'){
//		try{
			fileShow.init();
//		}catch(e){}
	}
}

//IE6兼容性适配 调整高度
function adapterHeight(){
		  if(window.dialogArguments == null){
		    return; //忽略非模态窗口
		  }
		  var ua = navigator.userAgent;
		  var height = document.body.offsetHeight;
		  if(ua.lastIndexOf("MSIE 6.0") != -1){
		  	var height = document.body.offsetHeight;
		    window.dialogHeight=(height+25)+"px";
		  }
}
