conDebug = true; // 全局变量：调试状态
conRootUrl = "http://"+window.location.host+"/"; //系统的根Url
conIncludeUrl = conRootUrl+"include/"; //include的Url
conIncludePath = "/include/";
var iLoadStart = new Date().getTime();
isLoad = false;   //是否每页预读取

//if (top.location == self.location){
//	self.moveTo(0,0);
//	self.resizeTo(screen.availWidth,screen.availHeight);
//}

//判断字符长度
function getLength(obj){
	oSpan = document.createElement("SPAN");
	oSpan.style.visibility = "hidden";
	oSpan.innerHTML = obj.innerText;
	document.body.insertBefore(oSpan);
	var len = oSpan.offsetWidth;
	oSpan.removeNode(true);
	return len;
}

/*
[功能] 通过数组自动生成<select>
[参数] value;name,value1;name1数祖
[返回值] HTML代码
[作者] molm 2003/12/15
*/
function array2select (arrValue,names,actions){
	if (arrValue==""){
		selects="暂时没有数据";
	}else{
		arrValue=arrValue.split(",");
		selects="<select name='"+names+"'";
		if (actions!=""){
			selects=selects+" onchange=\""+actions+"\"";
		}
		selects=selects+">";
		for (i=0;i<arrValue.length;i++){
			values=arrValue[i].split(";");
			selects=selects+"<option value='"+values[0]+"'>"+values[1]+"</option>";

		}
		selects=selects+"</select>";
	}
	return selects;

}

/*
[功能] 自动匹配value
[参数]
[作者] molm 2003/8/9
*/
function compareValue(obj,value,readonly){
	if (obj.name.indexOf("chooseDisplay")!=-1){
		value=value.split("#");
		chooseDisplayvalue=value[0];
		chooseHiddenvalue=value[1];
		newobjname=obj.name.replace("chooseDisplay","");
		obj.value=value[0];
		eval(obj.form.name+".chooseHidden"+newobjname+".value='"+value[1]+"'");
		if (readonly=="True"){
			obj.parentElement.innerHTML=obj.parentElement.innerHTML.replace(/type=button/ig,"type=button disabled")
			obj.disabled=true;
		}
	}else{
		switch (obj.type){
			case "hidden":
				obj.value=value;
				break;
			case "text":
				obj.value=value;
				break;
			case "textarea":
				obj.value=value.replace(/<br>/ig,"\n");
				break;
			case "select-one":
				for (i=0;i<obj.length;i++){
					if (obj.options[i].value==value){
						obj.options[i].selected=true;
						break;
					}
				}
				break;
		}
		if (readonly=="True"){
			obj.disabled=true;
		}
	}
	window.status = getElapseTime();
	/*
	if (obj.tagName=="INPUT"&&obj.type=="text"){
		if (obj.parentElement.innerHTML.indexOf("type=button")>-1||obj.parentElement.innerHTML.indexOf("type='button'")>-1||obj.parentElement.innerHTML.indexOf("type=\"button\"")>-1){
			objNewWidth=parseInt(obj.style.width.replace(/px/ig,""));
			if (!isNaN(objNewWidth)&&obj.style.width.indexOf("%")==-1){
				obj.style.width=objNewWidth-50;
			}else{
				if (obj.style.width>"75%"){
					obj.style.width="75%";
				}
			}
		}
	}
	*/
}


