var IE=navigator.userAgent.indexOf('MSIE')>0;var myParent=parent;var pageitem,curpage,linkobj,listTagObj;var visobj='';var secode='';var mdlcode=window.name.substr(3);var cmpbit=myParent.cmpbit;var fontSize=getCookie("fontsize");if(fontSize=="") fontSize=13;var DATE_SEPARATOR='.';var DATE_TYPE=getCookie("date_type");var curdate=new Date();var dialogObj;var popObj=new Object();var oPop;var lastError;function makeFrame(id,left,top,width,height,hide,z_index){document.write('');}if(IE){oPop=window.createPopup();}else{makeFrame('popup',0,0,10,10,'none',1003);}makeFrame('page2',0,0,0,0,'none',1001);document.write('
');function bodycontextmenu(){}function bodyselectstart(){event.returnValue=false;}function bodydragstart(){event.returnValue=false;}function doc(v,isAll){return docAll(v,isAll);}function docAll(v,isAll){if(isAll){var objs=document.getElementsByName(v);return(objs);}else{var obj=document.getElementById(v);if(!obj){var objs=document.getElementsByName(v);if(objs.length==0){return(null);}else if(objs.length==1){return(objs[0]);}else if(objs.length>1){if(isAll){return(objs);}else{return(objs[0]);}}}}return(obj);}function getCoord(element){var coord={x: 0, y: 0};obj=element;while(obj){coord.x+=obj.offsetLeft;coord.y+=obj.offsetTop;obj=obj.offsetParent;}if(IE) return coord;obj=element;while(obj){if((obj.tagName) && (obj.tagName.toUpperCase()=="DIV") && ((obj.scrollLeft>0) || (obj.scrollTop>0))){coord.x-=obj.scrollLeft;coord.y-=obj.scrollTop;break;}obj=obj.parentNode;}return coord;}function href(){var i,s=window.location.href;i=s.indexOf("?");if(i>0) s=s.substr(0,i);return(s);}function setDialogWH(w,h){if(IE){window.dialogWidth=w+"px";window.dialogHeight=(h-50)+"px";}else{window.outerWidth=w;window.outerHeight=h;}}function addObjTop(obj){return((IE)?0:obj.offsetTop);}function getCookie(vName){var p1,p2,s=document.cookie;p1=s.indexOf(vName+'=');if(p1>=0){p1+=vName.length+1;p2=s.indexOf(";",p1);if(p2<0) p2=s.length;return(decodeURI(s.substring(p1,p2)));}return("");}function delCookie(name){document.cookie=name+"=; expires=null;";}function myoncontextmenu(e){var obj,s=window.location.href;try{if((s.indexOf("localhost")<0) && (getCookie("serno")!="0")){if(!e) var e=window.event;if(e.target){obj=e.target;}else if(e.srcElement){obj=e.srcElement;}if((obj.tagName.toLowerCase()!="input") &&(obj.tagName.toLowerCase()!="textarea")){if(IE) e.returnValue=false;return(false);}}}finally{}}function trim(value){var i,l,s=value+"";l=s.length;i=0;while((s.charCodeAt(i)<=32) && (i=l){return("");}else{while(s.charCodeAt(l-1)<=32) l--;return(s.substring(i,l));}}function getIntValue(v){var j;j=parseFloat(v);if(isNaN(j)) j=0;return(j);}function myRound(a,b){var s='10000000000';var j=parseFloat(s.substr(0,b+1));var i=Math.round(a*j);return(i/j);}function formatNumber(n,d){if(isNaN(n))return(n);var s1,s2,s3,i,j,k;n=trim(n);i=n.indexOf(".");if(i>=0){s1=n.substr(0,i);s2=n.substr(i);}else{s1=n;s2="";}s3="";i=0;k=0;j=s1.length;while(i=65) && (i<=90));}function fillLChar(s,l,c){var i,s1='';for(i=myLen(''+s);i=0;i--) sIntArabic+=sArabic.substr(i,1);for(iSection=0;iSection<=((sIntArabic.length-1)/4);iSection++){sSectionArabic=sIntArabic.substr(iSection*4,4);sSection='';for(i=0;i0)) sSection='零'+sSection;bInZero=true;}else{if(i==1){sSection='拾'+sSection;}else if(i==2){sSection='佰'+sSection;}else if(i==3){sSection='仟'+sSection;}sSection=_ChineseNumeric.substr(iDigit,1)+sSection;bInZero=false;}}if(sSection.length==0){if((r.length>0) && (r.substr(0,1)!='零'))r='零'+r;}else{if(iSection==0){r=sSection;}else if(iSection==1){r=sSection+'萬'+r;}else if(iSection==2){r=sSection+'億'+r;}else if(iSection==3){r=sSection+'兆'+r;}}}if(r.length==0) r='零';if(bMinus) r='負'+r;return(r);}function validTime(vObj){if(vObj.value.length==4){vObj.value=vObj.value.substr(0,2)+":"+vObj.value.substr(2,2)}}function validNumber(e,isDec){var keyCode=('which' in e) ? e.which : e.keyCode;var isNumeric=((keyCode>=48 && keyCode<=57) || (keyCode>=96 && keyCode<=105)) && (!e.shiftKey);isNumeric=isNumeric || (keyCode==8) || (keyCode==46);isNumeric=isNumeric || (keyCode>=37 && keyCode<=40);if(isDec) isNumeric=isNumeric || (keyCode==190) || (keyCode==110) || (keyCode==189) || (keyCode==109);return isNumeric;}function validNumber_o(e){var s,i,c;i=(window.event) ? e.keyCode : e.which;var c=String.fromCharCode(i);if("0123456789-.".indexOf(c)<0){if(IE){event.returnValue=false;}else{return false;}}}function myReplace(v,s1,s2){var re=new RegExp(s1,"g");return(v.replace(re,s2));}function myLen(v){var i=0,j=0;while(i127) j++;j++;i++;}return(j);}function mySerno(v){var s,d=(v==null) ? new Date(myParent.curdate) : v;var d1=new Date();s=myEDate(d);s=s.substr(2,2)+s.substr(5,2)+s.substr(8,2)+myTime(d).replace(/:/g,"")+fillLChar(d1.getMilliseconds(),3,"0");return(s);}function mySno(v){var s,d,d1;d=(v==null) ? new Date(myParent.curdate) : v;s=Math.abs(Date.parse(d)/86400000)+"";d1=new Date();return(s.substr(0,5)+s.substr(6,5)+fillLChar(d1.getMilliseconds(),3,"0"));}function myDate(v){return(myDateA(v,DATE_TYPE=='1'));}function myDateA(v,isC){var i,s,d;if(v==null) d=new Date(myParent.curdate); else d=v;s=d.getFullYear();if(isC){s=s-1911;if(s<100) s='0'+s;}s+=DATE_SEPARATOR;i=d.getMonth()+1;if(i<10) s+='0';s=s+i+DATE_SEPARATOR;i=d.getDate();if(i<10) s+='0';s=s+i;return(s);}function myEDate(v){return(myDateA(v,false));}function myCDate(v){return(myDateA(v,true));}function myYear(vdate){var i,s,d;d=(vdate==null) ? new Date(myParent.curdate) : vdate;s=d.getFullYear();if(DATE_TYPE=="1"){s=s-1911;if(s<100) s='0'+s;}return(s);}function myMonth(vdate){var s,i,d;d=(vdate==null) ? new Date(myParent.curdate) : vdate;s='';i=d.getMonth()+1;if(i<10)s='0';s=s+i;return(s);}function myDay(vdate){var s,i,d;d=(vdate==null) ? new Date(myParent.curdate) : vdate;s='';i=d.getDate();if(i<10)s='0';s=s+i;return(s);}function myTime(vdate){var s='',i,d;d=(vdate==null) ? new Date(myParent.curdate) : vdate;i=d.getHours();if(i<10)i="0"+i;s+=i+":";i=d.getMinutes();if(i<10)i="0"+i;s+=i+":";i=d.getSeconds();if(i<10)i="0"+i;s+=i;return(s);}function myCDay(vdate){var d,i,x=new Array("日","一","二","三","四","五","六");d=(vdate==null) ? new Date(myParent.curdate) : vdate;return(x[d.getDay()]);}function myUpdTime(vdate){return(myEDate()+' '+myTime()+' '+myCDay());}function strToDate(value){var s=value.split(DATE_SEPARATOR);var s1;var d=new Date();if(DATE_TYPE=="1"){s1=s[0];if(s1.length==2) s[0]="0"+s[0];s[0]=""+(parseInt("1"+s[0])+911);}s1=s[1];if(s1.length==1) s[1]="0"+s[1];d.setFullYear(s[0],parseInt("1"+s[1])-101,s[2]);return(d);}function extractFileName(v){v=v.replace(/\//g,'\\');var i=v.lastIndexOf('\\');if(i>=0){return(v.substr(i+1));}else{return(v);}}function extractFileExt(v){var i=v.lastIndexOf(".");return (i>0) ? v.substr(i) : "";}function queryString(v,v1){var i,s,a,b;s=(v1==null) ? window.location.href : v1;i=s.indexOf("?");if(i>=0){a=s.substr(i+1).split("&");for(i=0;iobj.height){obj.width=w;obj.height=obj.height*w/obj.width;if(h!=null){if(obj.height>h) obj.height=h;}}else{obj.width=obj.width*h/obj.height;obj.height=h;if(obj.width>w) obj.width=w;}}function getSecode(v){var s='0000000000';if(myParent.xMenu.Locate('sys_mdl_code',v)){s='';s+=(myParent.xMenu.Fields('per_run').value=='True') ? '1' :'0';s+=(myParent.xMenu.Fields('per_add').value=='True') ? '1' :'0';s+=(myParent.xMenu.Fields('per_mod').value=='True') ? '1' :'0';s+=(myParent.xMenu.Fields('per_del').value=='True') ? '1' :'0';s+=(myParent.xMenu.Fields('per_prn').value=='True') ? '1' :'0';s+=(myParent.xMenu.Fields('per_exp').value=='True') ? '1' :'0';s+=(myParent.xMenu.Fields('per_ext1').value=='True') ? '1' :'0';s+=(myParent.xMenu.Fields('per_ext2').value=='True') ? '1' :'0';s+=(myParent.xMenu.Fields('per_ext3').value=='True') ? '1' :'0';s+='0';}return(s);}function isSec(v,v1){var s=(v1) ? v1 :mdlcode;if(!myParent.xMenu.Locate("sys_mdl_code",s)) return(false);return myParent.xMenu.Fields("per_"+v).value=="True";}function setColor(vObj,vColor,vText){var a=vColor.split(",");var i,j,k;for(i=0;i<=2;i++){for(j=0;j<=2;j++){for(k=0;k<=2;k++){var oOption=document.createElement("OPTION");vObj.options.add(oOption);oOption.value="#"+a[i]+a[j]+a[k];oOption.style.backgroundColor=oOption.value;oOption.text=(vText==null) ? oOption.value : vText;}}}}function setSelectColor(obj){if(IE) return;try{obj.style.backgroundColor=obj.options[obj.selectedIndex].style.backgroundColor;}catch(e){}}function getList(e,obj,kind,isSort,vWidth){var s,rs,obj=obj.previousSibling;s="select content from listItems where cmp_id='"+cmpid+"' and kind='"+kind+"'";popSelect(s,obj);}function editList(kind,title){var obj=new Object();obj.kind=kind;obj.title=title;showDialog('?path=html/listitems',obj);}function setOrgItem(obj,isCmpName){var s,html="",rs=new DataSet();var oOption=document.createElement("OPTION");obj.options.add(oOption);oOption.value='0';oOption.text=(isCmpName) ? parent.document.all.div_cmp_name.innerHTML : "";s="select a.serno,a.org_code,a.org_cname,"+isNull("o.org_code","'0'")+" as upcode from org a "+"left join org o on a.org_serno=o.serno "+"where a.cmp_id='"+cmpid+"' order by o.org_code,a.org_code";rs.Open(s);treeSelectFromDS(rs,"upcode","0","org_code","serno","org_cname",0,obj);}function setProdKindItem(obj,addNull){if(addNull){var oOption=document.createElement("OPTION");obj.options.add(oOption);oOption.value='';oOption.text='';}var s,rs=new DataSet();s="select pd_kind,pd_kind_name,pd_upkind from prod_kind where cmp_id='"+cmpid+"' order by pd_upkind,pd_kind";rs.Open(s);treeSelectFromDS(rs,"pd_upkind","0","pd_kind","pd_kind","pd_kind_name",0,obj);}function treeSelect(sql,key,keyvalue,value,text,level,obj){var s,rs=new DataSet();s=sql.replace(':no',keyvalue);rs.Open(s);while(!rs.EOF){var oOption=document.createElement("OPTION");obj.options.add(oOption);oOption.value=rs.Fields(value).value;oOption.text=stringOfChar('‧',level)+rs.Fields(text).value;treeSelect(sql,key,rs.Fields(key).value,value,text,level+1,obj);rs.MoveNext();}rs=null;}function treeSelectFromDS(rs,upkey,upvalue,key,value,text,level,obj){var s,i;if(!rs.Locate(upkey,upvalue,0)) return;while(!rs.EOF){if(rs.Fields(upkey).value!=upvalue) break;var oOption=document.createElement("OPTION");obj.options.add(oOption);oOption.value=rs.Fields(value).value;oOption.text=stringOfChar('‧',level)+rs.Fields(text).value;i=rs.RecNo;treeSelectFromDS(rs,upkey,rs.Fields(key).value,key,value,text,level+1,obj);rs.RecNo=i;rs.MoveNext();}}function setSelect(vObj,vSql,vValue,vText,addNull){var i,a,s,rs=new DataSet();if(addNull){var oOption=document.createElement("OPTION");vObj.options.add(oOption);oOption.value='';oOption.text='';}rs.Open(vSql);while(!rs.EOF){var oOption=document.createElement("OPTION");vObj.options.add(oOption);a=vValue.split(',');s='';for(i=0;iv2;if(b){v=v1;v1=v2;v2=v;n=0;}for(i=v1;i<=v2;i++){var oOption=document.createElement("OPTION");if(b){vObj.options.add(oOption,n);}else{vObj.options.add(oOption);}s=(l==0) ? i : fillLChar(i,l,"0");oOption.value=s;oOption.text=s;}vObj.selectedIndex=idx;}function getChild(no,vsql){var s,mRs,nos='';s=vsql.replace("@",no);mRs=new DataSet();mRs.Open(s);while(!mRs.EOF){nos+=","+mRs.Fields(0).value+getChild(mRs.Fields(0).value,vsql);mRs.MoveNext();}return(nos);}function getOrgChild(no){var s,nos;s="select serno from org where cmp_id='"+cmpid+"' and org_serno=@";nos=no+getChild(no,s);return(nos);}function getProdKindChild(no){var s,nos;s="select pd_kind from prod_kind where cmp_id='"+cmpid+"' and pd_upkind='@'";nos=no+getChild(no,s);return("'"+myReplace(nos,",","','")+"'");}function getpd_serno(){var r=new Array(0,0,0,0);rsTmp.Open("select serno,pd_kind from pd_item where cmp_id='"+cmpid+"' order by pd_no");if(rsTmp.Locate("pd_kind","簽証",0)) r[0]=rsTmp.Fields("serno").value;if(rsTmp.Locate("pd_kind","機票",0)) r[1]=rsTmp.Fields("serno").value;if(rsTmp.Locate("pd_kind","退票",0)) r[2]=rsTmp.Fields("serno").value;if(rsTmp.Locate("pd_kind","車資",0)) r[3]=rsTmp.Fields("serno").value;return(r);}function showError(text){var wm=window.open("_blank");wm.document.write(text);wm.document.close();}function showDialog(url,obj){var fm;myParent.dialogObj=obj;fm=myParent.document.all.fm_dialog;fm.style.width=0;fm.style.height=0;fm.style.top=0;fm.style.left=0;fm.src=url+((url.indexOf('?')<0)?'?':'&')+"sno="+Math.random();fm.style.display='';myParent.document.all.dlgFilter.style.display='';}function openDialog(w,h,url,obj,l,t){var x,y,s;if(l==null){x=(screen.width-w)/2;y=(screen.height-h)/2;}else{x=l;y=t;}s="help:0;resizable:1;scroll:0;status:0;"+"dialogHeight:"+h+"px;dialogWidth:"+w+"px;"+"dialogTop:"+y+"px;dialogLeft:"+x+"px;";window.showModalDialog(url+((url.indexOf('?')<0)?"?":"&")+"sno="+Math.random(),obj,s);}function popEmp(e,obj,tag){var obj=obj.previousSibling;var s="select serno,emp_cname from employee where "+isNull("emp_odate","''")+"='' "+andcmp(0)+" order by emp_no";popSelect(s,obj,tag,true);}function getEmpName(no){var s,rs=myParent.rsEmp;s=(rs.Locate('serno',no)) ? rs.Fields('emp_cname').value : '';return(s);}function setZip(obj,tag){var r,s,s1="",s2="",p1,p2,i;for(i=0;i<2;i++){p1=obj.value.indexOf("縣市".substr(i,1));if(p1>=0){p1++;s1=obj.value.substr(0,p1);break;}}if(p1<0) return("");for(i=0;i<4;i++){p2=obj.value.indexOf("市區鄉鎮".substr(i,1),p1);if(p2>=0){s2=obj.value.substring(p1,p2+1);break;}}if(p2<0) return("");s="select b.zipno from addr1 a "+"left join addr2 b on a.sno=b.sno "+"where a.name='"+s1+"' "+"and b.name='"+s2+"'";r=lookup2(s);if(r[0]) tag.value=r[1];}function addredit(caddr,eaddr,zip){var myObj=new Object();myObj.caddr=caddr;myObj.eaddr=eaddr;myObj.zip=zip;showDialog('?path=html/addredit',myObj);}function showMap(v){window.open("?path=html/viewmap&addr="+escape(v),null,"top=0,left=0,width=600,height=550,menubar=no,resizable=yes,scrollbars=no,toolbar=no,status=no,location=no");}function doHeaderScroll(src,tag){tag.scrollLeft=src.scrollLeft;}function setHeaderWidth(src,tag,isSecond,tag2,isDebug){var i,j=(isSecond) ? 1 : 0;var k,maxW,srcObj,tagObj;for(i=0;i0) obj.selectedIndex=obj.selectedIndex-1;}else if(i==39){if(obj.selectedIndex=0) && (j=0) && (obj.type!='hidden') && (!obj.disabled)){e.returnValue=false;obj.focus();if(obj.type=='text') obj.select();break;}if(i==38){j--;}else{j++;}};}function setPage(vTitle,vType){doc("page_title").innerHTML=vTitle;if(vType!=3){doc("page_edit").parentNode.style.display='none';doc("page_bws").parentNode.style.display='none';doc("page_edit").style.display='none';doc("page_bws").style.display='none';}}function makePage(){var i,j,s,a;s='';for(i=0;i'+''+''+''+' | ';}}s+='
';doc('dv_pages').innerHTML=s;doc('sp_page0').onclick();}function openPage(obj,url,isbws){try{if(typeof(beforePageChange)!="undefined") if(!beforePageChange())return;if(curpage!=null){curpage.className='submenu1';curpage.previousSibling.className='submenu1_l';curpage.nextSibling.className='submenu1_r';}obj.className='submenu2';obj.previousSibling.className='submenu2_l';obj.nextSibling.className='submenu2_r';curpage=obj;if(isbws=='0'){doc('pn_bws').style.visibility='hidden';}else{doc('pn_bws').style.visibility='visible';}if(curpage!=sp_page0){pObj=doc('page2');pObj.style.top=doc('dv_title').offsetTop+doc('dv_title').offsetHeight;pObj.style.display='';if(doc('page1')) doc('page1').style.display='none';var i,s="?path=html/"+url,s1=pObj.src;i=s1.indexOf('?');if(i>0) s1=s1.substr(i);if(s1!=s){pObj.src=s;}else{if(pObj.contentWindow.dataChange) pObj.contentWindow.dataChange();}}else{if(doc('page1')) doc('page1').style.display='';if(doc('page2')){doc('page2').style.display='none';doc('page2').style.top=screen.height;}}}catch(e){alert("錯誤: "+e.description);}}function pageInit(){document.body.oncontextmenu=myoncontextmenu;var i,a,obj;a=visobj.split(",");for(i=1;i<=a.length;i++){obj=document.getElementById(a[i-1]);if(obj) obj.style.visibility='visible';}obj=doc('page1');if(obj){obj.style.height=document.body.clientHeight-obj.offsetTop-((doc("nav_bar")) ? doc("nav_bar").offsetHeight : 0);obj.style.width=document.body.clientWidth-((IE)?0:6);obj.style.visibility="visible";}obj=doc('find');if(obj){obj.style.top=doc('page1').offsetTop;obj.style.height=doc('page1').style.height;obj.style.width=document.body.clientWidth;doc('find_header').style.width=obj.style.width;doc('find_body').style.width=obj.style.width;}obj=doc('page2');if(obj){if(doc('dv_title')){obj.style.top=doc('dv_title').offsetTop+doc('dv_title').offsetHeight;obj.style.height=document.body.clientHeight-doc('dv_title').offsetHeight;obj.style.width=document.body.clientWidth;}}}function reloadPage(){if(curpage==sp_page0){location.reload();}else{doc('page2').contentWindow.location.reload();}}function hideAllPage(){doc("page1").style.visibility='hidden';var obj=doc("find");if(obj!=null) obj.style.display='none';if(doc("nav_record")!=null) doc("nav_record").style.display='none';if(doc("nav_page")!=null) doc("nav_page").style.display='none';if(doc("edbtn")!=null) doc("edbtn").style.display='none';doc("page_edit").parentNode.background="./images/page_bk.jpg";doc("page_bws").parentNode.background="./images/page_bk.jpg";}function openEditPage(){try{fmObj.isBrowse=false;if(fmObj.mode==1) hideAllPage();doc("page_edit").parentNode.background="./images/page_fr.jpg";doc("page1").style.visibility='visible';if(doc('nav_record')) doc('nav_record').style.display='';if(doc('edbtn')) doc('edbtn').style.display='';if(doc('prt_bar')) doc('prt_bar').style.display='';}catch(e){alert("錯誤: "+e.description);}}function openBwsPage(v){fmObj.isBrowse=true;hideAllPage();if(fmObj.mode==1){doc("page_bws").parentNode.background="./images/page_fr.jpg";doc("find").style.display='inline';doc("nav_page").style.display='inline';if(doc("find")){if(window.setFind_Footer){doc('find_footer').style.display='';doc('find_footer').style.height=26;doc('find_body').style.height=doc('find').offsetHeight-doc('find_header').offsetHeight-doc('find_footer').offsetHeight-2;}else{doc('find_body').style.height=doc('find').offsetHeight-doc('find_header').offsetHeight-2;doc('find_footer').style.display='none';doc('find_footer').style.height=1;}}}else{doc('page1').style.display='';doc('srhmsg').style.visibility="visible";}if(doc('page2')) doc('page2').style.display='none';if(v){fmObj.List(1);}else if(fmObj.rsFind.SQLText==""){fmObj.srhwas='';fmObj.sort=fmObj.srhIndex;fmObj.List(1);}else{fmObj.List(5);}if((v!=null) && (window.setFind_Footer)) setFind_Footer();}function getNodeText(vnode,name){try{if(typeof(name)=="number"){var node=vnode.childNodes[name].firstChild;}else{var node,nodes=vnode.getElementsByTagName(name);if(nodes.length>0){node=nodes[0].firstChild;}}if(node) return(node.nodeValue);return("");}catch(e){alert("錯誤(getNodeText->"+name+"): "+e.description);return("");}}function setNodeText(vnode,name,text){var node;node=vnode.getElementsByTagName(name)[0];if(node.childNodes.length==0){if(IE){var newnode=node.ownerDocument.createTextNode(text);node.appendChild(newnode);}else{var newnode=document.createTextNode(text);node.appendChild(newnode);}}else{node.firstChild.nodeValue=text;}}function getBlob(vTb,vKey,vValue,vField,vBlob){var s;s="?path=data/blob&tb="+vTb+"&key="+encodeSQL(vKey)+"&value="+vValue+"&field="+vField+"&blob="+vBlob+"&sno="+Math.random();return(s);}function lookup(obj,vsql,vclr,debug){var s,fdname,rs,i,j,l,objs,obj1;try{rs=new DataSet();rs.Defs=true;rs.Open(vsql,debug);for(i=0;i=0){if(rs.RecordCount==1){if("checkbox,radio".indexOf(obj1.type)<0){obj1.value=rs.Fields(i).value;}else{obj1.checked=obj1.value==rs.Fields(i).value;}}else if(vclr){if("checkbox,radio".indexOf(obj1.type)<0) obj1.value="";}}else if(obj1.tagName=="OPTION"){objs.value=rs.Fields(i).value;break;}else{if(rs.RecordCount==1){obj1.innerHTML=rs.Fields(i).value;}else if(vclr){obj1.innerHTML="";}}}}return(rs.RecordCount==1);}catch(e){alert('field('+fdname+')'+e.description);return(false);}}function lookup1(vsql,debug){var i,s,rs,r;rs=new DataSet();rs.Defs=true;rs.Open(vsql,debug);if(rs.FieldsCount==1){if(rs.FieldType(0)=="B"){r=(rs.EOF) ? false : rs.Fields(0).value=="True";}else{r=(rs.EOF) ? "" : rs.Fields(0).value;}}else{r=new Array();for(i=0;i0) ? "and" : "where")+" "+vKey+"="+s1+vValue+s1;ds=new DataSet();ds.Open(s);if(vFields.indexOf(',')<0){return((ds.EOF) ? "" : ds.Fields(vFields).value);}else{var a,r,v;r=new Array();a=vFields.split(',');r[0]=ds.RecordCount>0;if(!r[0]) return(r);for(i=1;i<=a.length;i++){v=ds.Fields(a[i-1]).value;s=ds.Fields(a[i-1]).type;if(ds.EOF){r[i]=(s=='B') ? false : '';}else{r[i]=(s=='B') ? (v=='True') : v;}}return(r);}}function seek(vSQL,isMore){var rs;rs=new DataSet();rs.Open(vSQL);if(isMore){return(rs.RecordCount>0);}else{return(rs.RecordCount==1);}}function execSQL(vSQL,isDebeg,isShowError){var xmlDoc,s,postData=vSQL.length>1000;if(isShowError==null) isShowError=true;if(postData){s="?path=exec&sno="+Math.random();xmlDoc=loadXML(s,isDebeg,isShowError,"sql="+encodeSQL(vSQL));}else{s="?path=exec&sql="+encodeSQL(vSQL)+"&sno="+Math.random();xmlDoc=loadXML(s,isDebeg,isShowError);}if(!xmlDoc) return(false);s=getNodeText(xmlDoc,'State');if(s=="0") return(true);lastError=getNodeText(xmlDoc,'MSG');if(isShowError) alert(lastError+'\r\n'+getNodeText(xmlDoc,'SQL'));return(false);}function N(){var s=(dbtype=='1') ? 'N' : '';return(s);}function isNull(field,value){var s=(dbtype=='1') ? 'ISNULL('+field+','+value+')' : 'IIF(ISNULL('+field+'),'+value+','+field+')';return(s);}function sqlIIF(exp,v1,v2){var s=(dbtype=="1") ? s="CASE WHEN "+exp+" THEN "+v1+" ELSE "+v2+" END" : "IIF("+exp+","+v1+","+v2+")";return(s);}function valueSQL(obj,name){var r,field,dataType,value;try{if(obj=="Grid"){field=obj.Fields(name);dataType=obj.rs.FieldType(name);value=field.value;}else if(obj.tagName=="FORM"){field=obj.elements[name];value=field.value;if(field.type=="checkbox"){dataType="B";}else if(field.type=="radio"){dataType="C";value=(field.checked) ? field.value : "";}else if(field.className.indexOf("num")>=0){dataType="N";}}if(field.type=="checkbox"){r=(field.checked) ? "1" : "0";}else if(value==""){r="null";}else if(dataType=="N"){r=value;}else if(dataType=="B"){r=(value=="True") ? "1" : "0";}else{r=N()+"'"+value.replace(/\'/g,"''")+"'";}}catch(e){alert("錯誤("+name+"): "+e.description);}return(r);}function insSQL(tag,tbName,fields,values){var s,a,i;s="insert into "+tbName+" ("+fields+") values(";a=values.split(",");for(i=0;i'+''+obj.title+''+''+''+''+''+''+'製表日期: '+myDate()+' | '+' '+s1+' | '+''+stringOfChar(' ',19)+' | '+'
'+''+obj.title+' |
'+''+obj.description+' |
'+''+obj.body+' |
';if(obj.footer) s+=''+obj.footer+' |
';s+='
';if(isEdit){htmlEdit(s);}else{wm=window.open('about:blank','_blank','menubar=1,resizable=1,toolbar=1,scrollbars=1,status=yes');wm.document.write(s);wm.document.close();if(isPrint){wm.print();wm.close();};}}var dbtype=getCookie("dbtype");var currency=getCookie("currency");var iscurrency=getCookie("iscurrency")=="True";if(currency=="") currency="NTD";var xmlHTTP;if(window.XMLHttpRequest){xmlHTTP=new XMLHttpRequest();}else{xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP");}function loadXML(url,debug,showerror,postData){var xmlDoc;try{if(postData){xmlHTTP.open("POST",url,false);xmlHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlHTTP.setRequestHeader("Content-Length",postData.length);xmlHTTP.send(postData);}else{xmlHTTP.open("GET",url,false);xmlHTTP.send(null);}if(debug) window.open(url);if(xmlHTTP.responseXML){if(IE){xmlDoc=xmlHTTP.responseXML.documentElement;}else{xmlDoc=xmlHTTP.responseXML.firstChild;}return(xmlDoc);}else{if((showerror==null) || (showerror)){alert('error(loadXML)(1)\r\n'+xmlHTTP.responseText);alert(url);}return(null);}}catch(e){if((showerror==null) || (showerror)) alert('error(loadXML)(2)->'+e.description);if(debug) window.open(url);}}function popMenu(vItem,tagObj,vWidth){var i,s,a,a1,bgColor="#C5D5E7";s=''+'';a=vItem.split(';');for(i=0;i '+a1[0]+' ';}s+=' |
';doc('dv_menu').innerHTML=s;doc('dv_menu').style.width=(vWidth) ? vWidth : "";if(IE){oPop.document.body.innerHTML=s;oPop.show(0,tagObj.offsetTop+tagObj.offsetHeight,doc('dv_menu').offsetWidth,doc('dv_menu').offsetHeight,tagObj);}else{oPop=doc('popup');var coord=getCoord(tagObj);if((coord.y+tagObj.offsetHeight+doc('dv_menu').offsetHeight)>document.body.clientHeight){oPop.style.top=coord.y-doc('dv_menu').offsetHeight+2;}else{oPop.style.top=coord.y+tagObj.offsetHeight+2;}if((coord.x+doc('dv_menu').offsetWidth)>document.body.clientWidth){oPop.style.left=document.body.clientWidth-doc('dv_menu').offsetWidth;}else{oPop.style.left=coord.x;}oPop.style.width=doc('dv_menu').offsetWidth;oPop.style.height=doc('dv_menu').offsetHeight;oPop.contentWindow.document.write(''+s+'');oPop.contentWindow.document.close();oPop.style.display='';doc('dv_menu').innerHTML='';}}function hidePopup(e){if(IE){oPop.hide();}else{oPop.style.display="none";}}function popSelect(vItem,tagObj,valueObj,vNull,vH,vW,isMore,moreFun){var i,s,a,a1,x,y,w,h,dw,rs;if(vItem.substr(0,7).toLowerCase()=='select '){if(isMore) vItem="select top 7"+vItem.substr(6);rs=new DataSet();rs.Open(vItem);s='';if(vNull){s+='\n';if(rs.FieldsCount>1) s+='\t ';}while(!rs.EOF){s+='\n'+rs.Fields(0).value;if(rs.FieldsCount>1) s+='\t'+rs.Fields(1).value;rs.MoveNext();}vItem=s.substr(1);}popObj.textObj=tagObj;popObj.valueObj=valueObj;s='';}if(isMore){if(rs.RecordCount>=7){s+='更多.....
';}}s+='';doc('dv_menu').innerHTML=s;dw=doc('dv_menu').offsetWidth;h=(vH) ? vH : ((doc('dv_menu').offsetHeight>165) ? 165 : doc('dv_menu').offsetHeight);if(IE){if(vW){w=vW;}else{w=tagObj.offsetWidth+event.srcElement.offsetWidth;if(wdocument.body.clientHeight){y=coord.y-h-2;if(y<0) y=0;}oPop.style.top=y;oPop.contentWindow.document.write(''+s+'');oPop.contentWindow.document.close();oPop.contentWindow.document.body.firstChild.width="100%";oPop.style.height=oPop.contentWindow.document.body.clientHeight;doc('dv_menu').innerHTML='';}}function setPopValue(v1,v2){if(popObj.textObj){popObj.textObj.value=v2;if(popObj.textObj.onchange) popObj.textObj.onchange();}if(popObj.valueObj){popObj.valueObj.value=v1;if(popObj.valueObj.onchange) popObj.valueObj.onchange();}}function openCalendar(tag,event,iday){var obj=new Object();obj.dateObj=tag;obj.dateType=DATE_TYPE;obj.date=myParent.curdate;var x,y,w,h,s;w=201;h=215;x=event.screenX;y=event.screenY;s="help:0;resizable:0;scroll:0;status:0;"+"dialogHeight:"+h+"px;dialogWidth:"+w+"px;"+"dialogTop:"+y+"px;dialogLeft:"+x+"px;";dialogObj=obj;window.showModalDialog("?path=html/calendar&sno="+Math.random(),window,s);}var isday=0;var calendarObj;var calendarDate=new Date();var calendarMDate=new Date();calendarDate.setFullYear(curdate.getFullYear(),curdate.getMonth(),1);calendarMDate.setFullYear(curdate.getFullYear(),curdate.getMonth(),1);function showCalendar(obj,event,iday){if(obj.readOnly)return;var s,d,mYear,w,h,t,l;isday=iday;calendarObj=obj;s=obj.value;if(s==''){d=new Date();d.setDate(1);d.setFullYear(curdate.getFullYear(),curdate.getMonth(),curdate.getDate());}else{d=new Date();if(DATE_TYPE=="1"){mYear=s.substr(0,3);d.setFullYear(parseFloat(mYear)+1911,s.substr(4,2)-1,s.substr(7,2));}else{d.setFullYear(s.substr(0,4),s.substr(5,2)-1,s.substr(8,2));}if(isNaN(d)){d.setDate(1);d.setFullYear(curdate.getFullYear(),curdate.getMonth(),curdate.getDate());}}calendarDate=d;calendarMDate.setFullYear(calendarDate.getFullYear(),calendarDate.getMonth(),1);makeCalendar();makeDays();w=201;h=(IE) ? 212 : 210;if(IE){oPop.show(0,event.srcElement.offsetHeight+3,w,h,obj);}else{oPop=doc('popup');oPop.style.height=h;oPop.style.width=w;var coord=getCoord(obj);coord.y+=obj.offsetHeight;if((coord.x+w)>document.body.clientWidth) coord.x=document.body.clientWidth-w-4;if((coord.y+h)>document.body.clientHeight) coord.y=document.body.clientHeight-h-4;oPop.style.top=coord.y;oPop.style.left=coord.x;oPop.style.display='';}}function makeCalendar(){var a=new Array('年','月','日','一','二','三','四','五','六');var i,j,k,s,d2,y,m,s;y=calendarMDate.getFullYear();if(DATE_TYPE=="1")y=y-1911;m=calendarMDate.getMonth()+1;if(m<10) m="0"+m;s=''+''+''+' | '+'  | '+''+y+'.'+m+' | '+'  | '+' | '+'
';for(i=2;i<9;i++) s+=''+a[i]+' | ';s+='
';for(i=1;i<=6;i++){s+='';for(j=1;j<=7;j++){s+=' | ';}s+='
';}s+='';s+='(關閉)';s+=' |
';if(IE){oPop.document.body.innerHTML=s;}else{oPop=doc('popup');oPop.contentWindow.document.write(''+s+'');oPop.contentWindow.document.close();}}function makeDays(){var pDoc=(IE) ? oPop.document : doc("popup").contentWindow.document;var x,y,k,j,d2,tr,td,yy,mm;var tb=pDoc.getElementById("tb1");yy=calendarMDate.getFullYear();if(DATE_TYPE=="1") yy=yy-1911;mm=calendarMDate.getMonth()+1;if(mm<10) mm="0"+mm;pDoc.getElementById("td_ym").innerHTML=""+yy+"."+mm+"";d2=new Date();d2.setDate(1);d2.setMonth(calendarMDate.getMonth());d2.setFullYear(calendarMDate.getFullYear());k=d2.getMonth();j=d2.getDay();if(j>0){d2.setDate(1-j);}else{d2.setDate(1-7);}for(y=2;y<=7;y++){for(x=0;x<7;x++){td=tb.rows[y].cells[x];if(k!=d2.getMonth()){td.setAttribute("incm",((y==2) ? "-1" : "1"));td.style.backgroundColor="#EDF7FE";td.style.border="1px solid #F5F5F5";td.style.color="#808080";}else{td.setAttribute("incm","0");td.style.color="#000000";td.style.borderLeft="1px solid #FFFFFF";td.style.borderTop="1px solid #FFFFFF";td.style.borderRight="1px solid #909090";td.style.borderBottom="1px solid #909090";if(d2.getDay()==0) td.style.color="#FF0000";if(d2.getDate()==calendarDate.getDate()) td.style.border="1px solid #0000FF";td.style.backgroundColor="#DFEFFF";}td.innerHTML=d2.getDate();d2.setDate(d2.getDate()+1);}}}function nextmonth(){calendarMDate.setMonth(calendarMDate.getMonth()+1);makeDays();}function nextyear(){calendarMDate.setFullYear(calendarMDate.getFullYear()+1);makeDays();}function prevmonth(){calendarMDate.setMonth(calendarMDate.getMonth()-1);makeDays();}function prevyear(){calendarMDate.setFullYear(calendarMDate.getFullYear()-1);makeDays();}function setCalendarDate(obj) {var x=new Array("日","一","二","三","四","五","六");var i,s,v;v=parseFloat(obj.getAttribute("incm"));if(v!=0) calendarMDate.setMonth(calendarMDate.getMonth()+v);s=calendarMDate.getFullYear();if(DATE_TYPE=="1"){s=s-1911;if(s<100) s='0'+s;}s+=DATE_SEPARATOR;i=calendarMDate.getMonth()+1;if(i<10) s+='0';s+=i+DATE_SEPARATOR;if(obj.innerHTML.length==1) s+='0';s+=obj.innerHTML;if(isday==1) s+=x[obj.cellIndex];calendarObj.value=s;if(calendarObj.onchange!=null) calendarObj.onchange();hidePopup();}var XmlRS=function(){this.Root=null;this.postData=null;};XmlRS.prototype.Open=function(v,isDebug,isShowError){v+="&sssss="+Math.random();this.Root=loadXML(v,isDebug,isShowError,this.postData);};XmlRS.prototype.Fields=function(vName){return(getNodeText(this.Root,vName));};var DataSet=function(){this.BOF=true;this.EOF=true;this.RecNo=0;this.RecordCount=0;this.Defs=false;this.Page=false;this.PageNo=0;this.PageCount=0;this.PageSize=getCookie("pagesize");this.TableName='';this.IndexFields='';this.HtmlFields='';this.OldKeyValue='';this.Atn=0;this.GoToNo='';this.SummaryNode=null;this.FieldDefsNode=null;this.FieldsNode=null;this.FieldsCount=0;this.Root=null;this.Items=null;this.ReadStateChange=null;this.SQLText='';this.DelSQL='';this.tableHTML='';this.rowHTML='';this.lastError='';};DataSet.prototype.toString=function(){return('DataSet');};DataSet.prototype.Open=function(v,isDebug,isShowError){var s,s1,postData=v.length>1000;s="?path=data";if(this.Atn!=0) s+="/get&atn="+((this.Atn==6)?"":this.Atn)+"&tb="+this.TableName+"&indexfield="+this.IndexFields+"&no="+((this.Atn==6) ? encodeSQL(this.GoToNo) : encodeSQL(this.KeyValue()));if(this.Defs) s+="&defs=1";if(this.Page) s+="&page="+this.PageNo+"&pagesize="+this.PageSize;if(!postData){if(this.Atn==5) postData=(v.length+this.DelSQL.length)>1000;}if(!postData){s+="&sql="+encodeSQL(v);if(this.Atn==5) s+="&delsql="+encodeSQL(this.DelSQL);}s+="&sno="+Math.random();this.SQLText=v;if(postData){postData="sql="+encodeSQL(v);if(this.Atn==5) postData+="&delsql="+encodeSQL(this.DelSQL);}this.Root=loadXML(s,isDebug,isShowError,postData);if(!this.Root){this.lastError='loadXML Error!';return(false);}return this.XmlToData(this.Root,isShowError);};DataSet.prototype.OpenSys=function(v,isDebug,isShowError){var s;s="?path=sys&defs=1&sql="+encodeSQL(v)+"&sno="+Math.random();this.SQLText=v;this.Root=loadXML(s,isDebug,isShowError);if(!this.Root) return(false);this.XmlToData(this.Root);return(true);};DataSet.prototype.LoadXML=function(v){var xmlDoc;if(v=="") return;if(window.DOMParser){var parser=new DOMParser();xmlDoc=parser.parseFromString(v,"text/xml");}else{xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async=false;xmlDoc.loadXML(v);}this.XmlToData(xmlDoc.firstChild);};DataSet.prototype.XmlToData=function(v,isShowError){var i,node;this.RecNo=0;for(i=0;i"+getNodeText(node,"MSG")+'\r\n'+getNodeText(node,"SQL"));this.lastError=getNodeText(node,"MSG")+'\r\n'+getNodeText(node,"SQL");return(false);}else if(node.tagName=="Summary"){this.SummaryNode=node;if(this.Page){this.PageCount=parseFloat(this.Summary("PageCount"));this.PageNo=parseFloat(this.Summary("PageNo"));}}else if(node.tagName=="FieldDefs"){this.FieldDefsNode=node;this.FieldsCount=node.childNodes.length;}else if(node.tagName=="Fields"){this.FieldsNode=node;this.Items=node.getElementsByTagName('Item');this.RecordCount=this.Items.length;if(this.RecordCount>0) this.FieldsCount=this.Items[0].childNodes.length;this.BOF=(this.RecordCount==0);this.EOF=(this.RecordCount==0);this.RecNo=(this.BOF)?0:1;}}this.OldKeyValue=this.KeyValue();return(true);};DataSet.prototype.Refresh=function(){if(!this.Page){this.Atn=6;this.GoToNo=this.OldKeyValue;}this.Open(this.SQLText,false);};DataSet.prototype.Summary=function(vName){return(getNodeText(this.SummaryNode,vName));};DataSet.prototype.FieldDefs=function(vName){var s=(this.FieldDefsNode) ? getNodeText(this.FieldDefsNode,vName) : "";return(s);};DataSet.prototype.FieldType=function(vName){var s=this.FieldDefs(vName);if(s=="") return("");if(s.indexOf('Char')>=0){s='C';}else if(s=='Numeric'){s='N';}else if(s=='Boolean'){s='B';}else if((s=='Date') || (s='DateTime')){s='D';}else if(s=='Time'){s='T';}else if(s=='Text'){s='M';}else if(s=='Binary'){s='G';}else{s='Unknown';}return(s);};DataSet.prototype.Fields=function(vName){if(vName==null) return(null);if((vName+"")=="") return(null);var obj,node,s;var field=new Field();field.dataSet=this;try{if(typeof(vName)=="number"){node=this.Items[this.RecNo-1].childNodes[vName];field.name=node.tagName;}else{obj=this.Items[this.RecNo-1].getElementsByTagName(vName);if(obj.length==0){return(null);}node=obj[0];field.name=vName;}field.value=(node.childNodes.length==0) ? "" : node.firstChild.nodeValue;return(field);}catch(e){alert("Error(Fields:"+vName+")-> "+e.description);return(null);}};DataSet.prototype.SetValue=function(vName,vValue){setNodeText(this.Items[this.RecNo-1],vName,vValue);};DataSet.prototype.KeyValue=function(){if(this.BOF) return("");if(this.IndexFields=="") return("");var i,j,a,s='',s1;a=this.IndexFields.split(",");for(i=0;i=0) s1=s1.substr(j+1);s+=this.Fields(s1).value;}return(s);};DataSet.prototype.MoveFirst=function(){this.RecNo=(this.RecordCount==0) ? 0 : 1;this.BOF=(this.RecordCount==0);this.EOF=(this.RecordCount==0);};DataSet.prototype.MoveNext=function(){this.RecNo++;if(this.RecNo>this.RecordCount){this.RecNo=this.RecordCount;this.EOF=true;}else{this.EOF=false;}this.BOF=(this.RecordCount==0);};DataSet.prototype.MovePrevious=function(){this.RecNo--;if(this.RecNo<=0){this.RecNo=(this.RecordCount==0) ? 0 : 1;this.BOF=true;}else{this.BOF=false;}this.EOF=(this.RecordCount==0);};DataSet.prototype.MoveLast=function(){this.RecNo=this.RecordCount;this.BOF=(this.RecordCount==0);this.EOF=(this.RecordCount==0);};DataSet.prototype.Insert=function(nIndex){var xmlDoc=this.Root.ownerDocument;var newNode,refNode,i;newNode=xmlDoc.createElement("Item");refNode=(nIndex<0) ? null : this.FieldsNode.childNodes[nIndex];this.FieldsNode.insertBefore(newNode,refNode);for(i=0;ithis.RecordCount){this.RecNo=this.RecordCount;this.EOF=true;}};DataSet.prototype.BindToTable=function(vTable,isRowColor,Color1,Color2){var x,y,i,row,cell,objs,s,node,bgColor="";if(this.tableHTML==""){this.tableHTML=myReplace(vTable.parentNode.innerHTML,'tbody','TBODY');this.rowHTML=vTable.tHead.innerHTML;}if(IE){vTable.tBodies[0].innerText="";}else{vTable.tBodies[0].innerHTML="";}if(this.RecordCount==0) return;s=this.tableHTML.replace('',''+stringOfChar(this.rowHTML,this.RecordCount));node=vTable.parentNode;node.innerHTML=s;vTable=node.getElementsByTagName('TABLE')[0];this.MoveFirst();while(!this.EOF){if(isRowColor) bgColor=(this.RecNo%2==0) ? Color2 : Color1;for(y=0;y=0;}else{objs[i].value=this.Fields(objs[i].name).value;}}else{alert("INPUT Name:"+objs[i].name+" not found!");}}objs=row.getElementsByTagName('DIV');for(i=0;i=0){objs[j].innerHTML=obj.value;}else if("INPUT,SELECT".indexOf(a[i])>=0){if("hidden,text,password,textarea,select-one".indexOf(obj.type)){objs[j].value=obj.value;}else if(obj.type=="checkbox"){objs[j].checked=objs[j].value==obj.value;}}}}};DataSet.prototype.Locate=function(vField,vValue,vOption){var node,i,j,s1,s2,aField,aValue,isF=false;if(this.RecordCount==0) return(false);this.BOF=(this.RecordCount==0);this.EOF=(this.RecordCount==0);for(i=0;i1){isF=s1.indexOf(s2)==0;}else{isF=s1==s2;}if(!isF) break;}if(isF){this.RecNo=i+1;return(true);}}return(false);};var Field=function(){this.name='';this.value='';this.dataSet=null;};Field.prototype.toString=function(){return(this.value);};Field.prototype.dataType=function(){return(this.dataSet.FieldType(this.name));};var FormObj=function(vtb,vIndex,vAt,vForm,vNav){this.tb=vtb;this.index=vIndex;this.atn=vAt;this.mode=1;this.sql='';this.srhtb='';this.srhIndex=vIndex;this.selectedIndex=0;this.fields=null;this.htmlfield='';this.nocopyfield='';this.wora='and';this.srhsql='';this.srhwas='';this.sort='';this.prtStr='';this.findSql='';this.numFields='';this.defaultIndex='';this.disabledObj='';this.enabledObj='';this.deletenos='';this.pageCount=0;this.pageNo=0;this.debug=0;this.form=vForm;this.nav=vNav;this.oldData=new Array();this.rs=new DataSet();this.rs.Atn=vAt;this.rs.IndexFields=vIndex;this.rs.TableName=this.tb;this.state=0;this.isEOF=false;this.rsFind=new DataSet();this.rsFind.Page=true;this.rsFind.Defs=true;this.filterValue=new Array();this.isBrowse=false;this.onAfterOpen=null;document.onkeydown=this.DocKeyDown;this.form.onkeydown=this.KeyDown;setFormTabIndex(this.form);secode=getSecode(queryString("fmno"));};FormObj.prototype.Init=function(v){var i,j,s,s1,a;this.debug=v;if(this.htmlfield!=null) this.htmlfield=this.htmlfield.value;if(doc('srhfield')) for(i=doc('srhfield').options.length;i>0;i--) doc('srhfield').remove(i-1);if(this.fields!=null){s='';this.numFields=',';for(i=0;i