function mw_select(win)
{
var td=win.cur_td;
if(!td)return;
var o=td.getElementsByTagName('INPUT')[0];
if(!o)
{
mw_create_input(td,win);
o=td.getElementsByTagName('INPUT')[0];
o.value=td.v;
}
return o;
}
function mw_exe(win,exe)
{
var o=mw_select(win);
o.focus();
o.select();
o.document.execCommand(exe);
var e=gid('editBox',win.parent)
if(e &&o)e.value=o.value;
}
function mw_zhiShiPai_show(win,obj)
{
var t="<div id=div_zsp_but><a href=#ytd;  onclick=tf.mw_exe(window,'Copy') id=zsp_copy>复制</a><a href=#ytd; onclick=tf.mw_exe(window,'Cut'); id=zsp_cut>剪切</a><a href=#ytd;  onclick=tf.mw_exe(window,'Paste') id=zsp_paste>粘贴</a><a href=#ytd; id=zsp_to_win onclick=tf.mw_to_win(window) title='在窗口中打开本记录'></a></div>";
var td=obj;
var o=gid('tr0',win.parent).cells[td.cellIndex];
var buts="";
if(o.buttons_xg && o.buttons_xg!=''){buts=get_button_html(o.buttons_xg,o.id,3,o.cellName)}
var arr=o.check_weiYi_str.split("_cf_");
var c="<span id=col_but style='display:none2'>"+buts+"</span>";
zhiShiPai_show(win,obj,t,c,"main_work_pai",'ct-lb',150,30,-8,0);
var o=_gId('main_work_pai',win);
o.style.filter='Alpha(Opacity=80)';
}
function get_button_html(bts,zd_id,count,col)
{
if(bts=="")return "";
if(bts.indexOf("|/tr|")>0)
{
var arr=bts.split("|/tr|"),arr1,elseStr="";
if(count>5)count=5;
var s="<table border=0 cellpadding=0 cellspacing=0><tr>"
for(var i=0;i<arr.length-1;i++)
{
if((i+1)<=count)
{
arr1=arr[i].split("|/td|");
s=s+"<Td><a title='"+arr1[1]+"' col='"+col+"' style='width:16px;' onclick="+arr1[2]+"><span style='background-image:url("+arr1[3]+");width:100%'></span></a></td>"
}
elseStr+=arr[i].replace("|/tr|","|/td|")+"|/td|0|/tr|";
}
if(elseStr!=""&&arr.length>5)
{
elseStr=elseStr.replace(/\'/g,"@@");
s+="<td><a style='width:16px;color:gray;' wanneng_menu=0 onclick=\"tf.show_other_menu('work_tr_exe_xgBts"+zd_id+"','"+elseStr+"',this)\">";
s+="></a></td>";
}
s+="</tr></table>";
return s;
}
return "";
}
function mw_alpha(win)
{
var o=gid('main_work_pai',win);
if(!o)
{	
return;
}
var o_l=o.style.left.replace(/px/gi,'')-0;
var o_t=o.style.top.replace(/px/gi,'')-0;
var o_r=o_l+o.offsetWidth;
var o_b=o_t+o.offsetHeight;
var x=win.event.clientX+win.document.body.scrollLeft;
var y=win.event.clientY;
var w=h=0;
if(y<o_t)
{
h=o_t-y;
if(x<o_l){w=o_l-x}
else if(x>o_r){w=x-o_r}
else{w=0}
}
else if(y>o_b)
{
h=y-o_b;
if(x<o_l){w=o_l-x;}
else if(x>o_r){w=x-o_r;}
else{w=0}
}
else
{
h=0;
if(x<o_l){w=o_l-x}
else if(x>o_r){w=x-o_r}
else{w=0}
}
var c=(w>h)?w:h;
if(c>100)c=100;
if(c<0)c=0;
var p=100-c;
var old=o.style.filter;
if(old.indexOf('=')>-1)
{
old=old.split("=")[1];
old=old.split(")")[0];
}
else
{
old=100;
}
if(old-0==p-0)return;
o.style.filter=(p-0==100)?"":"Alpha(Opacity="+p+")";
}
function mw_down(obj,win)
{
var td=_gPar("obj.tagName=='TD'",obj);
var tr=_gPar("obj.tagName=='TR'",obj);
var id=tr.id.replace('tr_','');
var f=request("fileName",win);
var url="../"+asp_php+"/file."+asp_php+"?fileName="+f+"&id="+id;
gid("frame_blank").src=url
}
function mw_edit_mouseUp(oTb,win)
{
if(win.event.button!=1)return;
var obj=win.event.srcElement;
var c1=gid('but_click',win.parent).className;
var c2=gid('but_click_bottom',win.parent).className;
var c3=request("win_record_show_type",win)
if( c1=='view_selected' || c2=='view_selected' ||c3=="click_bottom")
{
mw_show_right(win,oTb,obj);
}
else
{
mw_edit_mouseUp2(win,oTb,obj);
}
}
function mw_edit_mouseUp2(win,oTable,obj)
{
if(win.document.location.href.indexOf("f000000shenpi")>-1)return;
if(request("mw_edit",win.parent)=='no' || giv('mw_edit',win)=='no')return;
var ed=_gId('editBox',win.parent);
var pai=_gId('main_work_pai',win)
var curTd=_gPar("obj.tagName=='TD'",obj);
if (curTd.tagName!='TD')return;
win.cur_td=curTd;
if(obj.tagName=="A") 
{
var input=obj.parentElement.getElementsByTagName('INPUT')[0];
if (input)
{
mw_td_winEdit(win);
return;
}
var col_nam=obj.nam;
var head_tb=_gId("head_tb",win.parent);
var cs=head_tb.rows[0].cells;
for(var i=0;i<cs.length;i++)
{
if(cs[i].cellName==col_nam)
{
if(cs[i].input_type)
{
eval("win.parent."+cs[i].input_type);
}
}
}
return;	
}
else if(obj.tagName=="TD" && obj.getElementsByTagName("A")[0])
{
if(ed){ed.value='';ed.disabled=true}
return;
}
if(obj.tagName=="TD" || obj.tagName=="INPUT")
{
if(obj==win.edit_obj)
{
if(ed)ed.disabled=false;
if(ed)ed.value=(obj.tagName=='INPUT')?obj.value:obj.innerText;
var curTable=oTable;
var tr0_curTd=mw_get_tr0_curTD(curTd,win)
if(tr0_curTd.input_type=='')
{
mw_zhiShiPai_show(win,curTd)
}
else
{
if(pai)pai.style.display='none';
}
var value;
if(obj.tagName=="TD")
{
var o=obj.getElementsByTagName('INPUT')[0]
if(!o)
{
mw_create_input(curTd,win);
o=curTd.getElementsByTagName('INPUT')[0];
if(o)
{
o.focus();
o.value=curTd.v;
}
else
{
pai=gid('main_work_pai',win);
if(pai)
{
gid("zsp_paste",win).style.display='none';	
gid("zsp_copy",win).style.display='none';	
gid("zsp_cut",win).style.display='none';
}
return;
}
}
ed.value=o.value;
}
if(obj.tagName=="INPUT"){ed.value=obj.value}
pai=gid('main_work_pai',win);
if(tr0_curTd.read_write=='read' || tr0_curTd.read_write=='random')
{
if(pai)
{
gid("zsp_paste",win).style.display='none';	
gid("zsp_copy",win).style.display='none';	
gid("zsp_cut",win).style.display='none';
}
ed.disabled=true;
return;
}
else
{
ed.disabled=false;
}	
}
}
}
function mw_create_input(td,win)
{
var id=mw_get_trID(td);
var tr0_curTD=mw_get_tr0_curTD(td,win);
var colName=tr0_curTD.cellName;
var input_name="t$"+colName+"$"+id;
var arr=tr0_curTD.input_type.split(':');
var typ=arr[0];
td.v=td.innerText;
var foc=" onfocus='tf.mw_input_focus(this,window)' ";
var blu=" onBlur='tf.mw_input_blur(this,window) '";
var key=" onkeyDown='tf.search_box_upDown(this,window)' ";
var keyUp=" onkeyUp='tf.mw_input_keyUp(this,window)' ";
switch (typ)
{
case "select":		key+=" onKeyup=tf.mw_sou_by_code(this,window) ";break;
case "select_write":key+=" onKeyup=tf.mw_sou_by_code(this,window) ";break;
case "select_tb":	key+=" onKeyup=tf.mw_sou_by_code(this,window) ";break;
tf.show_bind_sel_box(this,'$"+colName+"',window)
case "class_tb": 	key+=" onKeyup=\";tf.mw_sou_by_class(this,'"+colName+"','"+escape(arr[1])+"',window)\"";break;
case "tb": 			key+=" onKeyup=\";tf.mw_sou_by_tb(this,'"+input_name+"','"+escape(arr[1])+"',window)\"";break;
}
var tr0_curTd=mw_get_tr0_curTD(td,win)
var read_only="";
var ed=_gId('editBox',win.parent);
if (tr0_curTd.read_write=="random")
{
read_only=" readonly style='color:#987;' ";
if(ed)ed.disabled=true;
}
else if(tr0_curTd.read_write=="read")
{
if(ed)ed.disabled=true;
return;
}
else
{
if(ed)ed.disabled=false;
}
var s="<a class='"+typ+"'><input "+read_only+" "+foc+blu+key+keyUp+" class='ok'  style='width:100%' autoComplete=off hid=yes name='"+input_name+"'></a>";
td.innerHTML=s;
}
function wm_sum(win)
{
var f=request("fileName",win);
var fileName=giv('fileName');
if(fileName!=f || !f){return;}
var sp=win.div_sum.getElementsByTagName("SPAN");
for(var i=0;i<sp.length;i++)
{
if(sp[i].id=='sum1')
{
var td=sp[i].parentElement;
var tb=td.parentElement.parentElement.parentElement;
var c=td.cellIndex;
var s=wm_sum_sub(win,c);
s=s.toFixed(2);
sp[i].innerHTML='小计：'+s;
sp[i].title='当前页小计：'+s;
var span_total=tb.rows[2].cells[c].getElementsByTagName("SPAN")[0];
if(span_total.sum_other.length<1)
{
var s2=span_total.sum-s
s2=s2.toFixed(2);
span_total.sum_other=span_total.sum-s;
}
else
{
var s2=span_total.sum_other-0+(s-0);
s2=s2.toFixed(2);
span_total.innerHTML="总计："+s2;
span_total.title="所有页面合计："+s2;
}
}
}
}
function wm_sum_sub(win,c)
{
var s=0;
var trs=win.div_body.getElementsByTagName("TR");
for(var i=0;i<trs.length;i++)
{
if(trs[i].id.indexOf("tr_"));
{
var v=trs[i].cells[c].innerText;
v=v.replace(/,/g,"");
s=addNum(s,v)
}
}
return s;
}
function addNum(num1,num2)
{
var sq1,sq2,m;
try{sq1=num1.toString().split(".")[1].length;} catch(e){sq1=0;}
try{sq2=num2.toString().split(".")[1].length;} catch(e){sq2=0;}
m=Math.pow(10,Math.max(sq1,sq2));
return ( num1 * m + num2 * m ) / m;
}
function mw_sou_by_class(obj,colName,class_tbName,win)
{
var url='../'+asp_php+'/work_tr_exe.'+asp_php+"?exe=search_className&obj_id=$"+colName+"&class_tbName="+class_tbName;
send_search_req(obj.name,url,'class_tb',win);
}
function mw_sou_by_tb(obj,input_name,tb_str,win)
{
var url=get_link_mk_url(tb_str,input_name);
send_search_req(obj.name,url,'tb',win);
}
function mw_sou_by_code(obj,win)
{
var td=_gPar("obj.tagName=='TD'",obj);
var tr0_curTD=mw_get_tr0_curTD(td,win);
var typ=tr0_curTD.input_type;
var sel_str=(typ.indexOf('select_tb')>-1)?(typ):(typ.split(':')[1]);
sou_by_code(obj,sel_str,win);
}
function mw_get_trID(obj)
{
if (obj==null) return 0;
var tr=_gPar("obj.id.indexOf('tr_')>-1",obj)
if(tr.tagName=='TR'){
return tr.id.replace("tr_","")
}
}
function mw_get_tr0_curTD(obj,win)
{
var td=_gPar("obj.tagName=='TD'",obj);
if(!td)return;
try{
var tr0_curTD=win.parent.document.getElementById('tr0').cells[td.cellIndex];
}catch(e)
{
alert('没有找到相关的列')}
return tr0_curTD;
}
function mw_over(obj)
{
obj.style.backgroundColor='#FF9';
return;
}
function mw_out(obj)
{
obj.style.backgroundColor='';
return;
}
function mw_not_record(win)
{
var o=gid('div_body',win);
if(o)o.innerHTML='<div id=div_no_content><br><br><br><br><p align=center><font color=red>暂无相关信息</font></p></div>';
mw_clear_sum(win);
}
function mw_show_noly_so(win)
{
var o=gid('div_body',win);
if(o)o.innerHTML='<div id=div_no_content><br><br><br><br><p align=center><font color=red>只能通过搜索得到结果</font></div></p>';
mw_clear_sum(win);
}
function mw_clear_sum(win)
{
var o=gid('div_sum',win);
if(o)o.innerHTML="";
}
function mw_show_tb(win,s)
{
s=s.replace(/<tr id=tr_/g,"<tr onMouseOver=tf.mw_over(this) onMouseOut=tf.mw_out(this) id=tr_");
var not=_gId('div_no_content',win);
if(not)not.removeNode(true);
var o=_gId('div_body',win);
if(!o)return;
if(o.innerHTML.length<10 || (o.innerHTML.length<200 && o.innerHTML.indexOf("...")>-1)  )
{
o.innerHTML=s;
}
else
{
o.insertAdjacentHTML('beforeEnd',s);
}
}
function mw_show_cur_tr(win)
{
var obj=win.event.srcElement;
var tr=_gPar("obj.tagName=='TR'",obj)
if(!tr)return;
if (tr.id.indexOf('tr_')>-1)
{
var id=tr.id.replace('tr_',"")+'';
var ids=win.parent.document.getElementsByName("id");
for(var i=0;i<ids.length;i++)
{
ids[i].checked=(ids[i].value+''==id)?true:false;
tf.main_show_cur_tr_2(ids[i],win.parent);
}
}
main_chkall_state(win);
}
function mw_show_cangWei_tr(win)
{
var obj=win.event.srcElement;
var a=_gPar("obj.tagName=='A'",obj);
if(!a.href)return;
if(a.href.indexOf('#id')<0)return;
var id=a.href.split('#id')[1];
if(request("exe",win.parent)=="select_record_a")
{
mw_go_select_record_a(id,win);
return;
}
var fileName=tf.request("fileName",win);
var c1=gid('but_click',win.parent).className;
var c2=gid('but_click_bottom',win.parent).className;
if( c1=='view_selected' || c2=='view_selected')
{
right_open(fileName,id,"edit",win);
}
else
{
divWin_open(fileName,id,"edit",win);
}
mw_set_cangWei_cur_class(id,win);
}
function mw_show_file_tr(win)
{
var obj=win.event.srcElement;
var a=_gPar("obj.tagName=='A'",obj);
if(!a.href)return;
if(a.href.indexOf('#file_id')<0)return;
var id=a.href.split('#file_id')[1];
if(request("exe",win.parent)=="select_record_a")
{
mw_go_select_record_a(id,win);
return;
}
var fileName=request("fileName",win);
var f=request("fileName",win);
var url="../main/dialog.htm?go=../htm1/file.htm1?exe=look&fileName="+f+"&id="+id;
open_dialog(url,800,600,0,win)
}
function mw_set_cangWei_cur_class(id,win)
{
var as=gid('div_body',win).getElementsByTagName("A");
for(var i=0;i<as.length;i++)
{
var a=as[i];
if(a.href && a.href.indexOf('#id')>-1)
{
a.className=(a.href.indexOf('#id'+id+'#id')>-1)?('cangWei_cur'):('');
}
}
}
function mw_show_sub_mk(win)
{	
var obj=win.event.srcElement;
if(!obj.href)return;
if(obj.href.indexOf('#sub')<0)return;
var curTd=obj.parentElement;
var tr0_curTd=mw_get_tr0_curTD(curTd,win)
var typ=tr0_curTd.input_type;
var tr=tf._gPar("obj.id.indexOf('tr_')>-1",obj)
var id=tr.id.replace('tr_',"")+'';
var div=gid('div_toolBar_and_subMk')
var div2=gid('div_toolBar_and_subMk_sub')
if(top.dialogArguments || div.style.position=='absolute'||win.dialogArguments||gid("div_window_box").style.display!="none")
{
var url=typ.replace('link:','');
url=url+"&parent_id="+id;
open_dialog(url,800,550,0);
return;
}
if (typ.indexOf('index.htm')==-1)
{
divWin_open(request("fileName",win),id,"link",win)
return;	
}
var fileName=typ.split('fileName=')[1];
fileName=fileName.split('&')[0];
gid('bg_subMk').style.display='';
gid('par_fileName').value=gid('fileName').value;
gid('fileName').value=fileName;
var tr_but=gid('tr_but',tf);
tr_but.style.height=tr_but.offsetHeight+'px';
div.style.position='absolute';
div.className='sub_window';
var w=document.body.offsetWidth;
var h=document.body.offsetHeight;
var w1=w*0.75;
var h1=h*0.75;
var x=(w-w1)/2;
var y=(h-h1)/2;
div.style.width=w1;
div.style.height=h1;
div.style.top=y;
div.style.left=x;
div2.style.width=w1-10;
div2.style.height=h1-10;
var ifa=gid('frame_subMk');
ifa.style.height=h1-50;
ifa.style.display='block';
var url="main.htm?"+typ.split('index.htm?')[1];
url=url.replace('main_left=h','main_left=s');
ifa.src=url+"&parent_id="+id;
}
function mw_hid_sub_mk(win)
{	
var div=gid('div_toolBar_and_subMk')
var div2=gid('div_toolBar_and_subMk_sub')
div.className='sub_window_no';
div.style.height='';
div.style.width='100%';
div2.style.height='';
div2.style.width='100%';
gid('bg_subMk').style.display='none';
div.style.position='';
var tr_but=gid('tr_but',tf);
tr_but.style.height='';
var f=gid('par_fileName').value;
gid('fileName').value=f;
gid('frame_subMk').style.display='none';
show_but_bar(f,request("tixin",win),win)
}
function mw_but_open_edit(win,edit_view)
{
var chs=win.document.getElementsByName('id');
for(var i=0;i<chs.length;i++)
{
if(chs[i].checked==true)
{
main_tr_edit(chs[i].value,win);
break;
}
}
}
function mw_is_sel(win)
{
try
{
var id_chks=win.parent.document.getElementsByName("id");
var i,j=0;
for(i=0;i<id_chks.length;i++)
{
if(id_chks[i].checked)
{
j++;	
}
}
}catch(e){}
if(j==0)
{
return false;
}
return true;
}
function mw_mouse_right(win)
{
tf.ytd_menu_hiddenAll(tops);
mw_show_cur_tr(win);
var menuObj=_gId("main_work_menu_right",tops); 
if(!menuObj)return;
menuObj.style.display="block";
var centerObj=menuObj.rows[1].cells[0].childNodes[0]; 
var f=request("fileName",win);
var main_frame=_gId("main_frame_"+f);
var x=get_left(main_frame); 
var y=get_top(main_frame);
var mainFrame=win.parent; 
var del=mainFrame.shai_form.del.value;
var s=",D,C,U,(,%,"; 
var hid_but=",d,s,S,e,r,v,"; 
var b="";
_gId("top_keyWord",tops).value="";
if(del==1) 
{
b="s.indexOf(','+but_id+',')>-1";
}
else
{
b="s.indexOf(','+but_id+',')<0";
}
var is_chk=mw_is_sel(win); 
var but_p=menuObj.getElementsByTagName("P");
for(var i=0;i<but_p.length;i++)
{
var but=but_p[i];
var but_id=but.id.split("_")[1];
if(eval(b) && but.cur_mk=='y')
{
but.style.display="block";
}
else 
{
but.style.display="none";	
}
if(hid_but.indexOf(","+but_id+",")>-1&&mw_is_sel(win)==false)
{
but.disabled=true;
but.outerHTML=but.outerHTML.replace("onclick=","onclick1=");
}
else
{
but.disabled=false;
but.outerHTML=but.outerHTML.replace("onclick1=","onclick=");
}
}	
var work_frame=_gId("workFrame",mainFrame);
x=x+get_left(work_frame);
y=y+get_top(work_frame);
menuObj.style.left=x+win.event.clientX;
menuObj.style.top=y+win.event.clientY;
var menu_h=menuObj.offsetHeight;
var body_h=tf.document.body.offsetHeight;
var jiantou1=menuObj.rows[0].cells[0].getElementsByTagName("A")[0];
var jiantou2=menuObj.rows[2].cells[0].getElementsByTagName("A")[0];
if(menu_h>body_h||body_h-menu_h<get_top(menuObj))
{
var menu_martop=body_h-get_top(menuObj);
var menu_marbot=menu_h-menu_martop;
menuObj.style.top=get_top(menuObj)-menu_marbot-35;
if(get_top(menuObj)<0) 
{
menuObj.style.top=0;
var jiantou_h=jiantou1.offsetHeight;
centerObj.style.height=body_h-jiantou_h*2-35;
}
}
if(centerObj.scrollHeight>centerObj.offsetHeight)
{
jiantou1.style.display="block";
jiantou2.style.display="block";	
}
else
{
jiantou1.style.display="none";
jiantou2.style.display="none";		
}
var menu_w=menuObj.offsetWidth;
var body_w=tf.document.body.offsetWidth;
var menu_x=get_left(menuObj);
if(menu_x+menu_w>body_w) 
{
menuObj.style.left=menu_x-menu_w;
}
}
function mw_to_win(win)
{
var id=_gId('edit_id',win);
main_tr_edit(id,win.parent);
}
function mw_check_weiYi_run(win)
{
var id=mw_get_trID(win.cur_td);
mw_check_weiYi(win.cur_td.getElementsByTagName('INPUT')[0],id,win);
}
function mw_check_weiYi(obj,id,win)
{
var td=_gPar("obj.tagName=='TD'",obj);
var o=_gId('tr0',win.parent).cells[td.cellIndex]
if(o.check_weiYi_str=='')return;
var arr=o.check_weiYi_str.split("_cf_");
if(obj.value=='')return;
xh = new ActiveXObject("Microsoft.XMLHTTP");	
var f=_gId("fileName").value
var url="../"+asp_php+"/execute."+asp_php+"?exe=check_weiYi&fileName="+f+"&id="+id+"&tdName="+obj.name.split(".")[1]+"&td="+encodeURIComponent(obj.value);
var str =ajax(url);
if(str.indexOf('this_value_is_used=y')>-1)
{
var tishi;
if (arr[0]=="")
{
tishi="注意：【"+o.innerText+"】的值是不可以重复的。\r\r当前值：“"+obj.value+"”已经存在。";
}
else
{
tishi=arr[0];
}
if(arr[2]=="no")
{
obj.className="input_err"
alert(tishi);
}
else
{
obj.className="input_err"
if(!confirm(tishi+'\r\r\r◎要忽略点：“确定”\r\r◎要重填点：“取消”'))
{
obj.focus();
}
}
}
else
{
obj.className="input_ok"
}
}
function mw_input_show_sel(obj,win)
{
var td=_gPar("obj.tagName=='TD'",obj);
var tr0_curTd=mw_get_tr0_curTD(td,win);
var arr=tr0_curTd.input_type.split(":");
var text=td.getElementsByTagName('INPUT')[0];
text.focus();
text.value+='';
switch (arr[0])
{
case "select" : show_search_box(arr[1],text.name,'select',win);break;
case "select_tb" :
var s=get_select_tb_str(text,win);
tf.show_search_box(s,text.name,'select',win);
break;
case "select_write" : show_search_box(arr[1],text.name,'select',win);break;
case "class_tb" : show_search_box(arr[1],text.name,'select',win);break;
case "tb" : show_search_box(arr[1],text.name,'select',win);break;
}
}
function mw_input_focus(obj,win)
{
obj.hid='no';
var o=win.parent.editBox;
if(o)o.value=obj.value;
}
function mw_input_keyUp(obj,win)
{
_gId('editBox',win.parent).value=obj.value;
}
function mw_input_blur(obj,win)
{
hid_search_box(obj,win)
obj.hid='yes';
var a=tf._gPar("obj.tagName=='A'",obj);
_gId('editBox',win.parent).value=obj.value;
if(a.className=='')
{
var td=tf._gPar("obj.tagName=='TD'",obj);
if(obj.value==td.v)
{
if(obj.hid=='yes')
{td.innerText=obj.value;}
}
else
{
win.form1.submit();
}
}
else
{
mw_text_auto_del(obj.name,win);
}
}
function mw_dblClick(win)
{
var obj =win.event.srcElement;
if(obj.tagName=="BODY")return;
obj=_gPar("obj.id && obj.id.indexOf('tr_')>-1",obj)
if (obj.id.indexOf('tr_')>-1)
{
var id=obj.id.replace('tr_','');
if(request("exe",win.parent)=="select_record_a")
{
mw_go_select_record_a(id,win);
return;
}
main_tr_edit(id,win.parent);
}
}
function mw_go_select_record_a(id,win)
{
var url="../"+asp_php+"/execute."+asp_php;
url+=request_all("record_id",win.parent);
url+="&record_id="+id
var ifr=gid('frame_asp',win);
ifr.src=url;
}
function mw_set_value_from_bindMk(obj_ids,obj_values,obj_name,win)
{	
var arr=obj_name.split('$');
var arr1=obj_ids.split(",");
var arr2=obj_values.split(",");	
for(var i=0;i<arr1.length;i++)
{
var n="t$"+arr1[i]+"$"+arr[2]
var o=gid(n,win);
var v=decodeURIComponent(arr2[i]);
if(o){o.value=arr2[i]?v:"";}
else
{
mw_auto_input(arr1[i],arr[2],v,win);
}
}
var div=gid("search_box_div__"+obj_name,win);
if(div)div.style.display="none";
}
function mw_set_title(win)
{  
var obj=win.event.srcElement;
var curTd=_gPar("obj.tagName=='TD'",obj);
if(curTd.tagName!="TD")
if(!curTd || curTd.tagName!='TD')return;
if (curTd.title!=curTd.innerText)curTd.title=curTd.innerText;
}
function mw_show_right(win,oTable,obj)
{
if(win.document.location.href.indexOf("f000000shenpi")>-1)return;
var tr=_gPar("obj.id && obj.id.indexOf('tr_')>-1",obj)
if (tr.id.indexOf('tr_')<0)return;
var id=tr.id.replace('tr_','');
var fileName=request('fileName',win)
right_open(fileName,id,"edit",win);
}
function mw_td_winEdit(win)
{
var x=win.event.offsetX;
var obj=win.event.srcElement;
if(obj.tagName!="A")return;
if(x+18<obj.offsetWidth)return;
var curTd=_gPar("obj.tagName=='TD'",obj);
if(!curTd)return;
var input_type=mw_get_tr0_curTD(curTd,win).input_type;
var input=obj.getElementsByTagName("INPUT")[0];
if(!input)return;
var arr=input_type.split(":");
obj.hid='no';
switch(arr[0])
{
case "class_tb":
win.showModalDialog('select_class_type.htm?class_tbName='+arr[1]+"&cn="+input.name+"&s="+input.value,win,'resizable:yes;status:no;help:no;dialogHeight:420px;dialogWidth:650px');
break;
case "tb":
var s=unescape(arr[1]);
s=s.replace(/\"/g,"");
s=s.replace(/\(/,")");
s=s.split(')')[1];
var arr_c=s.split(",");
var zdy_str=get_zdy_str(arr_c[3],arr_c[0],input.name);
var url='?exe=select_record_a&to_fileName='+arr_c[0]+"&to_cols="+arr_c[1]+"&from_cols="+arr_c[2]+"&from_fileName="+arr_c[3]+"&fileName="+arr_c[3]+zdy_str+"&cur_input_name="+input.name;
var url="main.htm"+url;
index_add_sub_content(url,win);
break;
case "select":;mw_input_show_sel(input,win);break;
case "select_tb":;mw_input_show_sel(input,win);break;
case "select_write":;mw_input_show_sel(input,win);break;
}
}
function mw_tds_ok(n,win)
{
var o=gname(n,win)[0];
if(!o)return;
var td=tf._gPar("obj.tagName=='TD'",o);
var tr=td.parentElement;
if(tr && tr.id.indexOf('tr_')>-1)
{
td.innerText=o.value;
}
else
{
o.removeNode(true);
}
}
function mw_tds_def_ok(s,win)
{
var arr=s.split("[/td]")
var col_nam=arr[0] 
var id=arr[1]
var tdv=arr[2]
var head_tb=_gId("head_tb",win.parent);
var cs=head_tb.rows[0].cells;
var colindex;
for(var i=0;i<cs.length;i++)
{
if(cs[i].cellName==col_nam)
{
colindex=i
break;
}
}
var cur_tr=win.document.getElementById('tr_'+id);
if(cur_tr)
{
var cur_td=cur_tr.cells[colindex];
if(cur_td)
{
cur_td.innerHTML=tdv
}
}
}
function mw_tds_old(n,win)
{
var o=gname(n,win)[0];
if(!o)return;
var td=tf._gPar("obj.tagName=='TD'",o);
var tr=td.parentElement;
if(tr && tr.id.indexOf('tr_')>-1)
{
td.innerText=td.v;
}
else
{
o.removeNode(true);
}
}
function get_zdy_str(from_fileName,to_fileName,input_name)
{
var cur_id=input_name.split("$")[2];
var url="../"+asp_php+"/execute."+asp_php+"?exe=get_select_win_zdy_str&from_fileName="+from_fileName+"&to_fileName="+to_fileName+"&id="+cur_id;
var s=ajax(url);
var arr=s.split("[zdy_str]");
if(arr.length>0)
{
return arr[1];
}else
{return ""}
}
function mw_editBox_to_cur(obj,win)
{
if (win.cur_td.all[0]&&win.cur_td.all[0].tagName=='INPUT')
{
win.cur_td.all[0].value=obj.value
}
else
{
var tr0_curTd=mw_get_tr0_curTD(obj,win)
var id=mw_get_trID(win.cur_td);
var s2="<input type=hidden disabled value="+obj.value+">";
var read_only="";
if (tr0_curTd.read_write=="random" || tr0_curTd.read_write=="read")read_only=" readonly ";
win.cur_td.innerHTML="<input "+read_only+" class=input_ok onBlur='tf.mw_input_blur(this)' name=t."+cell+"."+id+" onkeyup='form_edit.editBox.value=this.value' value="+obj.value+">"+s2;
}
}
function mw_auto_input(col_name,id,value,win)
{
var tr0=gid('tr0',win.parent);
var tds=tr0.cells;
for(i=0;i<tds.length;i++)
{
if(tds[i].cellName==col_name)
{
var tr=gid('tr_'+id,win);
var td=tr.cells[tds[i].cellIndex];
mw_create_input(td,win);
var input=td.getElementsByTagName('INPUT')[0];
siv2(input,value);
input.focus();
return;
}
}
var n="t$"+col_name+"$"+id
var s="<input type=hidden name='"+n+"'>"
_gId('auto_input_div',win).insertAdjacentHTML( "beforeEnd",s);
var o=_gId(n,win);
o.value=value;
}
function mw_edit_mouseDown(win)
{
if(win.event.button!=1)return;
if(request("exe",win)=='select_record_a')return;
win.edit_obj=win.event.srcElement;
win.cur_td=win.edit_obj;
if(win.cur_td.parentElement.tagName=='TD'){win.cur_td=win.cur_td.parentElement}
}
function mw_text_auto_del(n,win)
{
setTimeout(function(){mw_text_auto_del_sub(n,win)},300);
}
function mw_text_auto_del_sub(n,win)
{
var obj=win.document.getElementsByName(n)[0];
if(!obj)return;
var td=tf._gPar("obj.tagName=='TD'",obj);
if(obj.value==td.v)
{
if(obj.hid=='yes')
{td.innerText=obj.value;}
}
else
{
var id=tf.mw_get_trID(obj);
win.form1.submit();
}
}
function mw_select_a_ok(s,obj,div_ran)
{
var win=gf().workFrame;
var arr_n=obj.split('$');
var arr=s.split(","),arr1,n,o;
for(var i=0;i<arr.length;i++)
{
if(arr[i].indexOf('=')>-1)
{
arr1=arr[i].split('=');
n="t$"+arr1[0]+"$"+arr_n[2];
var o=tf.gid(n,win);
if(o){o.value=arr1[1]?decodeURIComponent(arr1[1]):""}
else
{
tf.mw_auto_input(arr1[0],arr_n[2],decodeURIComponent(arr1[1]),win);
}
}
}
index_del_sub_content(div_ran);
}
function mw_get_class_type(n,v,id,win)
{
var o=gname(n,win)[0];
if(o)o.value=v;
var arr=n.split('$');
var classId_str=arr[0]+"$"+arr[1]+"_classId_$"+arr[2];
var classId=tf.gid(classId_str,win);
if(!classId)
{
classId=tf.insertHtml("BeforeEnd",o.parentElement,"<input type=hidden name='"+classId_str+"' id='"+classId_str+"' >");
}
classId.value=id;
}
function mw_zdy_sou(win) 
{
var colName=tf.request("zdy_so_col",win)
if(colName!='')
{
mw_zdy_sou_sub(win);
}
}
function mw_zdy_sou_sub(win) 
{
var colName=tf.request("zdy_so_col",win)
var sel=win.parent.shai_form.col_name;
var yn="";
for(var i=0;i<sel.options.length;i++)
{
var cur=sel.options[i];
if(cur.value==colName)
{
yn="yes";
break;	
}
}
if (yn!='yes')
{
var sel_str=sel.outerHTML
sel_str=sel_str.replace(/<\/SELECT>/gi,"<option value='"+colName+"'>"+colName+"<\/option><\/SELECT>")
sel.outerHTML=sel_str;
}
var fh=request("zdy_so_fh",win);
var v=unescape(request("zdy_so_value",win));
win.parent.shai_form.col_name.value=colName;
win.parent.shai_form.fuhao.value=fh;
win.parent.shai_form.keyword.value=v;
main_submit_page_and_shai(win.parent,"sou");
var div=gid('div_tishi',win);
div.innerHTML="<button onclick=\"div_tishi.style.display='none';tf.main_reSet(parent);tf.main_submit_page_and_shai(parent);\">查看更多...</button>";
div.style.display='';
}
function mw_html_edit(fileName,tdName,id,win)
{
var url="dialog.htm?go=../"+asp_php+"/html_edit."+asp_php+"?id="+id+"&fileName="+fileName+"&tdName="+tdName
tf.open_dialog(url,800,600,1,win);
}