function divWin_show()
{
var oDiv=gid('div_window_box');
if(gbl('div_win_w_h').indexOf(',')>-1)
{
var arr=gbl('div_win_w_h').split(',')
var w=arr[0];
var h=arr[1];
}
if(!w || w.length<2)
{
w=680;
h=450;
}
oDiv.style.width=w;
oDiv.style.height=h;
oDiv.style.display="block"
var l=(document.body.clientWidth-oDiv.offsetWidth)/2
var t=(document.body.clientHeight-oDiv.offsetHeight)/2
oDiv.style.left=l;
oDiv.style.top=t;
}
function divWin_close()
{
var oDiv=document.getElementById('div_window_box');
divWin_max(0,_gId("div_win_close_max"))
oDiv.style.display='none';
document.getElementById('Layer_bg').style.display='none';
if(_gId("index_new_record"))
{
_gId("index_new_record").removeNode(true);		
}
}
var xxxxxx_tb="";
function divWin_min(obj)
{
if(_gId("index_new_record"))
{
_gId("index_new_record").removeNode(true);		
}
var tb=_gId("div_window_tb");
obj.outerHTML="<a href=#ytd; id=div_win_close_max onClick='divWin_max(0,this)'></a>";
if(!tb)return;
xxxxxx_tb=tb.outerHTML;
var s='<table width=200px height=20px border="0" cellpadding="0" id="test_tb" cellspacing="0">';
for(var i=0;i<2;i++)
{
s+=tb.rows[i].outerHTML;	
}
s+="</table>";
div_window_box.innerHTML=s;
div_window_box.style.width=200;
div_window_box.style.height=20;
}
function divWin_max(mm,obj)
{
if(_gId("index_new_record"))
{
_gId("index_new_record").removeNode(true);		
}
var n;
if(mm==1)
{	
_gId("max_or_min").value=0;
var maxWidth=document.body.offsetWidth;
var maxHeight=document.body.offsetHeight;
_gId("div_window_box").style.width=maxWidth;
_gId("div_window_box").style.height=maxHeight;
_gId("div_window_box").style.top=0;
_gId("div_window_box").style.left=0;
n=0;
if(xxxxxx_tb!="")
{
_gId("div_window_box").innerHTML=xxxxxx_tb;
xxxxxx_tb="";
}
}
else
{
_gId("max_or_min").value=1;
if(xxxxxx_tb!="")
{
_gId("div_window_box").innerHTML=xxxxxx_tb;
xxxxxx_tb="";
}
divWin_show();
n=1;
}
obj.outerHTML="<a href=#ytd; id=div_win_close_max onClick='divWin_max("+n+",this)'>-大小-</a>";
}
function divWin_open(fileName,id,open_type,win)
{
var pid_str="";
gid("div_win_b2_2").style.display=""
gid("div_win_b2_4").style.display=""
if(fileName.indexOf('f000000shenpi')>-1)
{
var url='../'+asp_php+'/get_subTb_info.'+asp_php+'?exe=get_sub_tb_info&fileName='+fileName+'&id='+id;
var str=ajax(url);
var arr=str.split("<||>");
fileName=arr[0];
id=arr[1];
}
if(win.document.location.href.indexOf('index.htm')>-1)
{
if(gid('div_toolBar_and_subMk').style.position=='absolute')
{
win=frame_subMk;
}
}
var pid=request("parent_id",win);
var pf=request("parent_fileName",win);
if( top.dialogArguments || pf!='' || pid!='' || open_type=='dialog_add')
{
var exe=""
if(!id){exe="add"}else{exe="modify"}
var u1="work_tr_box.htm";
var u2="exe="+exe+"&id="+id
var url=request_all("exe,id",win);
if(url.length<2){url=u1+"?"+u2}else{url=u1+url+"&"+u2}
var go_str=url;
open_dialog("win_dialog.htm?go="+go_str,720,500,1,win);
return;
}
else if(pid != '')
{
pid_str="&parent_id="+pid+"&parent_fileName="+pf;
}
gid("cur_group").value="groups__0"; 
if (!id || id+''=='')
{
url='work_tr_box.htm?exe=add&fileName='+fileName+pid_str;
gid('div_win_c').innerHTML=create_iframe('frame_tr_box',url,'');
if(gid("div_win_but_prePage"))
{
gid("div_win_but_prePage").style.display="none"
gid("div_win_but_pre").style.display="none"
gid("div_win_but_next").style.display="none"
gid("div_win_but_nextPage").style.display="none"
gid("div_save_but_new").style.display="block"
}
}
else
{
if(typeof(frame_tr_box)=='undefined')
{
gid('div_win_c').innerHTML=create_iframe('frame_tr_box','about:blank','');
}
if(gid("div_save_but_new"))
{
gid("div_win_but_prePage").style.display=""
gid("div_win_but_pre").style.display=""
gid("div_win_but_next").style.display=""
gid("div_win_but_nextPage").style.display=""
gid("div_save_but_new").style.display="none"	
}
var old_f=request("fileName",frame_tr_box);
var old_exe=request("exe",frame_tr_box);
if (open_type=="link")
{
var obj=win.event.srcElement;
if(!obj)return;
var curTd=obj.parentElement;
var tr0_curTd=mw_get_tr0_curTD(curTd,win)
var typ=tr0_curTd.input_type;
if(typ.indexOf('link:')>-1)
{
var url
var typ=typ.replace('link:','');
if(typ+""=="")
{
url+="";	
}
else
{
if(typ.indexOf("?")==typ.length-1)
{
url=typ+'fileName='+fileName+"&id="+id;	
}else if(typ.indexOf("?")==-1)
{
url=typ+'?fileName='+fileName+"&id="+id;	
}else
{
url=typ+'&fileName='+fileName+"&id="+id;	
}
}
}else if(tr0_curTd.coltyp=="but:tongYong")
{
url=obj.getAttribute("data-href")
}
gid('frame_tr_box').src=url;
gid("div_win_b2_2").style.display="none"
gid("div_win_b2_4").style.display="none"
}else if(exe="modify" && old_f==fileName && typeof(frame_tr_box)!='undefined')
{
if(gid("frame_tr_box").src.indexOf("work_tr_box.htm")==-1)
{
var url='work_tr_box.htm?exe=modify&id='+id+"&divWin_open="+open_type+'&fileName='+fileName+pid_str;
gid('frame_tr_box').src=url;
}
var url="../"+asp_php+"/work_tr_exe."+asp_php+"?id="+id+"&fileName="+fileName;
var of=gid('frame_blank',frame_tr_box);
if(of){of.src=url;}
wt_up_id(id,frame_tr_box);
}
else
{
var url='work_tr_box.htm?exe=modify&id='+id+"&divWin_open="+open_type+'&fileName='+fileName+pid_str;
gid('frame_tr_box').src=url;
}
}
gid('Layer_bg').style.display='block';
divWin_show();
}
function right_open(fileName,id,open_type,win)
{
main_sh_right(win.parent);
try
{	
var f=gid('frame_main_tr',win.parent);
if(f.src.indexOf('work_tr_box.htm')>-1)
{
var url="../"+asp_php+"/work_tr_exe."+asp_php+"?id="+id+"&fileName="+fileName;
var f2=gid('frame_blank',win.parent.frame_main_tr);
if(f2)
{
if(f2.src!=url)
{
f2.src=url;
wt_up_id(id,win.parent.frame_main_tr);
}
}
}
else
{
gid("cur_group").value="groups__0"; 
var url='work_tr_box.htm?exe=modify&id='+id+"&divWin_open="+open_type+'&fileName='+fileName;
f.src=url;
}
}
catch(e)
{
}
}
function add_shenPi(win)
{
open_dialog("../main/dialog.htm?go=../asp/shenPi_mb_select.asp",900,600,1)
var url="../main/shenPi_mb_select.htm";
}
function up_file(win)
{
var pf=tf.giv('par_fileName',win)
var ifs=win.document.getElementsByTagName("IFRAME");
var pid=""
for(var i=0;i<ifs.length;i++)
{
var url=ifs[i].src;
if(url && url.indexOf('parent_id=')>-1)
{
var arr=url.split('parent_id=');
var s2=arr[1];
if (s2.indexOf("&")>-1)
{
s2=s2.substr(0,s2.indexOf("&"));
}
pid=s2
break;
}
}
url="../main/file_upfile.htm?fileName="+fileName.value+"&parent_fileName="+pf+"&parent_id="+pid+"&ok_js=top.up_file_ok('{old_name}',1)";
open_dialog(url,600,150,1);
}
var win_tuo=false;
var win_tuo_obj;
function divWin_tuo_down(obj)
{
while(obj.name!='win_tuo_div'){obj=obj.parentNode}
document.all.Layer_tuo_bg.style.visibility='visible';
document.all.div_win_frame.style.visibility='hidden';
win_tuo_obj=obj;
win_tuo=true;
}
function divWin_tuo_move()
{
if(win_tuo==false)return;
var oF=document.getElemnetById('div_win_frame');
if(oF)oF.style.visibility='visible';
win_tuo_obj.style.left=event.clientX-win_tuo_obj.offsetWidth/2;
win_tuo_obj.style.top=event.clientY-5;
}
function divWin_tuo_up()
{
var oDiv=document.getElementById('Layer_tuo_bg');
if(oDiv)oDiv.style.visibility='hidden';
var oF=document.getElementById('div_win_frame');
if(oF)oF.style.visibility='visible';
win_tuo=false;
}
function div_goto_up(curDiv)
{
var divs=document.getElementsByTagName('DIV')
for(var i=0;i<divs.length;i++)
{
if (divs[i]!=curDiv && divs[i].style.zIndex>=curDiv.style.zIndex){
curDiv.style.zIndex=divs[i].style.zIndex+1;
}
}
}
function divWin_reload()
{
var id=giv("tr_record_id",frame_tr_box);
var f=request("fileName",frame_tr_box);
var url="work_tr_box.htm?fileName="+f
if(id=="")
{
url+="&exe=add";
}
else
{
url+="&exe=modify&id="+id;
}
frame_tr_box.document.location.href=url;
}
function divWin_go_record(n,win) 
{
if(!win)var win=window;
if(win.parent.document.location.href.indexOf('win_dialog.htm')>-1)return;
var pre_r_a=gid("div_win_but_pre");
var next_r_a=gid("div_win_but_next");
if(n==-9)
{
if(pre_r_a){pre_r_a.disabled=true;}
if(next_r_a){next_r_a.disabled=true;}
return;
}
var main_frame=get_main_frame();
if(!main_frame)return;
var cur_id=giv("tr_record_id",frame_tr_box);
var arr_i=-1;
var cur_i=0;
var cs=main_frame.document.getElementsByName("id");
if(cs.length<=0){return;}
for(var i=0;i<cs.length;i++)
{
if(cs[i].value==cur_id)
{
cur_i=i;
break;
}
}
var new_i=cur_i+n;
pre_r_a.disabled=(new_i<=0)?(true):(false);
next_r_a.disabled=(new_i>=cs.length-1)?(true):(false);
if(n==0)return;
if(new_i<0)return;
if(new_i>=cs.length)return;
var new_id=cs[new_i].value;
var url="../"+asp_php+"/work_tr_exe."+asp_php+"?fileName="+request("fileName",frame_tr_box)+"&id="+new_id;
gid('frame_blank',frame_tr_box).src=url;
wt_up_id(new_id,win);
main_show_cur_tr(new_id,main_frame)
}
function divWin_go_page(n,win)
{
var pre_a=_gId("div_win_but_prePage",win);
var next_a=_gId("div_win_but_nextPage",win);
if(n==-9)
{
if(pre_a){	pre_a.disabled=true;}
if(next_a){next_a.disabled=true;}
return;
}
var fileName=tf.giv("fileName",win);
var main_frame=get_win("main_frame_"+fileName);
if(!main_frame)return;
var cur_page_obj=main_frame.page_form.input_cur_page;
var cur_datacount=main_frame.page_form.input_data_count.value;
var count_in_page=main_frame.page_form.input_count_in_page.value;
var page=cur_datacount/count_in_page;
var pageCount=(cur_datacount%count_in_page==0)?(parseInt(page)):((parseInt(page))+1);
var cur_page=cur_page_obj.value;
var new_page=cur_page-0+n;
pre_a.disabled=(new_page<=1)?(true):(false);
next_a.disabled=(new_page>=pageCount)?(true):(false);
if(new_page<1)return;
if(new_page>pageCount)return;
main_frame.open_first=(n==0)?0:1;
if(n==0)return;
goTo(new_page,main_frame)
}
function get_main_frame() 
{
var fileName=_gId("fileName",parent).value;
return get_win("main_frame_"+fileName);
}
function new_record(obj)
{
var new_id=gid("tr_record_id",frame_tr_box);
if(gid("index_new_record"))
{
gid("index_new_record").removeNode(true);		
}
if(new_id.value!="")
{
frame_tr_box.form1.reset();
new_id.value='-1';
add_get_defualt(frame_tr_box);
}
else 
{
var t=lang4("_system_prompts");
var c=lang4("_Whether")+"<p><a href=#ytd; onclick=\"frame_tr_box.form1.reset();index_new_record.style.display='none'\">"+lang4("_Y")+"</a>&nbsp;<a href=#ytd;  onClick=\"index_new_record.style.display='none'\">"+lang4("_N")+"</a></p>";
zhiShiPai_show(window,obj,t,c,"index_new_record",'lt-lb',222,50,-8,0);
}
}
function copy_cur_record()
{
var new_id=_gId("tr_record_id",frame_tr_box.window);
if(_gId("index_copy_record"))
{
_gId("index_copy_record").removeNode(true);		
}
if(new_id.value!="")
{
if(confirm(lang4("_copy_data")))
{
new_id.value="-1";
save_2mk_info(0);
}
}
else
{
var obj=_gId("div_win_but_save");
var t=lang4("_system_prompts");
var c=lang4("_data_then_copy");
zhiShiPai_show(window,obj,t,c,"index_new_record",'lt-lb',222,50,-8,0);	
}
}
function print_a()
{
var f=request("fileName",frame_tr_box);
var id=giv("tr_record_id",frame_tr_box);
if(id==""){alert("请保存后再打印");return;}
open_dialog("mb_list.htm?exe=print&fileName="+f+"&id="+id,1200,800,1)
}
function dialog_add(fileName,pf,pid,default_value_str,win)
{
var go_str="work_tr_box.htm?fileName="+fileName+"&parent_fileName="+pf+"&exe=add&parent_id="+pid;
if(default_value_str)
{
go_str+=default_value_str;
}
var url="../../../sys/mis/main/win_dialog.htm?fileName="+fileName+"&go="+go_str;
open_dialog(url,720,500,1,win);
}
function dialog_edit(fileName,id,win)
{
var go_str="work_tr_box.htm?fileName="+fileName+"&exe=modify&id="+id;
var url="../../../sys/mis/main/win_dialog.htm?go="+go_str;
open_dialog(url,920,600,1,win);
}