/*
[功能] 自动适应高度
[参数]
[作者] molm 2003/8/9
*/
function changeTableDiv(){

	cbt=document.all.tags("Table");
	for (cbtid=0;cbtid<cbt.length;cbtid++){
		if (cbt[cbtid].parentElement.tagName=="DIV"){
			if (cbt[cbtid].parentElement.id.indexOf("report")==-1&&cbt[cbtid].parentElement.id!="titletable_div1"&&cbt[cbtid].parentElement.id!="titletable_div2"&&cbt[cbtid].parentElement.id!="maintable_div1"&&cbt[cbtid].parentElement.id!="maintable_div2"){
				divHeight=cbt[cbtid].parentElement.style.height.replace(/px/ig,"");
				if (parseFloat(cbt[cbtid].clientHeight)<parseFloat(divHeight)&&cbt[cbtid].parentElement.id!="oDivOutline"){
					cbt[cbtid].parentElement.style.height=cbt[cbtid].clientHeight+20;
				}
			}
			//alert (cbt[cbtid].parentElement.style.height)

			//alert (cbt[cbtid].parentElement.style.height);
			//cbt[cbtid].width=cbtWidth;
		}
	}

}
function lockParentButton(){
	if (typeof(main)!="undefined"){
		cbt=document.all.tags("INPUT");

		for (cbtid=0;cbtid<cbt.length;cbtid++){
			if (cbt[cbtid].type=="button"||cbt[cbtid].type=="submit"){
				cbt[cbtid].disabled=true;
			}

		}
	}

}
function unlockParentButton(){
	if (typeof(parent)!="undefined"){
		cbt=parent.document.all.tags("INPUT");
		for (cbtid=0;cbtid<cbt.length;cbtid++){
			if (cbt[cbtid].type=="button"||cbt[cbtid].type=="submit"){
				cbt[cbtid].disabled=false;
			}

		}
	}

}
/*
[功能] 判断连续点击
[参数]
[作者] molm 2003/8/9
*/

submitClicks=1;
function checkClick(obj){
	if (submitClicks==1) {
    	submitClicks=2;
		obj.disabled=true;
    	return true;
  	} else {
		alert ("已经执行，请不要连续点击……");
		return false;
	}
}

function unlockButton(obj) {
	obj.disabled=false;
	submitClicks=1;
}

/*
[功能] 焦点定位在第一个输入框
[参数]
[作者] molm 2003/8/11
*/
function firstInput() {

	for (i=0;i<document.forms.length;i++)  {
		for (j=0;j<document.forms[i].elements.length;j++) {
			e=document.forms[i].elements[j];
			if (e.type=="text") {
				e.focus();
				return false;
			}
		}
	}
}

