
function fnExecuteKey(sltObj, kc){
var kn=String.fromCharCode(kc)
var len=sltObj.options.length
for(var i=0; i<len; i++){
	if(kn==sltObj.options[i].accessKey.toUpperCase()){
		sltObj.selectedIndex=i,
		sltObj.onchange();
		window.event.cancelBubble=true;
		window.event.returnValue=false;
		break
	}
}
}

function syshotkey(){
var kc=window.event.keyCode
switch(kc){
case 27:
	if(typeof(self.dialogArguments)!='undefined')	window.close();
	break;
case 114: //屏蔽F3
	window.event.keyCode=9;
	break;
case 115: //F4
	window.event.keyCode=9;
	break;
case 116: //屏蔽F5
	window.event.keyCode=9;
	break;
case 122: //屏蔽F11
	//window.event.keyCode=9;
	break;
default:
	if(window.event.altKey==true && kc>64 && kc<91){
		if(document.all("AllOprate")) fnExecuteKey(document.all("AllOprate"), kc)
		break;
	}
	else return;
}
window.event.cancelBubble=true;
window.event.returnValue=false;
}

function canCookie(){
	try{document.cookie = "test=; expires=Fri, 31 Dec 1999 23:59:59 GMT;";}
	catch(e){return false}
	return true
}
function setCookie(sName, sValue, days){
	var expdate
	if(days && !isNaN(days)) expdate = new Date((new Date()).getTime() + (24 * 60 * 60 * 1000 * days));
	else expdate = new Date();
	document.cookie = sName + "=" + escape(sValue) + "; expires=" + expdate.toGMTString();
}
function getCookie(name){
	var cname = name + "=";               
	var dc = document.cookie;
	if (dc.length > 0) {              
		begin = dc.indexOf(cname);
		if (begin != -1) {           
			begin += cname.length;
			end = dc.indexOf(";", begin);
			if (end == -1) end = dc.length;
			return unescape(dc.substring(begin, end));       
		}
	}
	return "";
}
function delCookie(sName){
	document.cookie = sName + "=; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}



function w_onload(){
/*
if(typeof(window.dialogArguments)=='object'){
	//模式窗口
	window.dialogArguments.childwindow=window;
}else{
	//普通窗口
	//for(var i=0; i<80; i++)	window.document.title += '　';	//设置标题
}
*/
//执行初始化程序
if(typeof(init)=='function'){init();}
}

function closeme(){
if(self.opener || typeof(self.dialogArguments)!='undefined')	window.close();
else window.history.back();
}

//选择日期
function GetDt(fld, flag){
var tmp='';
if(typeof(fld)=='object'){
	if(fld.disabled==true) return
	tmp=fld.value;
}
else if(fld){
	tmp=fld;
}
if(tmp!='' && !javaValidDate(tmp)) tmp='';
if(flag) tmp+=";"+flag
var retv = window.showModalDialog("/include/calendar.htm", tmp, "dialogHeight:250px;dialogWidth:250px;dialogTop1:275px;dialogLeft1:320px;center:Yes;help:No;resizable:No;status:No;");
if(retv!=null && typeof(fld)=='object') fld.value = retv;
return retv;
}

//选择
function fnSelectItem(codeobj, nameobj, whichitem, checkbox, eparam, wd, ht){
var retv=null
var code = ""
var name = ""
if(typeof(codeobj)=="object") code=codeobj.value
else if(codeobj) code=codeobj
if(typeof(nameobj)=="object") name=nameobj.value
else if(nameobj) name=nameobj
if(!whichitem) whichitem="dept"
if(!checkbox) checkbox="no"
if(!eparam) eparam=""
switch(whichitem){
case "dept":
	retv=window.showModalDialog("/select/dept_slt.asp?checkbox="+checkbox+"&"+eparam, code, "dialogWidth: 300px; dialogHeight: 400px; center: Yes; help: No; resizable: No; status: No;");
	break;
case "employee":
	retv=opendialog(name,"/select/employee_slt.asp?checkbox="+checkbox+"&"+eparam);
	break;
case "zone":
	var retv = window.showModalDialog("/select/zone_slt.asp?zone="+escape(name), null, "dialogHeight: 360px; dialogWidth: 320px; center: Yes; help: No; resizable: No; status: No;");
	if(!retv) return;
	retv=retv.substr(1,retv.indexOf(']')-1) + ";" + escape(retv.substr(retv.indexOf(']')+1,retv.length));
	break;
case "area":
	var retv = window.showModalDialog("/select/area_slt.asp?zone="+escape(name), null, "dialogHeight: 360px; dialogWidth: 320px; center: Yes; help: No; resizable: No; status: No;");
	if(!retv) return;
	retv=retv.substr(1,retv.indexOf(']')-1) + ";" + escape(retv.substr(retv.indexOf(']')+1,retv.length));
	break;
case "dict":
	var retv = window.showModalDialog("/select/dict_slt.asp?checkbox="+checkbox+"&pcode="+eparam+"&code="+code+"&name="+escape(name), null, "dialogHeight: 360px; dialogWidth: 320px; center: Yes; help: No; resizable: No; status: No;");
	if(!retv) return;
	//retv=retv.substr(1,retv.indexOf(']')-1) + ";" + escape(retv.substr(retv.indexOf(']')+1,retv.length));
	break;
	

case "user":
	var retv = window.showModalDialog("/select/user_slt.asp?codes="+code, "", "dialogHeight: 400px; dialogWidth: 300px; center: Yes; help: No; resizable: No; status: No;");
	if(!retv) return;
	break;

case "linkclass":
	var retv = window.showModalDialog("/select/linkclass_slt.asp?checkbox="+checkbox, "", "dialogHeight: 400px; dialogWidth: 300px; center: Yes; help: No; resizable: No; status: No;");
	if(!retv) return;
	break;
	
case "linkclass_my":
	var retv = window.showModalDialog("/select/linkclass_slt_my.asp?checkbox="+checkbox, "", "dialogHeight: 400px; dialogWidth: 300px; center: Yes; help: No; resizable: No; status: No;");
	if(!retv) return;
	break;
	
case "role":
	var retv = window.showModalDialog("/select/audrole_slt.asp?checkbox="+checkbox+"&code="+code+"&name="+escape(name), self, "dialogHeight: 360px; dialogWidth: 320px; center: Yes; help: No; resizable: No; status: No;");
	if(!retv) return;
	break;
case "other":
	if(!wd) var wd=null
	if(!ht) var ht=null
	retv=opendialog(name,eparam,wd,ht);
	break;
}
if(!retv) return;
var a=retv.indexOf(';');
if(typeof(codeobj)=="object") codeobj.value = unescape(retv.substr(0,a));
if(typeof(nameobj)=="object") nameobj.value=unescape(retv.substring(a+1,retv.length));
return retv.split(";")
}

function openwindow(url, name, wd, ht, resizable){
if(!wd) var wd=720
if(!ht) var ht=540
if(!name) var name=''
if(!resizable) var resizable='yes'
var tp=parseInt(screen.availHeight/2-ht/2)-20 //screen.height
var lf=parseInt(screen.availWidth /2-wd/2) //screen.width
var wobj=window.open(url,name,'top='+tp+',left='+lf+',width='+wd+',height='+ht+',toolbar=no,menubar=no,scrollbars=yes,resizable='+resizable);
wobj.focus();
return wobj;
}

function opendialog(fld, url, wd, ht){
if(!wd) var wd=720
if(!ht) var ht=540
url += (url.indexOf('?')>0?'&':'?') + 'flt=' + escape(fld);
return window.showModalDialog(url, self, "dialogWidth:"+wd+"px;dialogHeight:"+ht+"px;center:Yes;help:No;resizable:No;status:No;");
}

function debug(str){
//alert(str);
window.showModalDialog("/include/js/debug.htm", str, "dialogHeight: 240px; dialogWidth: 320px; center: Yes; help: No; resizable: No; status: No;");
}

function JsInputBox(content, subject, defaultvalue, dataformat){
if(!dataformat) dataformat=""
var str=escape(content) + '; ' + escape(subject) + '; ' + escape(defaultvalue) + '; ' + escape(dataformat);
return window.showModalDialog("/include/js/InputBox.htm", str, "dialogWidth:400px;dialogHeight:150px;center:Yes;help:No;resizable:No;status:No;");
}
function JsGetYM(yymm){
if(!yymm) var yymm=''
return window.showModalDialog("/include/selectym.asp", yymm, "dialogWidth:400px;dialogHeight:150px;center:Yes;help:No;resizable:No;status:No;");
}
function JsGetWK(wkcode){
if(!wkcode) var wkcode=''
return window.showModalDialog("/include/selectwk.asp", wkcode, "dialogWidth:400px;dialogHeight:150px;center:Yes;help:No;resizable:No;status:No;");
}
function JsGetTM(tm, fmt){
if(!tm) var tm=''
if(!fmt) var fmt='2'
var str=tm+';'+fmt
return window.showModalDialog("/include/selecttm.htm", str, "dialogWidth:400px;dialogHeight:150px;center:Yes;help:No;resizable:No;status:No;");
}
function fnPrint(){window.print();}

function redirect(str){window.location=str;}

document.attachEvent('onkeydown',syshotkey);
//document.attachEvent('oncontextmenu',new Function('return false'));
document.attachEvent('onhelp',new Function('var wobj=openwindow("/help.htm","help",640,480);wobj.focus();return false'));
//window.attachEvent('onerror',fnErrorTrap);
//window.attachEvent('onerror',new Function('return true'));
window.attachEvent('onload',w_onload);