/*
[功能] 通用的错误处理函数
[参数] Error Object
[作者] casso 2003/8/1
*/
function errorHandle(e) {
	var oCaller=errorHandle.caller;
	var functionName=oCaller.toString().match(/^function\s+(\S+)\s*\(/)[1];
	if (conDebug) {
		alert("JS Error:"+e.name+"["+(e.number&0xffff).toString()+"]\n"
			+"Function:"+functionName+"\n\nError Detail:"+e.message);
	}
	else {
		var strName="name="+escape(e.name+"["+(e.number&0xffff).toString()+"]");
		var strRef="refer="+escape(window.location.href);
		var strFunc="function="+escape(functionName);
		var strMessage="message="+escape(e.message);
		var url=conIncludeUrl+"src/js_error.asp?"+strName+"&"+strRef+"&"+strFunc+"&"+strMessage;
		openHideWindow(url);
	}
	return false;
}

/*
[功能] 在用户看不见的地方创建一个ie窗口
[参数] url地址
[作者] casso 2003/8/3
*/
function openHideWindow(url) {
	return window.open(url,"_blank",
		"height=100,width=100,top=2000,left=2000,status=no,toolbar=no,menubar=no,location=no");
}


/*
[功能] 在屏幕中部开新窗口
[参数] windowUrl 新窗口Url,windowWidth 新窗口宽度,windowHeight　新窗口高度,windowName　新窗口name，新窗口id默认为Name+"Id"
[作者] molm 2003/8/4
*/

function openWindow(windowUrl,windowWidth,windowHeight,windowName){
	try {

		if (windowName==""){
			windowName="newWindow";
			windowNames="";
		}else{
			windowNames=windowName;
		}
		//alert ("var "+windowName+"Id=window.open ('"+windowUrl+"','"+windowNames+"','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+windowWidth+",height="+windowHeight+"');");

		eval ("var "+windowName+"Id=window.open ('"+windowUrl+"','"+windowNames+"','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+windowWidth+",height="+windowHeight+"');");
		eval (windowName+"Id.moveTo((screen.width-windowWidth)/2,(screen.height-windowHeight)/2);");
		return false;



	}
	catch(e){
		errorHandle(e);
	}
}



/*
[功能] 获取当前obj的所有属性值
[参数] obj 名称
[作者] molm 2003/8/4
*/
function getElement(obj){
	//openWindow (conIncludeUrl+"const.asp",500,400,"getElementWindow")
	//getElementWindowId.window.close();
	//alert (newwin.window.name);
	try {
		for(i in obj) document.write (i+" ----- "+obj[i]+"<br>");
		return false;
	}
	catch(e){
		errorHandle(e);
	}
}


/*
[功能] 获取当前obj的相对位置
[参数] obj id名称
[返回] 数组 array(top,left,bottom,right)
[作者] molm 2003/8/4
*/
function getObjRect(obj){
	var _rect = obj.getBoundingClientRect();
	objRect=new Array(_rect.top,_rect.left,_rect.bottom,_rect.right);
	return objRect;
}
/*
[功能] 获取当前obj的绝对位置
[参数] obj id名称
[返回] 数组 array(top,left)
[作者] molm 2003/8/8
*/
function getObjRect2(obj){
	t=obj.offsetTop;
	l=obj.offsetLeft;
	while (obj=obj.offsetParent){
		t+=obj.offsetTop;
		l+=obj.offsetLeft;
	}
	objRect2=new Array(t,l)
	return objRect2;
}

/*
[功能] 判断该变量是否存在，防止报错
[参数] obj要检查的变量名称
[作者] molm 2003/8/6
*/
function isVarDefined(obj) {
	if(typeof(obj)=="undefined") {
		return false;
	} else {
		return true;
	}
}

/*
函数名称：getIndex()
函数介绍：获取点击的表格行数和对应列数和鼠标对应父窗口位置
调用方法：直接调用
返回信息：intRowIndex行数，intColIndex列数，intMouseX---x坐标，intMouseY---y坐标
*/
function getIndex(){
	if(event.srcElement.parentElement.tagName=='TD'){
		intRowIndex=event.srcElement.parentElement.parentElement.rowIndex;
	}else{
		intRowIndex=event.srcElement.parentElement.rowIndex;
	}
	intColIndex=event.srcElement.cellIndex;
	//alert (event.srcElement.cellIndex)
	intMouseX=event.x;
	intMouseY=event.y;
}

/*
函数名称：getIndex()
函数介绍：获取点击的表格行数和对应列数和鼠标对应父窗口位置
调用方法：直接调用
返回信息：intRowIndex行数，intColIndex列数，intMouseX---x坐标，intMouseY---y坐标
*/
function getIndexFinal(tbName){

	if(event.srcElement.parentElement.tagName=='TD'){
		eval("intRowIndex"+tbName+"=event.srcElement.parentElement.parentElement.rowIndex;");
	}else{
		eval("intRowIndex"+tbName+"=event.srcElement.parentElement.rowIndex;");
	}

	eval("intColIndex"+tbName+"=event.srcElement.cellIndex;");
	eval("intMouseX"+tbName+"=event.x;");
	eval("intMouseY"+tbName+"=event.y;");
}


/*
函数名称：changeColor(name,color)
函数介绍：改变指定区域内文字的颜色
调用方法：直接调用
参数介绍：name区域的id名称，color新的颜色
*/
function changeColor(name,color){
	eval(name+".style.color='"+color+"'");
}

/*
casso
*/
String.prototype.trim=function() {
	return this.replace(/(^\s*)|(\s*$)/g,"");
}

String.prototype.appendElement=function(str) {
	var seperator=";";
	return this+((this.trim()==""||str.trim()=="")?"":seperator)+str;
}

function TPsnList() {
	this.psnId = "";
	this.psnNameCn = "";
}

function sendSelect(fldPsnToSend,fldPsnId,fldPsnNameCn,type) {
	var thisForm = document.forms[0];
	if (thisForm.elements[fldPsnToSend].value == "") {
		alert("待处理发送人员列表为空。");
		return false;
	}
	else {
		var retVal = new TPsnList();
		url = conIncludeUrl+"src/workflow_select.asp?list=" + thisForm.elements[fldPsnToSend].value.replace(" ", "") + "&type=" + type;
		if (window.showModalDialog(url, retVal, "dialogHeight:21; dialogWidth:28; help:no; status:no; scroll:no")) {
			if(thisForm.elements[fldPsnId] != null) thisForm.elements[fldPsnId].value = retVal.psnId;
			if(thisForm.elements[fldPsnNameCn] != null) thisForm.elements[fldPsnNameCn].value = retVal.psnNameCn;
			return true;
		} else {
			return false;
		}
	}
}



/*
[功能] 删除select的某条记录
[参数] obj要检查的对象 form1.city
       selectid 选择的id  form1.city.selectedIndex
[作者] molm 2003/9/13
*/
function delSelect (obj) {
	if (obj.length==0){
		alert ("自定义查询条件暂时为空，不能删除。");
		return false;
	}
	if (obj.value==""){
		alert ("请从下面选择要删除的查询条件。");
		return false;
	}

	selectid=obj.selectedIndex;
	for (i=selectid;i<obj.length-1;i++) {
		obj.options[i].value=obj.options[i+1].value;
		obj.options[i].text=obj.options[i+1].text;
	}
	obj.length=obj.length-1;
	return false;
}

/*
[功能] 增加select的某条记录
[参数] obj要检查的对象  form1.city
       values  值
       texts 显示
[作者] molm 2003/9/13
*/
function addSelect(obj,values,texts,color) {
	selectlength=obj.length;
	//if (obj.options[0].text=="") {
	//	newlength=0;
	//}else{
	if (selectlength>0){
		for (i=0;i<selectlength;i++){
			if (obj.options[i].value==values&&obj.options[i].text==texts){
				alert ("当前增加信息已经存在，请不要出现重复数据。");
				return false;

			}

		}
	}

		newlength=selectlength+1;
	//}
	obj.length=newlength;
	obj.options[selectlength].value=values;
	obj.options[selectlength].text=texts;
	if (color!=""){
		obj.options[selectlength].style.color=color;
	}
	return false;

}

/**************************************************************************
Syntax:
	selectCommonData(src, type, cols);
Parameters:
	src: 数据源路径，是XML格式的文件，相对于根路径的形式，如：/chenyf/data/xml.asp
	type: 单选/多选，对应radio/checkbox
	cols: 返回哪些列的列值，一逗号分隔，如：1,3,5
	selected: 已选中数据，数组，格式同返回值一致
	width: 对话框窗体宽度
	height: 对话框窗体高度
Return:
	1).若选择有数据点击确定，则返回一个数组，若返回的是多列，则是多维数组
	2).若没有选择数据点击确定，则返回一个数组，数组的唯一元素为null
	3).若点击取消，则返回值为null
Usage:
	通用数据选择
Author: chenyf@reachtech.com.com
Date: 2003/08/08
**************************************************************************/
function selectCommonData(src, type, cols, selected, width, height) {
	try {
		var strURL = "/include/src/common_data_select.asp?src=" + src + "&type=" + type + "&cols=" + cols;
		return window.showModalDialog(strURL, selected, "dialogHeight: " + height + "px; dialogWidth: " + width + "px; help:no; status:no; scroll:no");
	} catch (e) {
		errorHandle(e);
	}
}

/********************
	中铁时候用的selectData函数
	widthss			窗口宽度
	heightss		窗口高度
	types			radio/checkbox
	table			数据库
	fields		字段 name,title
	wheres		条件 flag>1 and name=\'fff\'
	orderby		排序方式  name desc 
	names			标题栏
	widths		每列的宽度 200,300,*
	inputs		每列传回值目的input menu_table.name, menu_table.title
	checks		如果填写值，执行校验
	act				选择后，执行的触发动作 object.ifmContract.location.href=\'/bargain_balance/main/listContract.asp?temp_num=<%=temp_num%>&pid=<%=pid%>&bg_id=\'+object.menu_table.bg_id.value
*********************/
function selectData(widthss,heightss,types,table,fields,wheres,orderby,names,widths,inputs,checks,act){

	selectDataTable=table;
	selectDataFields=fields;
	selectDataWheres=wheres;
	selectDataOrderby=orderby;
	selectDataInputs=inputs;
	selectDataNames=names;
	selectDataWidths=widths;
	selectDataTypes=types;
	selectDataAct=act;
	selectDataChecks=checks;
	eval("var dataWindow=window.showModelessDialog('/include/src/select_data.asp',window,'dialogHeight:"+heightss+"px;dialogWidth:"+widthss+"px');");
	return false;
	
}



//填写意见
function writeOpinion(table,id,step){
	var arg="table="+table+"&id="+id+"&step="+step;
	var url=conIncludePath+"src/opinion.asp?"+arg;

	openWindow(url,640,480,"winOpinion");
}

function editOpinion(id){
	var arg="opinion_id="+id;
	var url=conIncludePath+"src/opinion.asp?"+arg;

	openWindow(url,640,480,"winOpinion");
}

function createDoc(table,id,step){
	var arg="table="+table+"&id="+id+"&step="+step;
	var url=conIncludePath+"src/createbytemplate.asp?"+arg;

	openWindow(url,520,390,"winDoc");
}


//改变电极连接颜色
oldHref="";
function changeHrefColor(obj){
	obj.style.color='blue';
	if (oldHref!=""){
		oldHref.style.color="";
	}
	oldHref=obj;


}

/*
[功能] 自动计算字符串长度
[参数]
[作者] molm 2003/8/16
*/
function countStrWidth(str){
	len2=0;
	for (var ci=0;ci<str.length;ci=ci+1){
		var code= str.charCodeAt(ci);
		if (code<128)
		        len1=6;
		else
			len1=12;
		len2=len2+len1;
    	}
    	return len2;
}


function historyBack(){
	history.back(-1);
	if (typeof(parent)=="object"){
		cbt=parent.document.all.tags("INPUT");
		for (cbtid=0;cbtid<cbt.length;cbtid++){
			if (cbt[cbtid].disabled){
				cbt[cbtid].disabled=false;
			}
		}
	}

}


function disabledButton(){
	//history.back(-1);
	cbt=document.all.tags("INPUT");
	for (cbtid=0;cbtid<cbt.length;cbtid++){
		if (!cbt[cbtid].disabled){
			cbt[cbtid].disabled=true;
		}
	}

}
function enableButton(){
	//history.back(-1);
	cbt=document.all.tags("INPUT");
	for (cbtid=0;cbtid<cbt.length;cbtid++){
		if (!cbt[cbtid].disabled){
			cbt[cbtid].disabled=false;
		}
	}
	submitClicks=1;
}
//--------------------------------------------------------
/*
函数名称：SetCookie
函数介绍：设置cookie
调用方法：SetCookie (name, value)
参数介绍：name cookie名,value cookie值
*/
//--------------------------------------------------------
/*
函数名称：SetCookie
函数介绍：设置cookie
调用方法：SetCookie (name, value)
参数介绍：name cookie名,value cookie值
*/
var exp = new Date();
function SetCookieDate(expDays){

exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
}
function SetCookie (name, value) {

	var argv = SetCookie.arguments;

	var argc = SetCookie.arguments.length;

	var expires = (argc > 2) ? argv[2] : null;

	var path = (argc > 3) ? argv[3] : null;

	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" : "");

}

function GetCookie(name){ 
	var cookieString = new String(document.cookie)
	var cookieHeader = name + "=";

	var beginPosition = cookieString.indexOf(cookieHeader);
	if (beginPosition != -1){
		//return cookieString.substring(beginPosition) ;
		
		return (unescape(cookieString.substring(beginPosition+cookieHeader.length).split(";")[0]));
	}
	else
		return "";	
}


/*
函数名称：得到当前控件距离底部的高度
函数介绍：
调用方法：getObjBottom (obj)
参数介绍：
*/
function getObjBottomHeight(obj){
	var screenHeight=window.document.body.offsetHeight;   //当前窗口的高度
	var objHeight=getObjRect2(obj)[0];       //显示的高度坐标
	return screenHeight-objHeight;
}

function reportPreview(form,action) {
	try {
		var sFeatures="dialogHeight:420px;dialogWidth:560px;scroll:yes;help:no";
		var mResult=window.showModalDialog("/include/src/report_preview.asp",window,sFeatures);
		if (mResult=='mrOk') {
			form.opflag.value=action;
			form.target="_blank";
			form.submit();
		}
	}
	catch (e) {
		errorHandle(e);
	}
}

function reportToExcel(form,action) {
	try {
		var sFeatures="dialogHeight:420px;dialogWidth:560px;scroll:yes;help:no";
		//var sFeatures="height:420px,width:560px,scroll:no,help:no";
		var mResult=window.showModalDialog("/include/src/report_toexcel.asp",window,sFeatures);
		//var mResult=window.open("/include/src/report_toexcel.asp",'',sFeatures);
		if (mResult=='mrOk') {
			form.opflag.value=action;
			form.submit();
		}
	}
	catch (e) {
		errorHandle(e);
	}
}

function openDoc(m,tid) {
	var arg="fullscreen=yes";
	if (m) {
		window.open("/include/src/createbytemplate.asp?tid="+tid,"_blank",arg);
	}
	else {
		window.open("/include/src/createbytemplate.asp?fname="+tid,"_blank",arg);
	}
}

function readDoc(url) {
	if (url=="") {
		alert("您想阅读的文档不存在。");
	}
	else {
		var arg="fullscreen=yes";
		window.open("/include/src/readdoc.asp?url="+url,"_blank",arg);
	}
}

function printTableToExcel(name, ids) {

	var oForm = document.createElement("<form name='fmPrint' method='post' action='/include/src/exp2xls.asp?fldFileName=" + escape(name) + "' target='_self'/>");
	oForm.style.display = "none";
	document.body.appendChild(oForm);
	var oFld = document.createElement("<textarea name='fldContent'/>");
	oFld.style.display = "none";
	oForm.appendChild(oFld);

	var arrId = ids.split(";");
	for (var j = 0; j < arrId.length; j++) {
		var obj = document.getElementById(arrId[j]);
		if (obj != null) {
			var oTable = obj.cloneNode(true);
			oTable.bgColor = "";
			oTable.className = "";
			oTable.border = "1";
			if (oTable.tagName.toLowerCase() == "table") {
				for (var i = 0; i < oTable.cells.length; i++) {
					oTable.cells(i).className = "";
				}
			}
	
			oFld.value += oTable.outerHTML + "<br/>";
		}
	}
	oForm.submit();
}

function printScriptX(url) {
	//window.open("/include/print.htm?url=" + escape(url),
	window.open(url,
			'_blank',
			'left=0, top=0, width=' + (window.screen.availWidth - 10) + ', height=' + (window.screen.availHeight - 50) + ', status=1, toolbar=0, menubar=0, location=0, scrollbars=1, resizable=1', false
			);
}

/**
 * @return elapse time after document load
 */
function getElapseTime() {
	var iLoadEnd = new Date().getTime();
	return (iLoadEnd - iLoadStart)
}

/** 
 * popup window in specified size
 * @param {String} url
 * @param {int} width in pixel
 * @param {int} height in pixel
 */
function popWin(url, width, height) {
	if (width != null & width != "" & height != null && height != "") {
		window.open(url, '_blank', 'left=0, top=0, width=' + width + ', height=' + height + ', status=1, toolbar=0, menubar=0, location=0, scrollbars=1, resizable=1', false);
	} else {
		window.open(url, '_blank', 'left=0, top=0, width=' + (window.screen.availWidth - 10) + ', height=' + (window.screen.availHeight - 50) + ', status=1, toolbar=0, menubar=0, location=0, scrollbars=1, resizable=1', false);
	}
}

//公共上传
function addAttachment(tbl, unid) {
	//sURL = "/include/src/upload/upload.asp?tbl="+tbl+"&unid="+unid;
	sURL = "/include/ntkofmanAsp/NTKO_Upload.asp?tbl="+tbl+"&unid="+unid;
	oWin=openWindow(sURL, 600, 250);
}

function redirectDefaultView(targetIfm){
	var back_url = GetCookie("view_back_url");
	//alert(back_url)
	if (back_url==""){
		alert("您访问的页面不存在，请选择输入正确的地址进行访问。");
		targetIfm.history.back(-1);
	}
	back_url = back_url.split("||");
	
	if (typeof(targetIfm) == "undefined"){
		location.href = back_url[0];	
	}else{
		targetIfm.location.href = back_url[0];
	}
	return false;
}

/**
 * @category 工作流
 * 选择流程
 * @param list 模版id
 * @param list 模版名称
 * @param string 打开的页面
 */
function wfSelectTemplate(tidlist,tnamelist,url) {
	try {
		var sFeatures="dialogHeight:360px;dialogWidth:480px;scroll:no;help:no";
		var wfid=window.showModalDialog("/include/src/wf_template.asp?idlist="+tidlist+"&namelist="+tnamelist,window,sFeatures);
		if (wfid!="" && typeof(wfid)!="undefined") {
			if (url.indexOf("_wfid")==-1)
				location.href=url+"&_wfid="+wfid;
		}
	}
	catch (e) {
		errorHandle(e);
	}
}

/**
 * @category 工作流
 * 流程处理调用函数,用于送至下一个活动,在任意选人的时候调用。
 * @param int 调用的flow ID
 * @param object 发起操作的部件
 * @param string form
 * @param string checkbox or radio
 */
function wfFlow0(fid,fname,obj,type) {
	var form=document.forms[0];
	try {
		if (workflowCallback(obj)) {
			if (!confirm("是否执行操作："+fname+"？")) {
				unlockButton(obj);
				return false;
			}
			selectPsnOrGroup(form._nextUserEn,form._nextUserCn,null,null,type);
			if (form._nextUserEn.value!="") {
				form.opflag.value="workflow"
				form._flowId.value=fid;
				form.submit();
			}
			else
				unlockButton(obj);
		}
	}
	catch (e) {
		errorHandle(e);
	}
}

/**
 * @category 工作流
 * 流程处理调用函数,用于送至下一个活动,在需要选择人员的时候调用。
 * @param int 调用的flow ID
 * @param object 发起操作的部件
 * @param string 待发送人员id list
 * @param string 待发送人员cn list
 * @param string checkbox or radio
 */
function wfFlow1(fid,fname,obj,idlist,cnlist,type) {
	var form=document.forms[0];
	try {
		if (workflowCallback(obj)) {
			if (!confirm("是否执行操作："+fname+"？")) {
				unlockButton(obj);
				return false;
			}
			if (idlist.indexOf(";")>-1) {
				form._sendUserId.value=idlist;
				if (sendSelect("_sendUserId","_nextUserId","_nextUserCn",type)) {
					form.opflag.value="workflow";
					form._flowId.value=fid;
					form.submit();
				}
				else
					unlockButton(obj);
			}
			else {
				form._nextUserId.value=idlist;
				form._nextUserCn.value=cnlist;
				form.opflag.value="workflow";
				form._flowId.value=fid;
				form.submit();
			}
		}
	}
	catch (e) {
		errorHandle(e);
	}
}

/**
 * @category 工作流
 * 流程处理调用函数,用于送至下一个活动,在指定人员的时候调用。
 * @param int 调用的flow ID
 * @param object 发起操作的部件
 * @param string form
 */
function wfFlow2(fid,fname,obj) {
	var form=document.forms[0];
	try {
		if (workflowCallback(obj)) {
			if (!confirm("是否执行操作："+fname+"？")) {
				unlockButton(obj);
				return false;
			}
			form.opflag.value="workflow"
			form._flowId.value=fid;
			form.submit();
		}
	}
	catch (e) {
		errorHandle(e);
	}
}

/**
 * @category 工作流
 * 流程处理调用函数,用于活动终止。
 * @param int 调用的flow ID
 * @param object 发起操作的部件
 * @param string form
 */
function wfFlowEnd(fid,fname,obj) {
	var form=document.forms[0];
	try {
		if (workflowCallback(obj)) {
			if (!confirm("是否执行操作："+fname+"？")) {
				unlockButton(obj);
				return false;
			}
			form.opflag.value="workflow"
			form._flowId.value=fid;
			form.submit();
		}
	}
	catch (e) {
		errorHandle(e);
	}
}

/**
 * @category 工作流
 * 取回操作
 * @param object 发起操作的部件
 * @return boolean
 */
function wfTakeback(obj) {
	var form=document.forms[0];
  try {
    if (!confirm("是否进行取回操作？")) {
      unlockButton(obj);
      return false;
    }
    form.opflag.value="takeback";
    form.submit();
    return true;
  }
  catch (e) {
    errorHandle(e);
  }
}
  	
