(function($){$.jgrid=$.jgrid||{};$.extend($.jgrid,{htmlDecode:function(value){if(value==" "||value==" "||(value.length==1&&value.charCodeAt(0)==160)){return""}return !value?value:String(value).replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/"/g,'"')},htmlEncode:function(value){return !value?value:String(value).replace(/&/g,"&").replace(/>/g,">").replace(/7){return rInd}for(i=0;irInd){return i}}return i},stripHtml:function(v){var regexp=/<("[^"]*"|'[^']*'|[^'">])*>/gi;if(v){return v.replace(regexp,"")}else{return v}},stringToDoc:function(xmlString){var xmlDoc;if(typeof xmlString!=="string"){return xmlString}try{var parser=new DOMParser();xmlDoc=parser.parseFromString(xmlString,"text/xml")}catch(e){xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async=false;xmlDoc.loadXML(xmlString)}return(xmlDoc&&xmlDoc.documentElement&&xmlDoc.documentElement.tagName!="parsererror")?xmlDoc:null},parse:function(jsonString){var js=jsonString;if(js.substr(0,9)=="while(1);"){js=js.substr(9)}if(js.substr(0,2)=="/*"){js=js.substr(2,js.length-4)}if(!js){js="{}"}with(window){return eval("("+js+")")}},empty:function(){while(this.firstChild){this.removeChild(this.firstChild)}}});$.fn.jqGrid=function(p){p=$.extend(true,{url:"",height:150,page:1,rowNum:20,records:0,pager:"",pgbuttons:true,pginput:true,colModel:[],rowList:[],colNames:[],sortorder:"asc",sortname:"",datatype:"xml",mtype:"GET",altRows:false,selarrrow:[],savedRow:[],shrinkToFit:true,xmlReader:{},jsonReader:{},subGrid:false,subGridModel:[],reccount:0,lastpage:0,lastsort:0,selrow:null,beforeSelectRow:null,onSelectRow:null,onSortCol:null,ondblClickRow:null,onRightClickRow:null,onPaging:null,onSelectAll:null,loadComplete:null,gridComplete:null,loadError:null,loadBeforeSend:null,afterInsertRow:null,beforeRequest:null,onHeaderClick:null,viewrecords:false,loadonce:false,multiselect:false,multikey:false,editurl:null,search:false,caption:"",hidegrid:true,hiddengrid:false,postData:{},userData:{},treeGrid:false,treeGridModel:"nested",treeReader:{},treeANode:-1,ExpandColumn:null,tree_root_level:0,prmNames:{page:"page",rows:"rows",sort:"sidx",order:"sord",search:"_search",nd:"nd"},forceFit:false,gridstate:"visible",cellEdit:false,cellsubmit:"remote",nv:0,loadui:"enable",toolbar:[false,""],scroll:false,multiboxonly:false,deselectAfterSort:true,scrollrows:false,autowidth:false,scrollOffset:18,cellLayout:5,subGridWidth:20,multiselectWidth:20,gridview:false,rownumWidth:25,rownumbers:false,pagerpos:"center",recordpos:"right",footerrow:false,userDataOnFooter:false,hoverrows:true,altclass:"ui-priority-secondary",viewsortcols:[false,"vertical",true],resizeclass:"",autoencode:false},$.jgrid.defaults,p||{});var grid={headers:[],cols:[],footers:[],dragStart:function(i,x,y){this.resizing={idx:i,startX:x.clientX,sOL:y[0]};this.hDiv.style.cursor="col-resize";this.curGbox=$("#rs_m"+p.id,"#gbox_"+p.id);this.curGbox.css({display:"block",left:y[0],top:y[1],height:y[2]});document.onselectstart=new Function("return false")},dragMove:function(x){if(this.resizing){var diff=x.clientX-this.resizing.startX,h=this.headers[this.resizing.idx],newWidth=h.width+diff,hn,nWn;if(newWidth>33){this.curGbox.css({left:this.resizing.sOL+diff});if(p.forceFit===true){hn=this.headers[this.resizing.idx+p.nv];nWn=hn.width-diff;if(nWn>33){h.newWidth=newWidth;hn.newWidth=nWn;this.newWidth=p.tblwidth}}else{this.newWidth=p.tblwidth+diff;h.newWidth=newWidth}}}},dragEnd:function(){this.hDiv.style.cursor="default";if(this.resizing){var idx=this.resizing.idx,nw=this.headers[idx].newWidth||this.headers[idx].width;this.resizing=false;$("#rs_m"+p.id).css("display","none");p.colModel[idx].width=nw;this.headers[idx].width=nw;this.headers[idx].el.style.width=nw+"px";if(this.cols.length>0){this.cols[idx].style.width=nw+"px"}if(this.footers.length>0){this.footers[idx].style.width=nw+"px"}if(p.forceFit===true){nw=this.headers[idx+p.nv].newWidth||this.headers[idx+p.nv].width;this.headers[idx+p.nv].width=nw;this.headers[idx+p.nv].el.style.width=nw+"px";if(this.cols.length>0){this.cols[idx+p.nv].style.width=nw+"px"}if(this.footers.length>0){this.footers[idx+p.nv].style.width=nw+"px"}p.colModel[idx+p.nv].width=nw}else{p.tblwidth=this.newWidth;$("table:first",this.bDiv).css("width",p.tblwidth+"px");$("table:first",this.hDiv).css("width",p.tblwidth+"px");this.hDiv.scrollLeft=this.bDiv.scrollLeft;if(p.footerrow){$("table:first",this.sDiv).css("width",p.tblwidth+"px");this.sDiv.scrollLeft=this.bDiv.scrollLeft}}}this.curGbox=null;document.onselectstart=new Function("return true")},scrollGrid:function(){if(p.scroll===true){var scrollTop=this.bDiv.scrollTop;if(scrollTop!=this.scrollTop){this.scrollTop=scrollTop;if((this.bDiv.scrollHeight-scrollTop-$(this.bDiv).height())<=0){if(parseInt(p.page,10)+1<=parseInt(p.lastpage,10)){p.page=parseInt(p.page,10)+1;this.populate()}}}}this.hDiv.scrollLeft=this.bDiv.scrollLeft;if(p.footerrow){this.sDiv.scrollLeft=this.bDiv.scrollLeft}}};return this.each(function(){if(this.grid){return}this.p=p;var i;if(this.p.colNames.length===0){for(i=0;i"),ii,isMSIE=$.browser.msie?true:false,isSafari=$.browser.safari?true:false;$(gv).insertBefore(this);$(this).appendTo(gv).removeClass("scroll");var eg=$("
");$(eg).insertBefore(gv).attr("id","gbox_"+this.id);$(gv).appendTo(eg).attr("id","gview_"+this.id);if(isMSIE&&$.browser.version<=6){ii=''}else{ii=""}$("
").append(ii).insertBefore(gv);$("
"+this.p.loadtext+"
").insertBefore(gv);$(this).attr({cellSpacing:"0",cellPadding:"0",border:"0",role:"grid","aria-multiselectable":this.p.multiselect,"aria-labelledby":"gbox_"+this.id});var ts=this,bSR=$.isFunction(this.p.beforeSelectRow)?this.p.beforeSelectRow:false,ondblClickRow=$.isFunction(this.p.ondblClickRow)?this.p.ondblClickRow:false,onSortCol=$.isFunction(this.p.onSortCol)?this.p.onSortCol:false,loadComplete=$.isFunction(this.p.loadComplete)?this.p.loadComplete:false,loadError=$.isFunction(this.p.loadError)?this.p.loadError:false,loadBeforeSend=$.isFunction(this.p.loadBeforeSend)?this.p.loadBeforeSend:false,onRightClickRow=$.isFunction(this.p.onRightClickRow)?this.p.onRightClickRow:false,afterInsRow=$.isFunction(this.p.afterInsertRow)?this.p.afterInsertRow:false,onHdCl=$.isFunction(this.p.onHeaderClick)?this.p.onHeaderClick:false,beReq=$.isFunction(this.p.beforeRequest)?this.p.beforeRequest:false,onSC=$.isFunction(this.p.onCellSelect)?this.p.onCellSelect:false,sortkeys=["shiftKey","altKey","ctrlKey"],IntNum=function(val,defval){val=parseInt(val,10);if(isNaN(val)){return defval?defval:0}else{return val}},formatCol=function(pos,rowInd){var ral=ts.p.colModel[pos].align,result='style="';if(ral){result+="text-align:"+ral+";"}if(ts.p.colModel[pos].hidden===true){result+="display:none;"}if(rowInd===0){result+="width: "+grid.headers[pos].width+"px;"}return result+'"'},addCell=function(rowId,cell,pos,irow,srvr){var v,prp;v=formatter(rowId,cell,pos,srvr,"add");prp=formatCol(pos,irow);return''+v+""},formatter=function(rowId,cellval,colpos,rwdat,_act){var cm=ts.p.colModel[colpos],v;if(typeof cm.formatter!=="undefined"){var opts={rowId:rowId,colModel:cm};if($.isFunction(cm.formatter)){v=cm.formatter(cellval,opts,rwdat,_act)}else{if($.fmatter){v=$.fn.fmatter(cm.formatter,cellval,opts,rwdat,_act)}else{v=cellVal(cellval)}}}else{v=cellVal(cellval)}return v},cellVal=function(val){return val===undefined||val===null||val===""?" ":ts.p.autoencode?$.jgrid.htmlEncode(val+""):val+""},addMulti=function(rowid,pos,irow){var v='',prp=formatCol(pos,irow);return""+v+""},addRowNum=function(pos,irow,pG,rN){var v=(parseInt(pG)-1)*parseInt(rN)+1+irow,prp=formatCol(pos,irow);return'"+v+""},reader=function(datatype){var field,f=[],j=0,i;for(i=0;i0?rcnt:0}}else{return}var i,fpos,ir=0,v,row,gi=0,si=0,ni=0,idn,getId,f=[],rd={},rl=ts.rows.length,xmlr,rid,rowData=[],ari=0,cn=(ts.p.altRows===true)?ts.p.altclass:"",cn1;if(!ts.p.xmlReader.repeatitems){f=reader("xml")}if(ts.p.keyIndex===false){idn=ts.p.xmlReader.id;if(idn.indexOf("[")===-1){getId=function(trow,k){return $(idn,trow).text()||k}}else{getId=function(trow,k){return trow.getAttribute(idn.replace(/[\[\]]/g,""))||k}}}else{getId=function(trow){return(f.length-1>=ts.p.keyIndex)?$(f[ts.p.keyIndex],trow).text():$(ts.p.xmlReader.cell+":eq("+ts.p.keyIndex+")",trow).text()}}$(ts.p.xmlReader.page,xml).each(function(){ts.p.page=this.textContent||this.text||1});$(ts.p.xmlReader.total,xml).each(function(){ts.p.lastpage=this.textContent||this.text||1});$(ts.p.xmlReader.records,xml).each(function(){ts.p.records=this.textContent||this.text||0});$(ts.p.xmlReader.userdata,xml).each(function(){ts.p.userData[this.getAttribute("name")]=this.textContent||this.text});var gxml=$(ts.p.xmlReader.root+" "+ts.p.xmlReader.row,xml),gl=gxml.length,j=0;if(gxml&&gl){var rn=ts.p.rowNum;while(j';if(ts.p.rownumbers===true){rowData[ari++]=addRowNum(0,j,ts.p.page,ts.p.rowNum);ni=1}if(ts.p.multiselect===true){rowData[ari++]=addMulti(rid,ni,j);gi=1}if(ts.p.subGrid===true){rowData[ari++]=$(ts).addSubGridCell(gi+ni,j+rcnt);si=1}if(ts.p.xmlReader.repeatitems===true){$(ts.p.xmlReader.cell,xmlr).each(function(k){v=this.textContent||this.text;rd[ts.p.colModel[k+gi+si+ni].name]=v;rowData[ari++]=addCell(rid,v,k+gi+si+ni,j+rcnt,xmlr)})}else{for(i=0;i";if(ts.p.gridview===false){if(ts.p.treeGrid===true){fpos=ts.p.treeANode>=-1?ts.p.treeANode:0;row=$(rowData.join(""))[0];try{$(ts).setTreeNode(rd,row)}catch(e){}rl===0?$("tbody:first",t).append(row):$(ts.rows[j+fpos+rcnt]).after(row)}else{$("tbody:first",t).append(rowData.join(""))}if(ts.p.subGrid===true){try{$(ts).addSubGrid(ts.rows[ts.rows.length-1],gi+ni)}catch(e){}}if(afterInsRow){ts.p.afterInsertRow(rid,rd,xmlr)}rowData=[];ari=0}rd={};ir++;j++;if(rn!=-1&&ir>rn){break}}}if(ts.p.gridview===true){$("table:first",t).append(rowData.join(""))}ts.p.totaltime=new Date()-startReq;if(ir>0){ts.grid.cols=ts.rows[0].cells;if(ts.p.records===0){ts.p.records=gl}}rowData=null;if(!ts.p.treeGrid&&!ts.p.scroll){ts.grid.bDiv.scrollTop=0;ts.p.reccount=ir}ts.p.treeANode=-1;if(ts.p.userDataOnFooter){$(ts).footerData("set",ts.p.userData,true)}updatepager(false)},addJSONData=function(data,t,rcnt){var startReq=new Date();ts.p.reccount=0;if(data){if(ts.p.treeANode===-1&&ts.p.scroll===false){var tBody=$("tbody:first",t);if(!ts.p.gridview){$("*",tBody).children().unbind()}if(isMSIE){$.jgrid.empty.apply(tBody[0])}else{tBody[0].innerHTML=""}tBody=null;rcnt=0}else{rcnt=rcnt>0?rcnt:0}}else{return}var ir=0,v,i,j,row,f=[],cur,gi=0,si=0,ni=0,len,drows,idn,rd={},fpos,rl=ts.rows.length,idr,rowData=[],ari=0,cn=(ts.p.altRows===true)?ts.p.altclass:"",cn1;ts.p.page=data[ts.p.jsonReader.page]||1;ts.p.lastpage=data[ts.p.jsonReader.total]||1;ts.p.records=data[ts.p.jsonReader.records]||0;ts.p.userData=data[ts.p.jsonReader.userdata]||{};if(!ts.p.jsonReader.repeatitems){f=reader("json")}if(ts.p.keyIndex===false){idn=ts.p.jsonReader.id;if(f.length>0&&!isNaN(idn)){idn=f[idn]}}else{idn=f.length>0?f[ts.p.keyIndex]:ts.p.keyIndex}drows=data[ts.p.jsonReader.root];if(drows){len=drows.length,i=0;var rn=ts.p.rowNum;while(i';if(ts.p.rownumbers===true){rowData[ari++]=addRowNum(0,i,ts.p.page,ts.p.rowNum);ni=1}if(ts.p.multiselect){rowData[ari++]=addMulti(idr,ni,i);gi=1}if(ts.p.subGrid){rowData[ari++]=$(ts).addSubGridCell(gi+ni,i+rcnt);si=1}if(ts.p.jsonReader.repeatitems===true){if(ts.p.jsonReader.cell){cur=cur[ts.p.jsonReader.cell]}for(j=0;j";if(ts.p.gridview===false){if(ts.p.treeGrid===true){fpos=ts.p.treeANode>=-1?ts.p.treeANode:0;row=$(rowData.join(""))[0];try{$(ts).setTreeNode(rd,row)}catch(e){}rl===0?$("tbody:first",t).append(row):$(ts.rows[i+fpos+rcnt]).after(row)}else{$("tbody:first",t).append(rowData.join(""))}if(ts.p.subGrid===true){try{$(ts).addSubGrid(ts.rows[ts.rows.length-1],gi+ni)}catch(e){}}if(afterInsRow){ts.p.afterInsertRow(idr,rd,cur)}rowData=[];ari=0}rd={};ir++;i++;if(rn!=-1&&ir>rn){break}}if(ts.p.gridview===true){$("table:first",t).append(rowData.join(""))}ts.p.totaltime=new Date()-startReq;if(ir>0){ts.grid.cols=ts.rows[0].cells;if(ts.p.records===0){ts.p.records=len}}}if(!ts.p.treeGrid&&!ts.p.scroll){ts.grid.bDiv.scrollTop=0;ts.p.reccount=ir}ts.p.treeANode=-1;if(ts.p.userDataOnFooter){$(ts).footerData("set",ts.p.userData,true)}updatepager(false)},updatepager=function(rn){var cp,last,base,bs,from,to,tot,fmt;base=(parseInt(ts.p.page)-1)*parseInt(ts.p.rowNum);if(ts.p.pager){if(ts.p.loadonce){cp=last=1;ts.p.lastpage=ts.page=1;$(".selbox",ts.p.pager).attr("disabled",true)}else{cp=IntNum(ts.p.page);last=IntNum(ts.p.lastpage);$(".selbox",ts.p.pager).attr("disabled",false)}if(ts.p.pginput===true){$(".ui-pg-input",ts.p.pager).val(ts.p.page);$("#sp_1",ts.p.pager).html(ts.p.lastpage)}if(ts.p.viewrecords){bs=ts.p.scroll===true?0:base;if(ts.p.reccount===0){$(".ui-paging-info",ts.p.pager).html(ts.p.emptyrecords)}else{from=bs+1;to=base+ts.p.reccount;tot=ts.p.records;if($.fmatter){fmt=$.jgrid.formatter.integer||{};from=$.fmatter.util.NumberFormat(from,fmt);to=$.fmatter.util.NumberFormat(to,fmt);tot=$.fmatter.util.NumberFormat(tot,fmt)}$(".ui-paging-info",ts.p.pager).html($.jgrid.format(ts.p.recordtext,from,to,tot))}}if(ts.p.pgbuttons===true){if(cp<=0){cp=last=1}if(cp==1){$("#first, #prev",ts.p.pager).addClass("ui-state-disabled").removeClass("ui-state-hover")}else{$("#first, #prev",ts.p.pager).removeClass("ui-state-disabled")}if(cp==last){$("#next, #last",ts.p.pager).addClass("ui-state-disabled").removeClass("ui-state-hover")}else{$("#next, #last",ts.p.pager).removeClass("ui-state-disabled")}}}if(rn===true&&ts.p.rownumbers===true){$("td.jqgrid-rownum",ts.rows).each(function(i){$(this).html(base+1+i)})}if($.isFunction(ts.p.gridComplete)){ts.p.gridComplete()}},populate=function(){if(!ts.grid.hDiv.loading){var prm={},dt,dstr,pN=ts.p.prmNames;if(pN.search!==null){prm[pN.search]=ts.p.search}if(pN.nd!=null){prm[pN.nd]=new Date().getTime()}if(pN.rows!==null){prm[pN.rows]=ts.p.rowNum}if(pN.page!==null){prm[pN.page]=ts.p.page}if(pN.sort!==null){prm[pN.sort]=ts.p.sortname}if(pN.order!==null){prm[pN.order]=ts.p.sortorder}$.extend(ts.p.postData,prm);var rcnt=ts.p.scroll===false?0:ts.rows.length-1;if($.isFunction(ts.p.datatype)){ts.p.datatype(ts.p.postData,"load_"+ts.p.id);return}else{if(beReq){ts.p.beforeRequest()}}dt=ts.p.datatype.toLowerCase();switch(dt){case"json":case"jsonp":case"xml":case"script":$.ajax({url:ts.p.url,type:ts.p.mtype,dataType:dt,data:ts.p.postData,complete:function(req,st){if(st=="success"||(req.statusText=="OK"&&req.status=="200")){if(dt==="xml"){addXmlData(req.responseXML,ts.grid.bDiv,rcnt)}else{addJSONData($.jgrid.parse(req.responseText),ts.grid.bDiv,rcnt)}if(loadComplete){loadComplete(req)}}req=null;endReq()},error:function(xhr,st,err){if(loadError){loadError(xhr,st,err)}endReq();xhr=null},beforeSend:function(xhr){beginReq();if(loadBeforeSend){loadBeforeSend(xhr)}}});if(ts.p.loadonce||ts.p.treeGrid){ts.p.datatype="local"}break;case"xmlstring":beginReq();addXmlData(dstr=$.jgrid.stringToDoc(ts.p.datastr),ts.grid.bDiv);ts.p.datatype="local";if(loadComplete){loadComplete(dstr)}ts.p.datastr=null;endReq();break;case"jsonstring":beginReq();if(typeof ts.p.datastr=="string"){dstr=$.jgrid.parse(ts.p.datastr)}else{dstr=ts.p.datastr}addJSONData(dstr,ts.grid.bDiv);ts.p.datatype="local";if(loadComplete){loadComplete(dstr)}ts.p.datastr=null;endReq();break;case"local":case"clientside":beginReq();ts.p.datatype="local";sortArrayData();endReq();break}}},beginReq=function(){ts.grid.hDiv.loading=true;if(ts.p.hiddengrid){return}switch(ts.p.loadui){case"disable":break;case"enable":$("#load_"+ts.p.id).show();break;case"block":$("#lui_"+ts.p.id).show();$("#load_"+ts.p.id).show();break}},endReq=function(){ts.grid.hDiv.loading=false;switch(ts.p.loadui){case"disable":break;case"enable":$("#load_"+ts.p.id).hide();break;case"block":$("#lui_"+ts.p.id).hide();$("#load_"+ts.p.id).hide();break}},sortArrayData=function(){var stripNum=/[\$,%]/g;var rows=[],col=0,st,sv,findSortKey,newDir=(ts.p.sortorder=="asc")?1:-1;$.each(ts.p.colModel,function(i,v){if(this.index==ts.p.sortname||this.name==ts.p.sortname){col=ts.p.lastsort=i;st=this.sorttype;return false}});if(st=="float"||st=="number"||st=="currency"){findSortKey=function($cell){var key=parseFloat($cell.replace(stripNum,""));return isNaN(key)?0:key}}else{if(st=="int"||st=="integer"){findSortKey=function($cell){return IntNum($cell.replace(stripNum,""))}}else{if(st=="date"){findSortKey=function($cell){var fd=ts.p.colModel[col].datefmt||"Y-m-d";return parseDate(fd,$cell).getTime()}}else{findSortKey=function($cell){return $.trim($cell.toUpperCase())}}}}$.each(ts.rows,function(index,row){try{sv=$.unformat($(row).children("td").eq(col),{colModel:ts.p.colModel[col]},col,true)}catch(_){sv=$(row).children("td").eq(col).text()}row.sortKey=findSortKey(sv);rows[index]=this});if(ts.p.treeGrid){$(ts).SortTree(newDir)}else{rows.sort(function(a,b){if(a.sortKeyb.sortKey){return newDir}return 0});if(rows[0]){$("td",rows[0]).each(function(k){$(this).css("width",grid.headers[k].width+"px")});grid.cols=rows[0].cells}$.each(rows,function(index,row){$("tbody",ts.grid.bDiv).append(row);row.sortKey=null})}if(ts.p.multiselect){$("tbody tr",ts.grid.bDiv).removeClass("ui-state-highlight");$("[id^=jqg_]",ts.rows).attr("checked",false);$("#cb_jqg",ts.grid.hDiv).attr("checked",false);ts.p.selarrrow=[]}ts.grid.bDiv.scrollTop=0},parseDate=function(format,date){var tsp={m:1,d:1,y:1970,h:0,i:0,s:0},k,hl,dM;date=date.split(/[\\\/:_;.\t\T\s-]/);format=format.split(/[\\\/:_;.\t\T\s-]/);var dfmt=$.jgrid.formatter.date.monthNames;for(k=0,hl=format.length;k11){date[k]=dM+1-12}}tsp[format[k].toLowerCase()]=parseInt(date[k],10)}tsp.m=parseInt(tsp.m,10)-1;var ty=tsp.y;if(ty>=70&&ty<=99){tsp.y=1900+tsp.y}else{if(ty>=0&&ty<=69){tsp.y=2000+tsp.y}}return new Date(tsp.y,tsp.m,tsp.d,tsp.h,tsp.i,tsp.s,0)},setPager=function(){var sep="",pgid=$(ts.p.pager).attr("id")||"pager",pginp=(ts.p.pginput===true)?""+$.jgrid.format(ts.p.pgtext||"","","")+"":"",pgl="",str,pgcnt,lft,cent,rgt,twd,tdw,i,clearVals=function(onpaging){if($.isFunction(ts.p.onPaging)){ts.p.onPaging(onpaging)}ts.p.selrow=null;if(ts.p.multiselect){ts.p.selarrrow=[];$("#cb_jqg",ts.grid.hDiv).attr("checked",false)}ts.p.savedRow=[]};pgcnt="pg_"+pgid;lft=pgid+"_left";cent=pgid+"_center";rgt=pgid+"_right";$(ts.p.pager).addClass("ui-jqgrid-pager corner-bottom").append("
");if(ts.p.pgbuttons===true){pgl+="";pgl+="";pgl+=pginp!=""?sep+pginp+sep:"";pgl+="";pgl+=""}else{if(pginp!=""){pgl+=pginp}}if(ts.p.rowList.length>0){str="";pgl+=""+str+""}pgl+="";if(ts.p.viewrecords===true){$("td#"+pgid+"_"+ts.p.recordpos,"#"+pgcnt).append("
")}$("td#"+pgid+"_"+ts.p.pagerpos,"#"+pgcnt).append(pgl);tdw=$(".ui-jqgrid").css("font-size")||"11px";$("body").append("");twd=$(pgl).clone().appendTo("#testpg").width();$("#testpg").remove();if(twd>0){twd+=25;$("td#"+pgid+"_"+ts.p.pagerpos,"#"+pgcnt).width(twd)}ts.p._nvtd=[];ts.p._nvtd[0]=twd?Math.floor((ts.p.width-twd)/2):Math.floor(ts.p.width/3);ts.p._nvtd[1]=0;pgl=null;$(".ui-pg-selbox","#"+pgcnt).bind("change",function(){ts.p.page=Math.round(ts.p.rowNum*(ts.p.page-1)/this.value-0.5)+1;ts.p.rowNum=this.value;clearVals("records");populate();return false});if(ts.p.pgbuttons===true){$(".ui-pg-button","#"+pgcnt).hover(function(e){if($(this).hasClass("ui-state-disabled")){this.style.cursor="default"}else{$(this).addClass("ui-state-hover");this.style.cursor="pointer"}},function(e){if($(this).hasClass("ui-state-disabled")){}else{$(this).removeClass("ui-state-hover");this.style.cursor="default"}});$("#first, #prev, #next, #last",ts.p.pager).click(function(e){var cp=IntNum(ts.p.page),last=IntNum(ts.p.lastpage),selclick=false,fp=true,pp=true,np=true,lp=true;if(last===0||last===1){fp=false;pp=false;np=false;lp=false}else{if(last>1&&cp>=1){if(cp===1){fp=false;pp=false}else{if(cp>1&&cp1&&cp===0){np=false;lp=false;cp=last-1}}}if(this.id==="first"&&fp){ts.p.page=1;selclick=true}if(this.id==="prev"&&pp){ts.p.page=(cp-1);selclick=true}if(this.id==="next"&&np){ts.p.page=(cp+1);selclick=true}if(this.id==="last"&&lp){ts.p.page=last;selclick=true}if(selclick){clearVals(this.id);populate()}return false})}if(ts.p.pginput===true){$("input.ui-pg-input","#"+pgcnt).keypress(function(e){var key=e.charCode?e.charCode:e.keyCode?e.keyCode:0;if(key==13){ts.p.page=($(this).val()>0)?$(this).val():ts.p.page;clearVals("user");populate();return false}return this})}},sortData=function(index,idxcol,reload,sor){if(!ts.p.colModel[idxcol].sortable){return}var imgs,so;if(ts.p.savedRow.length>0){return}if(!reload){if(ts.p.lastsort==idxcol){if(ts.p.sortorder=="asc"){ts.p.sortorder="desc"}else{if(ts.p.sortorder=="desc"){ts.p.sortorder="asc"}}}else{ts.p.sortorder="asc"}ts.p.page=1}if(sor){if(ts.p.lastsort==idxcol&&ts.p.sortorder==sor){return}else{ts.p.sortorder=sor}}var thd=$("thead:first",ts.grid.hDiv).get(0);$("tr th:eq("+ts.p.lastsort+") span.ui-grid-ico-sort",thd).addClass("ui-state-disabled");$("tr th:eq("+ts.p.lastsort+")",thd).attr("aria-selected","false");$("tr th:eq("+idxcol+") span.ui-icon-"+ts.p.sortorder,thd).removeClass("ui-state-disabled");$("tr th:eq("+idxcol+")",thd).attr("aria-selected","true");if(!ts.p.viewsortcols[0]){if(ts.p.lastsort!=idxcol){$("tr th:eq("+ts.p.lastsort+") span.s-ico",thd).hide();$("tr th:eq("+idxcol+") span.s-ico",thd).show()}}ts.p.lastsort=idxcol;index=index.substring(5);ts.p.sortname=ts.p.colModel[idxcol].index||index;so=ts.p.sortorder;if(onSortCol){onSortCol(index,idxcol,so)}if(ts.p.datatype=="local"){if(ts.p.deselectAfterSort){$(ts).resetSelection()}}else{ts.p.selrow=null;if(ts.p.multiselect){$("#cb_jqg",ts.grid.hDiv).attr("checked",false)}ts.p.selarrrow=[];ts.p.savedRow=[]}if(ts.p.scroll===true){$("tbody tr",ts.grid.bDiv).remove()}if(ts.p.subGrid&&ts.p.datatype=="local"){$("td.sgexpanded","#"+ts.p.id).each(function(){$(this).trigger("click")})}populate();if(ts.p.sortname!=index&&idxcol){ts.p.lastsort=idxcol}},setColWidth=function(){var initwidth=0,brd=ts.p.cellLayout,vc=0,lvc,scw=ts.p.scrollOffset,cw,hs=false,aw,tw=0,gw=0,msw=ts.p.multiselectWidth,sgw=ts.p.subGridWidth,rnw=ts.p.rownumWidth,cl=ts.p.cellLayout,cr;$.each(ts.p.colModel,function(i){if(typeof this.hidden==="undefined"){this.hidden=false}if(this.hidden===false){initwidth+=IntNum(this.width);vc++}});if(isNaN(ts.p.width)){ts.p.width=grid.width=initwidth}else{grid.width=ts.p.width}ts.p.tblwidth=initwidth;if(ts.p.shrinkToFit===false&&ts.p.forceFit===true){ts.p.forceFit=false}if(ts.p.shrinkToFit===true){if(isSafari){brd=0;msw+=cl;sgw+=cl;rnw+=cl}if(ts.p.multiselect){tw=msw;gw=msw+brd;vc--}if(ts.p.subGrid){tw+=sgw;gw+=sgw+brd;vc--}if(ts.p.rownumbers){tw+=rnw;gw+=rnw+brd;vc--}aw=grid.width-brd*vc-gw;if(isNaN(ts.p.height)){}else{aw-=scw;hs=true}initwidth=0;$.each(ts.p.colModel,function(i){if(this.hidden===false&&this.name!=="cb"&&this.name!=="subgrid"&&this.name!=="rn"){cw=Math.floor(aw/(ts.p.tblwidth-tw)*this.width);this.width=cw;initwidth+=cw;lvc=i}});cr=0;if(hs&&grid.width-gw-(initwidth+brd*vc)!==scw){cr=grid.width-gw-(initwidth+brd*vc)-scw}else{if(!hs&&Math.abs(grid.width-gw-(initwidth+brd*vc))!==1){cr=grid.width-gw-(initwidth+brd*vc)}}ts.p.colModel[lvc].width+=cr;ts.p.tblwidth=initwidth+tw+cr}},nextVisible=function(iCol){var ret=iCol,j=iCol,i;for(i=iCol+1;i");this.p.colModel.unshift({name:"cb",width:isSafari?ts.p.multiselectWidth+ts.p.cellLayout:ts.p.multiselectWidth,sortable:false,resizable:false,hidedlg:true,search:false,align:"center"})}if(this.p.rownumbers){this.p.colNames.unshift("");this.p.colModel.unshift({name:"rn",width:ts.p.rownumWidth,sortable:false,resizable:false,hidedlg:true,search:false,align:"center"})}ts.p.xmlReader=$.extend({root:"rows",row:"row",page:"rows>page",total:"rows>total",records:"rows>records",repeatitems:true,cell:"cell",id:"[id]",userdata:"userdata",subgrid:{root:"rows",row:"row",repeatitems:true,cell:"cell"}},ts.p.xmlReader);ts.p.jsonReader=$.extend({root:"rows",page:"page",total:"total",records:"records",repeatitems:true,cell:"cell",id:"id",userdata:"userdata",subgrid:{root:"rows",repeatitems:true,cell:"cell"}},ts.p.jsonReader);if(ts.p.scroll===true){ts.p.pgbuttons=false;ts.p.pginput=false;ts.p.rowList=[]}var thead="",tdc,idn,w,res,sort,td,ptr,tbody,imgs,iac="",idc="";if(ts.p.shrinkToFit===true&&ts.p.forceFit===true){for(i=ts.p.colModel.length-1;i>=0;i--){if(!ts.p.colModel[i].hidden){ts.p.colModel[i].resizable=false;break}}}if(ts.p.viewsortcols[1]=="horizontal"){iac=" ui-i-asc";idc=" ui-i-desc"}tdc=isMSIE?"class='ui-th-div-ie'":"";imgs="";for(i=0;i";idn=ts.p.colModel[i].index||ts.p.colModel[i].name;thead+="
"+ts.p.colNames[i];if(idn==ts.p.sortname){ts.p.lastsort=i}thead+=imgs+"
"}thead+="";$(this).append(thead);$("thead tr:first th",this).hover(function(){$(this).addClass("ui-state-hover")},function(){$(this).removeClass("ui-state-hover")});if(this.p.multiselect){var onSA=true,emp=[],chk;if(typeof ts.p.onSelectAll!=="function"){onSA=false}$("#cb_jqg",this).bind("click",function(){if(this.checked){$("[id^=jqg_]",ts.rows).attr("checked",true);$(ts.rows).each(function(i){if(!$(this).hasClass("subgrid")){$(this).addClass("ui-state-highlight").attr("aria-selected","true");ts.p.selarrrow[i]=ts.p.selrow=this.id}});chk=true;emp=[]}else{$("[id^=jqg_]",ts.rows).attr("checked",false);$(ts.rows).each(function(i){if(!$(this).hasClass("subgrid")){$(this).removeClass("ui-state-highlight").attr("aria-selected","false");emp[i]=this.id}});ts.p.selarrrow=[];ts.p.selrow=null;chk=false}if(onSA){ts.p.onSelectAll(chk?ts.p.selarrrow:emp,chk)}})}$.each(ts.p.colModel,function(i){if(!this.width){this.width=150}});if(ts.p.autowidth===true){var pw=$(eg).innerWidth();ts.p.width=pw>0?pw:"nw"}setColWidth();$(eg).css("width",grid.width+"px").append("
 
");$(gv).css("width",grid.width+"px");thead=$("thead:first",ts).get(0);var tfoot="";$("tr:first th",thead).each(function(j){var ht=$("div",this)[0];w=ts.p.colModel[j].width;if(typeof ts.p.colModel[j].resizable==="undefined"){ts.p.colModel[j].resizable=true}res=document.createElement("span");$(res).html(" ");if(ts.p.colModel[j].resizable){$(this).addClass(ts.p.resizeclass);$(res).mousedown(function(e){if(ts.p.forceFit===true){ts.p.nv=nextVisible(j)}grid.dragStart(j,e,getOffset(j));return false}).addClass("ui-jqgrid-resize")}else{res=""}$(this).css("width",w+"px").prepend(res);if(ts.p.colModel[j].hidden){$(this).css("display","none")}grid.headers[j]={width:w,el:this};sort=ts.p.colModel[j].sortable;if(typeof sort!=="boolean"){ts.p.colModel[j].sortable=true;sort=true}var nm=ts.p.colModel[j].name;if(!(nm=="cb"||nm=="subgrid"||nm=="rn")){if(ts.p.viewsortcols[2]==false){$(".ui-grid-ico-sort",this).click(function(){sortData(ht.id,j,true,$(this).attr("sort"));return false})}else{$("div",this).addClass("ui-jqgrid-sortable").click(function(){sortData(ht.id,j);return false})}}if(sort){if(ts.p.viewsortcols[0]){$("div span.s-ico",this).show();if(j==ts.p.lastsort){$("div span.ui-icon-"+ts.p.sortorder,this).removeClass("ui-state-disabled")}}else{if(j==ts.p.lastsort){$("div span.s-ico",this).show();$("div span.ui-icon-"+ts.p.sortorder,this).removeClass("ui-state-disabled")}}}tfoot+=""});tfoot+="
 
";tbody=document.createElement("tbody");this.appendChild(tbody);$(this).addClass("ui-jqgrid-btable");var hTable=$("
").append(thead),hg=(ts.p.caption&&ts.p.hiddengrid===true)?true:false,hb=$("
");grid.hDiv=document.createElement("div");$(grid.hDiv).css({width:grid.width+"px"}).addClass("ui-state-default ui-jqgrid-hdiv").append(hb);$(hb).append(hTable);if(hg){$(grid.hDiv).hide()}ts.p._height=0;if(ts.p.pager){if(typeof ts.p.pager=="string"){if(ts.p.pager.substr(0,1)!="#"){ts.p.pager="#"+ts.p.pager}}$(ts.p.pager).css({width:grid.width+"px"}).appendTo(eg).addClass("ui-state-default ui-jqgrid-pager");ts.p._height+=parseInt($(ts.p.pager).height(),10);if(hg){$(ts.p.pager).hide()}setPager()}if(ts.p.cellEdit===false&&ts.p.hoverrows===true){$(ts).bind("mouseover",function(e){ptr=$(e.target).parents("tr.jqgrow");if($(ptr).attr("class")!=="subgrid"){$(ptr).addClass("ui-state-hover")}return false}).bind("mouseout",function(e){ptr=$(e.target).parents("tr.jqgrow");$(ptr).removeClass("ui-state-hover");return false})}var ri,ci;$(ts).before(grid.hDiv).click(function(e){td=e.target;var scb=$(td).hasClass("cbox");ptr=$(td,ts.rows).parents("tr.jqgrow");if($(ptr).length===0){return this}var cSel=true;if(bSR){cSel=bSR(ptr[0].id,e)}if(td.tagName=="A"||((td.tagName=="INPUT"||td.tagName=="TEXTAREA"||td.tagName=="OPTION"||td.tagName=="SELECT")&&!scb)){return true}if(cSel===true){if(ts.p.cellEdit===true){if(ts.p.multiselect&&scb){$(ts).setSelection(ptr[0].id,true)}else{ri=ptr[0].rowIndex;ci=!$(td).is("td")?$(td).parents("td:first")[0].cellIndex:td.cellIndex;if(isMSIE){ci=$.jgrid.getAbsoluteIndex(ptr[0],ci)}try{$(ts).editCell(ri,ci,true)}catch(e){}}}else{if(!ts.p.multikey){if(ts.p.multiselect&&ts.p.multiboxonly){if(scb){$(ts).setSelection(ptr[0].id,true)}else{$(ts.p.selarrrow).each(function(i,n){var ind=ts.rows.namedItem(n);$(ind).removeClass("ui-state-highlight");$("#jqg_"+n.replace(".","\\."),ind).attr("checked",false)});ts.p.selarrrow=[];$("#cb_jqg",ts.grid.hDiv).attr("checked",false);$(ts).setSelection(ptr[0].id,true)}}else{$(ts).setSelection(ptr[0].id,true)}}else{if(e[ts.p.multikey]){$(ts).setSelection(ptr[0].id,true)}else{if(ts.p.multiselect&&scb){scb=$("[id^=jqg_]",ptr).attr("checked");$("[id^=jqg_]",ptr).attr("checked",!scb)}}}}if(onSC){ri=ptr[0].id;ci=!$(td).is("td")?$(td).parents("td:first")[0].cellIndex:td.cellIndex;if(isMSIE){ci=$.jgrid.getAbsoluteIndex(ptr[0],ci)}onSC(ri,ci,$(td).html(),td)}}e.stopPropagation()}).bind("reloadGrid",function(e){if(ts.p.treeGrid===true){ts.p.datatype=ts.p.treedatatype}if(ts.p.datatype=="local"){$(ts).resetSelection()}else{if(!ts.p.treeGrid){ts.p.selrow=null;if(ts.p.multiselect){ts.p.selarrrow=[];$("#cb_jqg",ts.grid.hDiv).attr("checked",false)}if(ts.p.cellEdit){ts.p.savedRow=[]}}}if(ts.p.scroll===true){$("tbody tr",ts.grid.bDiv).remove()}ts.grid.populate();return false});if(ondblClickRow){$(this).dblclick(function(e){td=(e.target);ptr=$(td,ts.rows).parents("tr.jqgrow");if($(ptr).length===0){return false}ri=ptr[0].rowIndex;ci=!$(td).is("td")?$(td).parents("td:first")[0].cellIndex:td.cellIndex;if(isMSIE){ci=$.jgrid.getAbsoluteIndex(ptr[0],ci)}ts.p.ondblClickRow($(ptr).attr("id"),ri,ci);return false})}if(onRightClickRow){$(this).bind("contextmenu",function(e){td=e.target;ptr=$(td,ts.rows).parents("tr.jqgrow");if($(ptr).length===0){return false}if(!ts.p.multiselect){$(ts).setSelection(ptr[0].id,true)}ri=ptr[0].rowIndex;ci=!$(td).is("td")?$(td).parents("td:first")[0].cellIndex:td.cellIndex;if(isMSIE){ci=$.jgrid.getAbsoluteIndex(ptr[0],ci)}ts.p.onRightClickRow($(ptr).attr("id"),ri,ci);return false})}grid.bDiv=document.createElement("div");$(grid.bDiv).append(this).addClass("ui-jqgrid-bdiv").css({height:ts.p.height+(isNaN(ts.p.height)?"":"px"),width:(grid.width)+"px"}).scroll(function(e){grid.scrollGrid()});$("table:first",grid.bDiv).css({width:ts.p.tblwidth+"px"});if(isMSIE){if($("tbody",this).size()==2){$("tbody:first",this).remove()}if(ts.p.multikey){$(grid.bDiv).bind("selectstart",function(){return false})}}else{if(ts.p.multikey){$(grid.bDiv).bind("mousedown",function(){return false})}}if(hg){$(grid.bDiv).hide()}grid.cDiv=document.createElement("div");var arf=ts.p.hidegrid===true?$("").addClass("ui-jqgrid-titlebar-close HeaderButton").hover(function(){arf.addClass("ui-state-hover")},function(){arf.removeClass("ui-state-hover")}).append(""):"";$(grid.cDiv).append(arf).append(""+ts.p.caption+"").addClass("ui-jqgrid-titlebar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix");$(grid.cDiv).insertBefore(grid.hDiv);if(ts.p.toolbar[0]){grid.uDiv=document.createElement("div");if(ts.p.toolbar[1]=="top"){$(grid.uDiv).insertBefore(grid.hDiv)}else{if(ts.p.toolbar[1]=="bottom"){$(grid.uDiv).insertAfter(grid.hDiv)}}if(ts.p.toolbar[1]=="both"){grid.ubDiv=document.createElement("div");$(grid.uDiv).insertBefore(grid.hDiv).addClass("ui-userdata ui-state-default").attr("id","t_"+this.id);$(grid.ubDiv).insertAfter(grid.hDiv).addClass("ui-userdata ui-state-default").attr("id","tb_"+this.id);ts.p._height+=IntNum($(grid.ubDiv).height());if(hg){$(grid.ubDiv).hide()}}else{$(grid.uDiv).width(grid.width).addClass("ui-userdata ui-state-default").attr("id","t_"+this.id)}ts.p._height+=IntNum($(grid.uDiv).height());if(hg){$(grid.uDiv).hide()}}if(ts.p.footerrow){grid.sDiv=document.createElement("div");hb=$("
");$(grid.sDiv).addClass("ui-jqgrid-sdiv").append(hb).insertAfter(grid.hDiv).width(grid.width);$(hb).append(tfoot);grid.footers=$(".ui-jqgrid-ftable",grid.sDiv)[0].rows[0].cells;if(ts.p.rownumbers){grid.footers[0].className="ui-state-default jqgrid-rownum"}if(hg){$(grid.sDiv).hide()}}if(ts.p.caption){ts.p._height+=parseInt($(grid.cDiv,ts).height(),10);var tdt=ts.p.datatype;if(ts.p.hidegrid===true){$(".ui-jqgrid-titlebar-close",grid.cDiv).click(function(){if(ts.p.gridstate=="visible"){$(".ui-jqgrid-bdiv, .ui-jqgrid-hdiv","#gview_"+ts.p.id).slideUp("fast");if(ts.p.pager){$(ts.p.pager).slideUp("fast")}if(ts.p.toolbar[0]===true){if(ts.p.toolbar[1]=="both"){$(grid.ubDiv).slideUp("fast")}$(grid.uDiv).slideUp("fast")}if(ts.p.footerrow){$(".ui-jqgrid-sdiv","#gbox_"+ts.p.id).slideUp("fast")}$("span",this).removeClass("ui-icon-circle-triangle-n").addClass("ui-icon-circle-triangle-s");ts.p.gridstate="hidden";if(onHdCl){if(!hg){ts.p.onHeaderClick(ts.p.gridstate)}}}else{if(ts.p.gridstate=="hidden"){$(".ui-jqgrid-hdiv, .ui-jqgrid-bdiv","#gview_"+ts.p.id).slideDown("fast");if(ts.p.pager){$(ts.p.pager).slideDown("fast")}if(ts.p.toolbar[0]===true){if(ts.p.toolbar[1]=="both"){$(grid.ubDiv).slideDown("fast")}$(grid.uDiv).slideDown("fast")}if(ts.p.footerrow){$(".ui-jqgrid-sdiv","#gbox_"+ts.p.id).slideDown("fast")}$("span",this).removeClass("ui-icon-circle-triangle-s").addClass("ui-icon-circle-triangle-n");if(hg){ts.p.datatype=tdt;populate();hg=false}ts.p.gridstate="visible";if(onHdCl){ts.p.onHeaderClick(ts.p.gridstate)}}}return false});if(hg){ts.p.datatype="local";$(".ui-jqgrid-titlebar-close",grid.cDiv).trigger("click")}}}else{$(grid.cDiv).hide()}$(grid.hDiv).after(grid.bDiv);$(".ui-jqgrid-labels",grid.hDiv).bind("selectstart",function(){return false}).mousemove(function(e){if(grid.resizing){grid.dragMove(e)}return false});ts.p._height+=parseInt($(grid.hDiv).height(),10);$(document).mouseup(function(e){if(grid.resizing){grid.dragEnd();return false}return true});this.updateColumns=function(){var r=this.rows[0],self=this;if(r){$("td",r).each(function(k){$(this).css("width",self.grid.headers[k].width+"px")});this.grid.cols=r.cells}return this};ts.formatCol=function(a,b){return formatCol(a,b)};ts.sortData=function(a,b,c){sortData(a,b,c)};ts.updatepager=function(a){updatepager(a)};ts.formatter=function(rowId,cellval,colpos,rwdat,act){return formatter(rowId,cellval,colpos,rwdat,act)};$.extend(grid,{populate:function(){populate()}});this.grid=grid;ts.addXmlData=function(d){addXmlData(d,ts.grid.bDiv)};ts.addJSONData=function(d){addJSONData(d,ts.grid.bDiv)};populate();ts.p.hiddengrid=false;$(window).unload(function(){$(this).empty();this.grid=null;this.p=null})})};$.fn.extend({getGridParam:function(pName){var $t=this[0];if(!$t.grid){return}if(!pName){return $t.p}else{return $t.p[pName]?$t.p[pName]:null}},setGridParam:function(newParams){return this.each(function(){if(this.grid&&typeof(newParams)==="object"){$.extend(true,this.p,newParams)}})},getDataIDs:function(){var ids=[],i=0,len;this.each(function(){len=this.rows.length;if(len&&len>0){while(i=0){if(ner>olr){scrGrid(ner,"d")}else{scrGrid(ner,"u")}}}if(!$t.p.multiselect){if($(pt).attr("class")!=="subgrid"){if($t.p.selrow){$("tr#"+$t.p.selrow.replace(".","\\."),$t.grid.bDiv).removeClass("ui-state-highlight").attr("aria-selected","false")}$t.p.selrow=selection;$(pt).addClass("ui-state-highlight").attr("aria-selected","true");if($t.p.onSelectRow&&onsr){$t.p.onSelectRow($t.p.selrow,true)}}}else{$t.p.selrow=selection;ia=$.inArray($t.p.selrow,$t.p.selarrrow);if(ia===-1){if($(pt).attr("class")!=="subgrid"){$(pt).addClass("ui-state-highlight").attr("aria-selected","true")}stat=true;$("#jqg_"+$t.p.selrow.replace(".","\\."),$t.rows).attr("checked",stat);$t.p.selarrrow.push($t.p.selrow);if($t.p.onSelectRow&&onsr){$t.p.onSelectRow($t.p.selrow,stat)}}else{if($(pt).attr("class")!=="subgrid"){$(pt).removeClass("ui-state-highlight").attr("aria-selected","false")}stat=false;$("#jqg_"+$t.p.selrow.replace(".","\\."),$t.rows).attr("checked",stat);$t.p.selarrrow.splice(ia,1);if($t.p.onSelectRow&&onsr){$t.p.onSelectRow($t.p.selrow,stat)}tpsr=$t.p.selarrrow[0];$t.p.selrow=(tpsr===undefined)?null:tpsr}}function scrGrid(iR,tp){var ch=$($t.grid.bDiv)[0].clientHeight,st=$($t.grid.bDiv)[0].scrollTop,nROT=$t.rows[iR].offsetTop+$t.rows[iR].clientHeight,pROT=$t.rows[iR].offsetTop;if(tp=="d"){if(nROT>=ch){$($t.grid.bDiv)[0].scrollTop=st+nROT-pROT}}if(tp=="u"){if(pROT span:first",ind).html(vl).attr("title",$.jgrid.stripHtml(vl))}else{$("td:eq("+i+")",ind).html(vl).attr("title",$.jgrid.stripHtml(vl))}success=true}})}});return success},addRowData:function(rowid,data,pos,src){if(!pos){pos="last"}var success=false,nm,row,gi=0,si=0,ni=0,sind,i,v,prp="";if(data){this.each(function(){var t=this;rowid=typeof(rowid)!="undefined"?rowid+"":t.p.records+1;row='';if(t.p.rownumbers===true){prp=t.formatCol(ni,1);row+='0";ni=1}if(t.p.multiselect){v='';prp=t.formatCol(ni,1);row+='"+v+"";gi=1}if(t.p.subGrid===true){row+=$(t).addSubGridCell(gi+ni,1);si=1}for(i=gi+si+ni;i'+v+""}row+="";if(t.p.subGrid===true){row=$(row)[0];$(t).addSubGrid(row,gi+ni)}if(t.rows.length===0){$("table:first",t.grid.bDiv).append(row)}else{switch(pos){case"last":$(t.rows[t.rows.length-1]).after(row);break;case"first":$(t.rows[0]).before(row);break;case"after":sind=t.rows.namedItem(src);sind!=null?$(t.rows[sind.rowIndex+1]).hasClass("ui-subgrid")?$(t.rows[sind.rowIndex+1]).after(row):$(sind).after(row):"";break;case"before":sind=t.rows.namedItem(src);if(sind!=null){$(sind).before(row);sind=sind.rowIndex}break}}t.p.records++;t.p.reccount++;if(pos==="first"||(pos==="before"&&sind==0)||t.rows.length===1){t.updateColumns()}if(t.p.altRows===true){var cn=t.p.altclass;if(pos=="last"){if(t.rows.length%2==1){$(t.rows[t.rows.length-1]).addClass(cn)}}else{$(t.rows).each(function(i){if(i%2==1){$(this).addClass(cn)}else{$(this).removeClass(cn)}})}}try{t.p.afterInsertRow(rowid,data)}catch(e){}t.updatepager(true);success=true})}return success},footerData:function(action,data,format){var nm,success=false,res={};function isEmpty(obj){for(var i in obj){return false}return true}if(typeof(action)=="undefined"){action="get"}if(typeof(format)!="boolean"){format=true}action=action.toLowerCase();this.each(function(){var t=this,vl,ind;if(!t.grid||!t.p.footerrow){return false}if(action=="set"){if(isEmpty(data)){return false}}success=true;$(this.p.colModel).each(function(i){nm=this.name;if(action=="set"){if(data[nm]!=undefined){vl=format?t.formatter("",data[nm],i,data,"edit"):data[nm];$("tr.footrow td:eq("+i+")",t.grid.sDiv).html(vl).attr("title",$.jgrid.stripHtml(vl));success=true}}else{if(action=="get"){res[nm]=$("tr.footrow td:eq("+i+")",t.grid.sDiv).html()}}})});return action=="get"?res:success},ShowHideCol:function(colname,show){return this.each(function(){var $t=this,fndh=false;if(!$t.grid){return}if(typeof colname==="string"){colname=[colname]}show=show!="none"?"":"none";var sw=show==""?true:false;$(this.p.colModel).each(function(i){if($.inArray(this.name,colname)!==-1&&this.hidden===sw){$("tr",$t.grid.hDiv).each(function(){$("th:eq("+i+")",this).css("display",show)});$($t.rows).each(function(j){$("td:eq("+i+")",$t.rows[j]).css("display",show)});if($t.p.footerrow){$("td:eq("+i+")",$t.grid.sDiv).css("display",show)}if(show=="none"){$t.p.tblwidth-=this.width}else{$t.p.tblwidth+=this.width}this.hidden=!sw;fndh=true}});if(fndh===true){$("table:first",$t.grid.hDiv).width($t.p.tblwidth);$("table:first",$t.grid.bDiv).width($t.p.tblwidth);$t.grid.hDiv.scrollLeft=$t.grid.bDiv.scrollLeft;if($t.p.footerrow){$("table:first",$t.grid.sDiv).width($t.p.tblwidth);$t.grid.sDiv.scrollLeft=$t.grid.bDiv.scrollLeft}}})},hideCol:function(colname){return this.each(function(){$(this).ShowHideCol(colname,"none")})},showCol:function(colname){return this.each(function(){$(this).ShowHideCol(colname,"")})},setGridWidth:function(nwidth,shrink){return this.each(function(){var $t=this,cw,initwidth=0,brd=$t.p.cellLayout,lvc,vc=0,isSafari,hs=false,scw=$t.p.scrollOffset,aw,gw=0,tw=0,msw=$t.p.multiselectWidth,sgw=$t.p.subGridWidth,rnw=$t.p.rownumWidth,cl=$t.p.cellLayout,cr;if(!$t.grid){return}if(typeof shrink!="boolean"){shrink=$t.p.shrinkToFit}if(isNaN(nwidth)){return}if(nwidth==$t.grid.width){return}else{$t.grid.width=$t.p.width=nwidth}$("#gbox_"+$t.p.id).css("width",nwidth+"px");$("#gview_"+$t.p.id).css("width",nwidth+"px");$($t.grid.bDiv).css("width",nwidth+"px");$($t.grid.hDiv).css("width",nwidth+"px");if($t.p.pager){$($t.p.pager).css("width",nwidth+"px")}if($t.p.toolbar[0]===true){$($t.grid.uDiv).css("width",nwidth+"px");if($t.p.toolbar[1]=="both"){$($t.grid.ubDiv).css("width",nwidth+"px")}}if($t.p.footerrow){$($t.grid.sDiv).css("width",nwidth+"px")}if(shrink===false&&$t.p.forceFit==true){$t.p.forceFit=false}if(shrink===true){$.each($t.p.colModel,function(i){if(this.hidden===false){initwidth+=parseInt(this.width,10);vc++}});isSafari=$.browser.safari?true:false;if(isSafari){brd=0;msw+=cl;sgw+=cl;rnw+=cl}if($t.p.multiselect){tw=msw;gw=msw+brd;vc--}if($t.p.subGrid){tw+=sgw;gw+=sgw+brd;vc--}if($t.p.rownumbers){tw+=rnw;gw+=rnw+brd;vc--}$t.p.tblwidth=initwidth;aw=nwidth-brd*vc-gw;if(!isNaN($t.p.height)){if($($t.grid.bDiv)[0].clientHeight<$($t.grid.bDiv)[0].scrollHeight){hs=true;aw-=scw}}initwidth=0;var cle=$t.grid.cols.length>0;$.each($t.p.colModel,function(i){var tn=this.name;if(this.hidden===false&&tn!=="cb"&&tn!=="subgrid"&&tn!=="rn"){cw=Math.floor((aw)/($t.p.tblwidth-tw)*this.width);this.width=cw;initwidth+=cw;$t.grid.headers[i].width=cw;$t.grid.headers[i].el.style.width=cw+"px";if($t.p.footerrow){$t.grid.footers[i].style.width=cw+"px"}if(cle){$t.grid.cols[i].style.width=cw+"px"}lvc=i}});cr=0;if(hs&&nwidth-gw-(initwidth+brd*vc)!==scw){cr=nwidth-gw-(initwidth+brd*vc)-scw}else{if(Math.abs(nwidth-gw-(initwidth+brd*vc))!==1){cr=nwidth-gw-(initwidth+brd*vc)}}$t.p.colModel[lvc].width+=cr;cw=$t.p.colModel[lvc].width;$t.grid.headers[lvc].width=cw;$t.grid.headers[lvc].el.style.width=cw+"px";if(cl>0){$t.grid.cols[lvc].style.width=cw+"px"}$t.p.tblwidth=initwidth+tw+cr;$("table:first",$t.grid.bDiv).css("width",initwidth+tw+cr+"px");$("table:first",$t.grid.hDiv).css("width",initwidth+tw+cr+"px");$t.grid.hDiv.scrollLeft=$t.grid.bDiv.scrollLeft;if($t.p.footerrow){$t.grid.footers[lvc].style.width=cw+"px";$("table:first",$t.grid.sDiv).css("width",initwidth+tw+cr+"px")}}})},setGridHeight:function(nh){return this.each(function(){var $t=this;if(!$t.grid){return}$($t.grid.bDiv).css({height:nh+(isNaN(nh)?"":"px")});$t.p.height=nh})},setCaption:function(newcap){return this.each(function(){this.p.caption=newcap;$("span.ui-jqgrid-title",this.grid.cDiv).html(newcap);$(this.grid.cDiv).show()})},setLabel:function(colname,nData,prop,attrp){return this.each(function(){var $t=this,pos=-1;if(!$t.grid){return}if(isNaN(colname)){$($t.p.colModel).each(function(i){if(this.name==colname){pos=i;return false}})}else{pos=parseInt(colname,10)}if(pos>=0){var thecol=$("tr.ui-jqgrid-labels th:eq("+pos+")",$t.grid.hDiv);if(nData){$("div",thecol).html(nData);$t.p.colNames[pos]=nData}if(prop){if(typeof prop==="string"){$(thecol).addClass(prop)}else{$(thecol).css(prop)}}if(typeof attrp==="object"){$(thecol).attr(attrp)}}})},setCell:function(rowid,colname,nData,cssp,attrp){return this.each(function(){var $t=this,pos=-1,v;if(!$t.grid){return}if(isNaN(colname)){$($t.p.colModel).each(function(i){if(this.name==colname){pos=i;return false}})}else{pos=parseInt(colname,10)}if(pos>=0){var ind=$t.rows.namedItem(rowid);if(ind){var tcell=$("td:eq("+pos+")",ind);if(nData!==""){v=$t.formatter(rowid,nData,pos,ind,"edit");$(tcell).html(v).attr("title",$.jgrid.stripHtml(v))}if(cssp){if(typeof cssp==="string"){$(tcell).addClass(cssp)}else{$(tcell).css(cssp)}}if(typeof attrp==="object"){$(tcell).attr(attrp)}}}})},getCell:function(rowid,col){var ret=false;this.each(function(){var $t=this,pos=-1;if(!$t.grid){return}if(isNaN(col)){$($t.p.colModel).each(function(i){if(this.name===col){pos=i;return false}})}else{pos=parseInt(col,10)}if(pos>=0){var ind=$t.rows.namedItem(rowid);if(ind){try{ret=$.unformat($("td:eq("+pos+")",ind),{colModel:$t.p.colModel[pos]},pos)}catch(e){ret=$.jgrid.htmlDecode($("td:eq("+pos+")",ind).html())}}}});return ret},getCol:function(col,obj){var ret=[],val;obj=obj==false?false:true;this.each(function(){var $t=this,pos=-1;if(!$t.grid){return}if(isNaN(col)){$($t.p.colModel).each(function(i){if(this.name===col){pos=i;return false}})}else{pos=parseInt(col,10)}if(pos>=0){var ln=$t.rows.length,i=0;if(ln&&ln>0){while(i0){if(b===true){if(d==k.p.iRow&&c==k.p.iCol){return}}var h=a("td:eq("+k.p.savedRow[0].ic+")>#"+k.p.savedRow[0].id+"_"+k.p.savedRow[0].name.replace(".","\\."),k.rows[k.p.savedRow[0].id]).val();if(k.p.savedRow[0].v!=h){a(k).saveCell(k.p.savedRow[0].id,k.p.savedRow[0].ic)}else{a(k).restoreCell(k.p.savedRow[0].id,k.p.savedRow[0].ic)}}else{window.setTimeout(function(){a("#"+k.p.knv).attr("tabindex","-1").focus()},0)}n=k.p.colModel[c].name;if(n=="subgrid"||n=="cb"||n=="rn"){return}if(k.p.colModel[c].editable===true&&b===true){g=a("td:eq("+c+")",k.rows[d]);if(parseInt(k.p.iCol)>=0&&parseInt(k.p.iRow)>=0){a("td:eq("+k.p.iCol+")",k.rows[k.p.iRow]).removeClass("edit-cell ui-state-highlight");a(k.rows[k.p.iRow]).removeClass("selected-row ui-state-hover")}a(g).addClass("edit-cell ui-state-highlight");a(k.rows[d]).addClass("selected-row ui-state-hover");try{l=a.unformat(g,{colModel:k.p.colModel[c]},c)}catch(m){l=a(g).html()}if(!k.p.colModel[c].edittype){k.p.colModel[c].edittype="text"}k.p.savedRow.push({id:d,ic:c,name:n,v:l});if(a.isFunction(k.p.formatCell)){var j=k.p.formatCell(k.rows[d].id,n,l,d,c);if(j){l=j}}var f=a.extend({},k.p.colModel[c].editoptions||{},{id:d+"_"+n,name:n});var e=createEl(k.p.colModel[c].edittype,f,l,true);if(a.isFunction(k.p.beforeEditCell)){k.p.beforeEditCell(k.rows[d].id,n,l,d,c)}a(g).html("").append(e).attr("tabindex","0");window.setTimeout(function(){a(e).focus()},0);a("input, select, textarea",g).bind("keydown",function(o){if(o.keyCode===27){a(k).restoreCell(d,c)}if(o.keyCode===13){a(k).saveCell(d,c)}if(o.keyCode==9){if(o.shiftKey){a(k).prevCell(d,c)}else{a(k).nextCell(d,c)}}o.stopPropagation()});if(a.isFunction(k.p.afterEditCell)){k.p.afterEditCell(k.rows[d].id,n,l,d,c)}}else{if(parseInt(k.p.iCol)>=0&&parseInt(k.p.iRow)>=0){a("td:eq("+k.p.iCol+")",k.rows[k.p.iRow]).removeClass("edit-cell ui-state-highlight");a(k.rows[k.p.iRow]).removeClass("selected-row ui-state-hover")}a("td:eq("+c+")",k.rows[d]).addClass("edit-cell ui-state-highlight");a(k.rows[d]).addClass("selected-row ui-state-hover");if(a.isFunction(k.p.onSelectCell)){l=a("td:eq("+c+")",k.rows[d]).html().replace(/\ \;/ig,"");k.p.onSelectCell(k.rows[d].id,n,l,d,c)}}k.p.iCol=c;k.p.iRow=d})},saveCell:function(c,b){return this.each(function(){var k=this,m;if(!k.grid||k.p.cellEdit!==true){return}if(k.p.savedRow.length>=1){m=0}else{m=null}if(m!=null){var g=a("td:eq("+b+")",k.rows[c]),r,p,s=k.p.colModel[b].name.replace(".","\\.");switch(k.p.colModel[b].edittype){case"select":if(!k.p.colModel[b].editoptions.multiple){r=a("#"+c+"_"+s+">option:selected",k.rows[c]).val();p=a("#"+c+"_"+s+">option:selected",k.rows[c]).text()}else{var d=a("#"+c+"_"+s,k.rows[c]),f=[];r=a(d).val();if(r){r.join(",")}else{r=""}a("option:selected",d).each(function(e,t){f[e]=a(t).text()});p=f.join(",")}if(k.p.colModel[b].formatter){p=r}break;case"checkbox":var h=["Yes","No"];if(k.p.colModel[b].editoptions){h=k.p.colModel[b].editoptions.value.split(":")}r=a("#"+c+"_"+s.replace(".","\\."),k.rows[c]).attr("checked")?h[0]:h[1];p=r;break;case"password":case"text":case"textarea":case"button":r=!k.p.autoencode?a("#"+c+"_"+s.replace(".","\\."),k.rows[c]).val():a.jgrid.htmlEncode(a("#"+c+"_"+s.replace(".","\\."),k.rows[c]).val());p=r;break}if(p!=k.p.savedRow[m].v){if(a.isFunction(k.p.beforeSaveCell)){var q=k.p.beforeSaveCell(k.rows[c].id,s,r,c,b);if(q){r=q}}var j=checkValues(r,b,k);if(j[0]===true){var l={};if(a.isFunction(k.p.beforeSubmitCell)){l=k.p.beforeSubmitCell(k.rows[c].id,s,r,c,b);if(!l){l={}}}if(p==""){p=" "}if(k.p.cellsubmit=="remote"){if(k.p.cellurl){var o={};o[s]=r;o.id=k.rows[c].id;o=a.extend(l,o);a.ajax({url:k.p.cellurl,data:o,type:"POST",complete:function(e,u){if(u=="success"){if(a.isFunction(k.p.afterSubmitCell)){var t=k.p.afterSubmitCell(e,o.id,s,r,c,b);if(t[0]===true){a(g).empty();a(k).setCell(k.rows[c].id,b,p);a(g).addClass("dirty-cell");a(k.rows[c]).addClass("edited");if(a.isFunction(k.p.afterSaveCell)){k.p.afterSaveCell(k.rows[c].id,s,r,c,b)}k.p.savedRow.splice(0,1)}else{info_dialog(a.jgrid.errors.errcap,t[1],a.jgrid.edit.bClose);a(k).restoreCell(c,b)}}else{a(g).empty();a(k).setCell(k.rows[c].id,b,p);a(g).addClass("dirty-cell");a(k.rows[c]).addClass("edited");if(a.isFunction(k.p.afterSaveCell)){k.p.afterSaveCell(k.rows[c].id,s,r,c,b)}k.p.savedRow.splice(0,1)}}},error:function(e,t){if(a.isFunction(k.p.errorCell)){k.p.errorCell(e,t);a(k).restoreCell(c,b)}else{info_dialog(a.jgrid.errors.errcap,e.status+" : "+e.statusText+"
"+t,a.jgrid.edit.bClose);a(k).restoreCell(c,b)}}})}else{try{info_dialog(a.jgrid.errors.errcap,a.jgrid.errors.nourl,a.jgrid.edit.bClose);a(k).restoreCell(c,b)}catch(n){}}}if(k.p.cellsubmit=="clientArray"){a(g).empty();a(k).setCell(k.rows[c].id,b,p);a(g).addClass("dirty-cell");a(k.rows[c]).addClass("edited");if(a.isFunction(k.p.afterSaveCell)){k.p.afterSaveCell(k.rows[c].id,s,r,c,b)}k.p.savedRow.splice(0,1)}}else{try{window.setTimeout(function(){info_dialog(a.jgrid.errors.errcap,r+" "+j[1],a.jgrid.edit.bClose)},100);a(k).restoreCell(c,b)}catch(n){}}}else{a(k).restoreCell(c,b)}}if(a.browser.opera){a("#"+k.p.knv).attr("tabindex","-1").focus()}else{window.setTimeout(function(){a("#"+k.p.knv).attr("tabindex","-1").focus()},0)}})},restoreCell:function(c,b){return this.each(function(){var h=this,d;if(!h.grid||h.p.cellEdit!==true){return}if(h.p.savedRow.length>=1){d=0}else{d=null}if(d!=null){var g=a("td:eq("+b+")",h.rows[c]);if(a.isFunction(a.fn.datepicker)){try{a.datepicker("hide")}catch(f){try{a.datepicker.hideDatepicker()}catch(f){}}}a(g).empty().attr("tabindex","-1");a(h).setCell(h.rows[c].id,b,h.p.savedRow[d].v);h.p.savedRow.splice(0,1)}window.setTimeout(function(){a("#"+h.p.knv).attr("tabindex","-1").focus()},0)})},nextCell:function(c,b){return this.each(function(){var f=this,e=false;if(!f.grid||f.p.cellEdit!==true){return}for(var d=b+1;d0){a(f).saveCell(c,b)}}})},prevCell:function(c,b){return this.each(function(){var f=this,e=false;if(!f.grid||f.p.cellEdit!==true){return}for(var d=b-1;d>=0;d--){if(f.p.colModel[d].editable===true){e=d;break}}if(e!==false){a(f).editCell(c,e,true)}else{if(f.p.savedRow.length>0){a(f).saveCell(c,b)}}})},GridNav:function(){return this.each(function(){var f=this;if(!f.grid||f.p.cellEdit!==true){return}f.p.knv=a("table:first",f.grid.bDiv).attr("id")+"_kn";var e=a(""),c;a(e).insertBefore(f.grid.cDiv);a("#"+f.p.knv).focus();a("#"+f.p.knv).keydown(function(g){switch(g.keyCode){case 38:if(f.p.iRow-1>=0){d(f.p.iRow-1,f.p.iCol,"vu");a(f).editCell(f.p.iRow-1,f.p.iCol,false)}break;case 40:if(f.p.iRow+1<=f.rows.length-1){d(f.p.iRow+1,f.p.iCol,"vd");a(f).editCell(f.p.iRow+1,f.p.iCol,false)}break;case 37:if(f.p.iCol-1>=0){c=b(f.p.iCol-1,"lft");d(f.p.iRow,c,"h");a(f).editCell(f.p.iRow,c,false)}break;case 39:if(f.p.iCol+1<=f.p.colModel.length-1){c=b(f.p.iCol+1,"rgt");d(f.p.iRow,c,"h");a(f).editCell(f.p.iRow,c,false)}break;case 13:if(parseInt(f.p.iCol,10)>=0&&parseInt(f.p.iRow,10)>=0){a(f).editCell(f.p.iRow,f.p.iCol,true)}break}return false});function d(p,n,o){if(o.substr(0,1)=="v"){var g=a(f.grid.bDiv)[0].clientHeight,q=a(f.grid.bDiv)[0].scrollTop,r=f.rows[p].offsetTop+f.rows[p].clientHeight,l=f.rows[p].offsetTop;if(o=="vd"){if(r>=g){a(f.grid.bDiv)[0].scrollTop=a(f.grid.bDiv)[0].scrollTop+f.rows[p].clientHeight}}if(o=="vu"){if(l=k+parseInt(j)){a(f.grid.bDiv)[0].scrollLeft=a(f.grid.bDiv)[0].scrollLeft+f.rows[p].cells[n].clientWidth}else{if(m=0;h--){if(f.p.colModel[h].hidden!==true){j=h;break}}}if(g=="rgt"){j=k-1;for(h=k;h"+a.caption+"");var k=jQuery("
").hover(function(){k.addClass("ui-state-hover")},function(){k.removeClass("ui-state-hover")}).append("");jQuery(b).append(k);var g=document.createElement("div");jQuery(g).addClass("ui-jqdialog-content ui-widget-content").attr("id",j.modalcontent);jQuery(g).append(d);h.appendChild(g);jQuery(h).prepend(b);if(m===true){jQuery("body").append(h)}else{jQuery(h).insertBefore(l)}if(typeof a.jqModal==="undefined"){a.jqModal=true}if(jQuery.fn.jqm&&a.jqModal===true){if(a.left==0&&a.top==0){var f=[];f=findPos(n);a.left=f[0]+4;a.top=f[1]+4}}jQuery("a.ui-jqdialog-titlebar-close",b).click(function(p){var o=jQuery("#"+j.themodal).data("onClose")||a.onClose;var q=jQuery("#"+j.themodal).data("gbox")||a.gbox;hideModal("#"+j.themodal,{gb:q,jqm:a.jqModal,onClose:o});return false});if(a.width==0||!a.width){a.width=300}if(a.height==0||!a.height){a.height=200}if(!a.zIndex){a.zIndex=950}jQuery(h).css({top:a.top+"px",left:a.left+"px",width:isNaN(a.width)?"auto":a.width+"px",height:isNaN(a.height)?"auto":a.height+"px",zIndex:a.zIndex,overflow:"hidden"}).attr({tabIndex:"-1",role:"dialog","aria-labelledby":j.modalhead,"aria-hidden":"true"});if(typeof a.drag=="undefined"){a.drag=true}if(typeof a.resize=="undefined"){a.resize=true}if(a.drag){jQuery(b).css("cursor","move");if(jQuery.fn.jqDrag){jQuery(h).jqDrag(b)}else{try{jQuery(h).draggable({handle:jQuery("#"+b.id)})}catch(c){}}}if(a.resize){if(jQuery.fn.jqResize){jQuery(h).append("
");jQuery("#"+j.themodal).jqResize(".jqResize",j.scrollelm?"#"+j.scrollelm:false)}else{try{jQuery(h).resizable({handles:"se",alsoResize:j.scrollelm?"#"+j.scrollelm:false})}catch(c){}}}if(a.closeOnEscape===true){jQuery(h).keydown(function(p){if(p.which==27){var o=jQuery("#"+j.themodal).data("onClose")||a.onClose;hideModal(this,{gb:a.gbox,jqm:a.jqModal,onClose:o})}})}};var viewModal=function(a,c){c=jQuery.extend({toTop:true,overlay:10,modal:false,onShow:showModal,onHide:closeModal,gbox:"",jqm:true,jqM:true},c||{});if(jQuery.fn.jqm&&c.jqm==true){if(c.jqM){jQuery(a).attr("aria-hidden","false").jqm(c).jqmShow()}else{jQuery(a).attr("aria-hidden","false").jqmShow()}}else{if(c.gbox!=""){jQuery(".jqgrid-overlay:first",c.gbox).show();jQuery(a).data("gbox",c.gbox)}jQuery(a).show().attr("aria-hidden","false");try{jQuery(":input:visible",a)[0].focus()}catch(b){}}};var hideModal=function(a,d){d=jQuery.extend({jqm:true,gb:""},d||{});if(d.onClose){var b=d.onClose(a);if(typeof b=="boolean"&&!b){return}}if(jQuery.fn.jqm&&d.jqm===true){jQuery(a).attr("aria-hidden","true").jqmHide()}else{if(d.gb!=""){try{jQuery(".jqgrid-overlay:first",d.gb).hide()}catch(c){}}jQuery(a).hide().attr("aria-hidden","true")}};function info_dialog(l,f,b,k){var g={width:290,height:"auto",dataheight:"auto",drag:true,resize:false,caption:""+l+"",left:250,top:170,jqModal:true,closeOnEscape:true,align:"center",buttonalign:"center"};jQuery.extend(g,k||{});var c=g.jqModal;if(jQuery.fn.jqm&&!c){c=false}var h=isNaN(g.dataheight)?g.dataheight:g.dataheight+"px",j="text-align:"+g.align+";";var a="
";a+="
"+f+"
";a+=b?"":"";a+="
";try{jQuery("#info_dialog").remove()}catch(d){}createModal({themodal:"info_dialog",modalhead:"info_head",modalcontent:"info_content",scrollelm:"infocnt"},a,g,"","",true);jQuery("#closedialog","#info_id").click(function(m){hideModal("#info_dialog",{jqm:c});return false});jQuery(".fm-button","#info_dialog").hover(function(){jQuery(this).addClass("ui-state-hover")},function(){jQuery(this).removeClass("ui-state-hover")});viewModal("#info_dialog",{onHide:function(e){e.w.hide().remove();if(e.o){e.o.remove()}},modal:true,jqm:c})}function findPos(a){var b=curtop=0;if(a.offsetParent){do{b+=a.offsetLeft;curtop+=a.offsetTop}while(a=a.offsetParent)}return[b,curtop]}function isArray(a){if(a.constructor.toString().indexOf("Array")==-1){return false}else{return true}}function createEl(h,r,f,s){var g="";if(r.defaultValue){delete r.defaultValue}function o(t,e){if(jQuery.isFunction(e.dataInit)){t.id=e.id;e.dataInit(t);delete e.id;delete e.dataInit}if(e.dataEvents){jQuery.each(e.dataEvents,function(){if(this.data!=null){jQuery(t).bind(this.type,this.data,this.fn)}else{jQuery(t).bind(this.type,this.fn)}});delete e.dataEvents}return e}switch(h){case"textarea":g=document.createElement("textarea");if(s){if(!r.cols){jQuery(g).css({width:"98%"})}}else{if(!r.cols){r.cols=20}}if(!r.rows){r.rows=2}if(f==" "||f==" "||(f.length==1&&f.charCodeAt(0)==160)){f=""}g.value=f;r=o(g,r);jQuery(g).attr(r);break;case"checkbox":g=document.createElement("input");g.type="checkbox";if(!r.value){var p=f.toLowerCase();if(p.search(/(false|0|no|off|undefined)/i)<0&&p!==""){g.checked=true;g.defaultChecked=true;g.value=f}else{g.value="on"}jQuery(g).attr("offval","off")}else{var a=r.value.split(":");if(f===a[0]){g.checked=true;g.defaultChecked=true}g.value=a[0];jQuery(g).attr("offval",a[1]);try{delete r.value}catch(l){}}r=o(g,r);jQuery(g).attr(r);break;case"select":g=document.createElement("select");var q=r.multiple===true?true:false;if(r.dataUrl!=null){jQuery.get(r.dataUrl,{_nsd:(new Date().getTime())},function(u){try{delete r.dataUrl;delete r.value}catch(v){}var t=jQuery(u).html();jQuery(g).append(t);r=o(g,r);if(typeof r.size==="undefined"){r.size=q?3:1}jQuery(g).attr(r);setTimeout(function(){jQuery("option",g).each(function(e){if(jQuery(this).text()==f||jQuery(this).html()==f){this.selected="selected";return false}})},0)},"html")}else{if(r.value){var j=[],k;if(q){j=f.split(",");j=jQuery.map(j,function(e){return jQuery.trim(e)});if(typeof r.size==="undefined"){r.size=3}}else{r.size=1}if(typeof r.value==="function"){r.value=r.value()}if(typeof r.value==="string"){var c=r.value.split(";"),n,d;for(k=0;k-1||jQuery.inArray(n[0],j)>-1)){d.selected="selected"}g.appendChild(d)}}else{if(typeof r.value==="object"){var b=r.value;k=0;for(var m in b){k++;d=document.createElement("option");d.value=m;d.innerHTML=b[m];if(!q&&(m==f||b[m]==f)){d.selected="selected"}if(q&&(jQuery.inArray(b[m],j)>-1||jQuery.inArray(m,j)>-1)){d.selected="selected"}g.appendChild(d)}}}r=o(g,r);try{delete r.value}catch(l){}jQuery(g).attr(r)}}break;case"text":case"password":case"button":g=document.createElement("input");g.type=h;g.value=jQuery.jgrid.htmlDecode(f);r=o(g,r);if(h!="button"){if(s){if(!r.size){jQuery(g).css({width:"98%"})}}else{if(!r.size){r.size=20}}}jQuery(g).attr(r);break;case"image":case"file":g=document.createElement("input");g.type=h;r=o(g,r);jQuery(g).attr(r);break}return g}function checkValues(c,l,j){var f,h,m;if(typeof(l)=="string"){for(h=0,len=j.p.colModel.length;h=0){f=j.p.colModel[l].editrules}}if(f){if(!m){m=j.p.colNames[l]}if(f.required===true){if(c.match(/^s+$/)||c==""){return[false,m+": "+jQuery.jgrid.edit.msg.required,""]}}var d=f.required===false?false:true;if(f.number===true){if(!(d===false&&isEmpty(c))){if(isNaN(c)){return[false,m+": "+jQuery.jgrid.edit.msg.number,""]}}}if(typeof f.minValue!="undefined"&&!isNaN(f.minValue)){if(parseFloat(c)parseFloat(f.maxValue)){return[false,m+": "+jQuery.jgrid.edit.msg.maxValue+" "+f.maxValue,""]}}var a;if(f.email===true){if(!(d===false&&isEmpty(c))){a=/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;if(!a.test(c)){return[false,m+": "+jQuery.jgrid.edit.msg.email,""]}}}if(f.integer===true){if(!(d===false&&isEmpty(c))){if(isNaN(c)){return[false,m+": "+jQuery.jgrid.edit.msg.integer,""]}if((c%1!=0)||(c.indexOf(".")!=-1)){return[false,m+": "+jQuery.jgrid.edit.msg.integer,""]}}}if(f.date===true){if(!(d===false&&isEmpty(c))){var b=j.p.colModel[l].datefmt||"Y-m-d";if(!checkDate(b,c)){return[false,m+": "+jQuery.jgrid.edit.msg.date+" - "+b,""]}}}if(f.time===true){if(!(d===false&&isEmpty(c))){if(!checkTime(c)){return[false,m+": "+jQuery.jgrid.edit.msg.date+" - hh:mm (am/pm)",""]}}}if(f.url===true){if(!(d===false&&isEmpty(c))){a=/^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;if(!a.test(c)){return[false,m+": "+jQuery.jgrid.edit.msg.url,""]}}}}return[true,"",""]}function checkDate(l,c){var e={},n;l=l.toLowerCase();if(l.indexOf("/")!=-1){n="/"}else{if(l.indexOf("-")!=-1){n="-"}else{if(l.indexOf(".")!=-1){n="."}else{n="/"}}}l=l.split(n);c=c.split(n);if(c.length!=3){return false}var f=-1,m,g=-1,d=-1;for(var h=0;h12){return false}}if(g===-1){return false}else{k=e[l[g]].toString();if(k.length<1||e[l[g]]<1||e[l[g]]>31||(e[l[d]]==2&&e[l[g]]>daysInFebruary(e[l[f]]))||e[l[g]]>a[e[l[d]]]){return false}}return true}function daysInFebruary(a){return(((a%4==0)&&((!(a%100==0))||(a%400==0)))?29:28)}function DaysArray(b){for(var a=1;a<=b;a++){this[a]=31;if(a==4||a==6||a==9||a==11){this[a]=30}if(a==2){this[a]=29}}return this}function isEmpty(a){if(a.match(/^s+$/)||a==""){return true}else{return false}}function checkTime(c){var b=/^(\d{1,2}):(\d{2})([ap]m)?$/,a;if(!isEmpty(c)){a=c.match(b);if(a){if(a[3]){if(a[1]<1||a[1]>12){return false}}else{if(a[1]>23){return false}}if(a[2]>59){return false}}else{return false}}return true}(function(a){a.fn.extend({getColProp:function(d){var b={},f=this[0];if(!f.grid){return}var e=f.p.colModel;for(var c=0;c0){a(e).each(function(n){j=this;l=h.rows.namedItem(j[c]);if(l){g=j[c];if(d===true){if(h.p.jsonReader.repeatitems===true){if(h.p.jsonReader.cell){j=j[h.p.jsonReader.cell]}for(var m=0;m span:first",l).html(k).attr("title",a.jgrid.stripHtml(k))}else{a("td:eq("+m+")",l).html(k).attr("title",a.jgrid.stripHtml(k))}}f=true;return true}}a(h.p.colModel).each(function(o){b=d===true?this.jsonmap||this.name:this.name;if(j[b]!=undefined){k=h.formatter(g,j[b],o,j,"edit");if(h.p.treeGrid===true&&b==h.p.ExpandColumn){a("td:eq("+o+") > span:first",l).html(k).attr("title",a.jgrid.stripHtml(k))}else{a("td:eq("+o+")",l).html(k).attr("title",a.jgrid.stripHtml(k))}f=true}})}})}});return f},filterGrid:function(c,b){b=a.extend({gridModel:false,gridNames:false,gridToolbar:false,filterModel:[],formtype:"horizontal",autosearch:true,formclass:"filterform",tableclass:"filtertable",buttonclass:"filterbutton",searchButton:"Search",clearButton:"Clear",enableSearch:false,enableClear:false,beforeSearch:null,afterSearch:null,beforeClear:null,afterClear:null,url:"",marksearched:true},b||{});return this.each(function(){var m=this;this.p=b;if(this.p.filterModel.length==0&&this.p.gridModel===false){alert("No filter is set");return}if(!c){alert("No target grid is set!");return}this.p.gridid=c.indexOf("#")!=-1?c:"#"+c;var d=a(this.p.gridid).getGridParam("colModel");if(d){if(this.p.gridModel===true){var e=a(this.p.gridid)[0];var g;a.each(d,function(p,q){var o=[];this.search=this.search===false?false:true;if(this.editrules&&this.editrules.searchhidden===true){g=true}else{if(this.hidden===true){g=false}else{g=true}}if(this.search===true&&g===true){if(m.p.gridNames===true){o.label=e.p.colNames[p]}else{o.label=""}o.name=this.name;o.index=this.index||this.name;o.stype=this.edittype||"text";if(o.stype!="select"){o.stype="text"}o.defval=this.defval||"";o.surl=this.surl||"";o.sopt=this.editoptions||{};o.width=this.width;m.p.filterModel.push(o)}})}else{a.each(m.p.filterModel,function(p,q){for(var o=0;o0?true:false;a.extend(p.p.postData,r);var t;if(m.p.url){t=a(p).getGridParam("url");a(p).setGridParam({url:m.p.url})}a(p).setGridParam({search:s,page:1}).trigger("reloadGrid");if(t){a(p).setGridParam({url:t})}if(a.isFunction(m.p.afterSearch)){m.p.afterSearch()}};var l=function(){var r={},o,q=0;var p=a(m.p.gridid)[0],n;if(a.isFunction(m.p.beforeClear)){m.p.beforeClear()}a.each(m.p.filterModel,function(u,x){n=this.index;o=(this.defval)?this.defval:"";if(!this.stype){this.stype=="text"}switch(this.stype){case"select":var w;a("select[name="+n+"] option",m).each(function(y){if(y==0){this.selected=true}if(a(this).text()==o){this.selected=true;w=a(this).val();return false}});if(w){r[n]=w;if(m.p.marksearched){a("#jqgh_"+this.name,p.grid.hDiv).addClass("dirty-cell")}q++}else{if(m.p.marksearched){a("#jqgh_"+this.name,p.grid.hDiv).removeClass("dirty-cell")}try{delete p.p.postData[this.index]}catch(v){}}break;case"text":a("input[name="+n+"]",m).val(o);if(o){r[n]=o;if(m.p.marksearched){a("#jqgh_"+this.name,p.grid.hDiv).addClass("dirty-cell")}q++}else{if(m.p.marksearched){a("#jqgh_"+this.name,p.grid.hDiv).removeClass("dirty-cell")}try{delete p.p.postData[this.index]}catch(v){}}break}});var s=q>0?true:false;a.extend(p.p.postData,r);var t;if(m.p.url){t=a(p).getGridParam("url");a(p).setGridParam({url:m.p.url})}a(p).setGridParam({search:s,page:1}).trigger("reloadGrid");if(t){a(p).setGridParam({url:t})}if(a.isFunction(m.p.afterClear)){m.p.afterClear()}};var j=function(){var r=document.createElement("tr");var o,t,n,p,s,q;if(m.p.formtype=="horizontal"){a(f).append(r)}a.each(m.p.filterModel,function(B,w){p=document.createElement("td");a(p).append("");s=document.createElement("td");var A=this;if(!this.stype){this.stype="text"}switch(this.stype){case"select":if(this.surl){a(s).load(this.surl,function(){if(A.defval){a("select",this).val(A.defval)}a("select",this).attr({name:A.index||A.name,id:"sg_"+A.name});if(A.sopt){a("select",this).attr(A.sopt)}if(m.p.gridToolbar===true&&A.width){a("select",this).width(A.width)}if(m.p.autosearch===true){a("select",this).change(function(F){h();return false})}})}else{if(A.sopt.value){var u=A.sopt.value;var x=document.createElement("select");a(x).attr({name:A.index||A.name,id:"sg_"+A.name}).attr(A.sopt);if(typeof u==="string"){var v=u.split(";"),E,y;for(var z=0;z");if(A.sopt){a("input",s).attr(A.sopt)}if(m.p.gridToolbar===true&&A.width){if(a.browser.msie){a("input",s).width(A.width-4)}else{a("input",s).width(A.width-2)}}if(m.p.autosearch===true){a("input",s).keypress(function(G){var F=G.charCode?G.charCode:G.keyCode?G.keyCode:0;if(F==13){h();return false}return this})}break}if(m.p.formtype=="horizontal"){if(m.p.gridToolbar===true&&m.p.gridNames===false){a(r).append(s)}else{a(r).append(p).append(s)}a(r).append(s)}else{o=document.createElement("tr");a(o).append(p).append(s);a(f).append(o)}});s=document.createElement("td");if(m.p.enableSearch===true){t="";a(s).append(t);a("input#sButton",s).click(function(){h();return false})}if(m.p.enableClear===true){n="";a(s).append(n);a("input#cButton",s).click(function(){l();return false})}if(m.p.enableClear===true||m.p.enableSearch===true){if(m.p.formtype=="horizontal"){a(r).append(s)}else{o=document.createElement("tr");a(o).append(" ").append(s);a(f).append(o)}}};var k=a("
");var f=a("
");a(k).append(f);j();a(this).append(k);this.triggerSearch=function(){h()};this.clearSearch=function(){l()}})},filterToolbar:function(b){b=a.extend({autosearch:true,beforeSearch:null,afterSearch:null,beforeClear:null,afterClear:null,searchurl:""},b||{});return this.each(function(){var g=this;var c=function(){var p={},o=0,n,m;g.p.searchdata={};if(a.isFunction(b.beforeSearch)){b.beforeSearch()}a.each(g.p.colModel,function(s,u){m=this.index||this.name;switch(this.stype){case"select":n=a("select[name="+m+"]",g.grid.hDiv).val();if(n){p[m]=n;o++}else{try{delete g.p.postData[m]}catch(t){}}break;case"text":n=a("input[name="+m+"]",g.grid.hDiv).val();if(n){p[m]=n;o++}else{try{delete g.p.postData[m]}catch(t){}}break}});var q=o>0?true:false;a.extend(g.p.postData,p);var r;if(g.p.searchurl){r=g.p.url;a(g).setGridParam({url:g.p.searchurl})}a(g).setGridParam({search:q,page:1}).trigger("reloadGrid");if(r){a(g).setGridParam({url:r})}if(a.isFunction(b.afterSearch)){b.afterSearch()}};var k=function(){var p={},n,o=0,m;if(a.isFunction(b.beforeClear)){b.beforeClear()}a.each(g.p.colModel,function(s,v){n=(this.searchoptions&&this.searchoptions.defaultValue)?this.searchoptions.defaultValue:"";m=this.index||this.name;switch(this.stype){case"select":var u;a("select[name="+m+"] option",g.grid.hDiv).each(function(w){if(w==0){this.selected=true}if(a(this).text()==n){this.selected=true;u=a(this).val();return false}});if(u){p[m]=u;o++}else{try{delete g.p.postData[m]}catch(t){}}break;case"text":a("input[name="+m+"]",g.grid.hDiv).val(n);if(n){p[m]=n;o++}else{try{delete g.p.postData[m]}catch(t){}}break}});var q=o>0?true:false;a.extend(g.p.postData,p);var r;if(g.p.searchurl){r=g.p.url;a(g).setGridParam({url:g.p.searchurl})}a(g).setGridParam({search:q,page:1}).trigger("reloadGrid");if(r){a(g).setGridParam({url:r})}if(a.isFunction(b.afterClear)){b.afterClear()}};var l=function(){var m=a("tr.ui-search-toolbar",g.grid.hDiv);if(m.css("display")=="none"){m.show()}else{m.hide()}};function f(m,o){var n=a(m);if(n[0]!=null){jQuery.each(o,function(){if(this.data!=null){n.bind(this.type,this.data,this.fn)}else{n.bind(this.type,this.fn)}})}}var h=a(""),d,j,e;a.each(g.p.colModel,function(t,p){var v=this;d=a("");j=a("
");if(this.hidden===true){a(d).css("display","none")}this.search=this.search===false?false:true;if(typeof this.stype=="undefined"){this.stype="text"}e=a.extend({},this.searchoptions||{});if(this.search){switch(this.stype){case"select":if(this.surl){a(j).load(this.surl,{_nsd:(new Date().getTime())},function(){if(e.defaultValue){a("select",this).val(e.defaultValue)}a("select",this).attr({name:v.index||v.name,id:"gs_"+v.name});if(e.attr){a("select",this).attr(e.attr)}a("select",this).css({width:"100%"});if(e.dataInit!=null){e.dataInit(a("select",this)[0])}if(e.dataEvents!=null){f(a("select",this)[0],e.dataEvents)}if(b.autosearch===true){a("select",this).change(function(n){c();return false})}})}else{if(v.editoptions&&v.editoptions.value){var m=v.editoptions.value,q=document.createElement("select");q.style.width="100%";a(q).attr({name:v.index||v.name,id:"gs_"+v.name});if(typeof m==="string"){var o=m.split(";"),x,r;for(var s=0;s");if(e.attr){a("input",j).attr(e.attr)}if(e.dataInit!=null){e.dataInit(a("input",j)[0])}if(e.dataEvents!=null){f(a("input",j)[0],e.dataEvents)}if(b.autosearch===true){a("input",j).keypress(function(y){var n=y.charCode?y.charCode:y.keyCode?y.keyCode:0;if(n==13){c();return false}return this})}break}}a(d).append(j);a(h).append(d)});a("table thead",g.grid.hDiv).append(h);this.triggerToolbar=function(){c()};this.clearToolbar=function(){k()};this.toggleToolbar=function(){l()}})}})})(jQuery);(function(b){var a=null;b.fn.extend({searchGrid:function(c){c=b.extend({recreateFilter:false,drag:true,sField:"searchField",sValue:"searchString",sOper:"searchOper",sFilter:"filters",beforeShowSearch:null,afterShowSearch:null,onInitializeSearch:null,closeAfterSearch:false,closeOnEscape:false,multipleSearch:false,sopt:null,onClose:null},b.jgrid.search,c||{});return this.each(function(){var m=this;if(!m.grid){return}if(b.fn.searchFilter){var g="fbox_"+m.p.id;if(c.recreateFilter===true){b("#"+g).remove()}if(b("#"+g).html()!=null){if(b.isFunction(c.beforeShowSearch)){c.beforeShowSearch(b("#"+g))}f();if(b.isFunction(c.afterShowSearch)){c.afterShowSearch(b("#"+g))}}else{var o=[],v=jQuery("#"+m.p.id).getGridParam("colNames"),s=jQuery("#"+m.p.id).getGridParam("colModel"),u=["eq","ne","lt","le","gt","ge","bw","bn","in","ni","ew","en","cn","nc"],l,r,h;b.each(s,function(x,C){var z=(typeof C.search==="undefined")?true:C.search,y=(C.hidden===true),k=b.extend({},{text:v[x],value:C.index||C.name},this.searchoptions),w=(k.searchhidden===true)||true;if(typeof k.sopt=="undefined"){k.sopt=u}h=0;k.ops=[];for(l=0;l0){var q=jQuery.fn.searchFilter.defaults.operators;if(c.sopt!=null){q=[];h=0;for(l=0;c.sopt.length<0;l++){if((r=b.inArray(c.sopt[l],u))!=-1){q[h]={op:c.sopt[l],text:c.odata[r]};h++}}}b("").insertBefore("#gview_"+m.p.id);jQuery("#"+g).searchFilter(o,{groupOps:c.groupOps,operators:q,onClose:d,resetText:c.Reset,searchText:c.Find,windowTitle:c.caption,rulesText:c.rulesText,matchText:c.matchText,onSearch:t,onReset:n,stringResult:c.multipleSearch});b(".ui-widget-overlay","#"+g).remove();if(c.drag===true){b("#"+g+" table thead tr:first td:first").css("cursor","move");if(jQuery.fn.jqDrag){jQuery("#"+g).jqDrag(b("#"+g+" table thead tr:first td:first"))}else{try{b("#"+g).draggable({handle:jQuery("#"+g+" table thead tr:first td:first")})}catch(p){}}}if(c.multipleSearch===false){b(".ui-del, .ui-add, .ui-del, .ui-add-last, .matchText, .rulesText","#"+g).hide();b("select[name='groupOp']","#"+g).hide()}if(b.isFunction(c.onInitializeSearch)){c.onInitializeSearch(b("#"+g))}if(b.isFunction(c.beforeShowSearch)){c.beforeShowSearch(b("#"+g))}f();if(b.isFunction(c.afterShowSearch)){c.afterShowSearch(b("#"+g))}if(c.closeOnEscape===true){jQuery("#"+g).keydown(function(j){if(j.which==27){d(b("#"+g))}})}}}}function t(w){var e=(w!==undefined),k=jQuery("#"+m.p.id),j={};if(c.multipleSearch===false){j[c.sField]=w.rules[0].field;j[c.sValue]=w.rules[0].data;j[c.sOper]=w.rules[0].op}else{j[c.sFilter]=w}k[0].p.search=e;b.extend(k[0].p.postData,j);k[0].p.page=1;k.trigger("reloadGrid");if(c.closeAfterSearch){d(b("#"+g))}}function n(w){var e=(w!==undefined),k=jQuery("#"+m.p.id),j=[];k[0].p.search=e;if(c.multipleSearch===false){j[c.sField]=j[c.sValue]=j[c.sOper]=""}else{j[c.sFilter]=""}b.extend(k[0].p.postData,j);k[0].p.page=1;k.trigger("reloadGrid")}function d(e){if(c.onClose){var j=c.onClose(e);if(typeof j=="boolean"&&!j){return}}e.hide();b(".jqgrid-overlay","#gbox_"+m.p.id).hide()}function f(){b("#"+g).show();b(".jqgrid-overlay","#gbox_"+m.p.id).show();try{b(":input:visible","#"+g)[0].focus()}catch(e){}}})},editGridRow:function(c,d){d=b.extend({top:0,left:0,width:300,height:"auto",dataheight:"auto",modal:false,drag:true,resize:true,url:null,mtype:"POST",closeAfterAdd:false,clearAfterAdd:true,closeAfterEdit:false,reloadAfterSubmit:true,onInitializeForm:null,beforeInitData:null,beforeShowForm:null,afterShowForm:null,beforeSubmit:null,afterSubmit:null,onclickSubmit:null,afterComplete:null,onclickPgButtons:null,afterclickPgButtons:null,editData:{},recreateForm:false,jqModal:true,closeOnEscape:false,addedrow:"first",topinfo:"",bottominfo:"",saveicon:[],closeicon:[],savekey:[false,13],navkeys:[false,38,40],checkOnSubmit:false,checkOnUpdate:false,_savedData:{},onClose:null},b.jgrid.edit,d||{});a=d;return this.each(function(){var e=this;if(!e.grid||!c){return}var C=e.p.id,y="FrmGrid_"+C,u="TblGrid_"+C,h={themodal:"editmod"+C,modalhead:"edithd"+C,modalcontent:"editcnt"+C,scrollelm:y},D=b.isFunction(a.beforeShowForm)?a.beforeShowForm:false,O=b.isFunction(a.afterShowForm)?a.afterShowForm:false,N=b.isFunction(a.beforeInitData)?a.beforeInitData:false,o=b.isFunction(a.onInitializeForm)?a.onInitializeForm:false,I=null,J=1,q=0,v,E,F,R,H,B;if(c=="new"){c="_empty";d.caption=d.addCaption}else{d.caption=d.editCaption}if(d.recreateForm===true&&b("#"+h.themodal).html()!=null){b("#"+h.themodal).remove()}var k=true;if(d.checkOnUpdate&&d.jqModal&&!d.modal){k=false}if(b("#"+h.themodal).html()!=null){b(".ui-jqdialog-title","#"+h.modalhead).html(d.caption);b("#FormError","#"+u).hide();if(N){N(b("#"+y))}n(c,e,y);if(c=="_empty"){b("#pData, #nData","#"+u+"_2").hide()}else{b("#pData, #nData","#"+u+"_2").show()}if(d.processing===true){d.processing=false;b("#sData","#"+u).removeClass("ui-state-active")}if(b("#"+y).data("disabled")===true){b(".confirm","#"+h.themodal).hide();b("#"+y).data("disabled",false)}if(D){D(b("#"+y))}b("#"+h.themodal).data("onClose",a.onClose);viewModal("#"+h.themodal,{gbox:"#gbox_"+C,jqm:d.jqModal,jqM:false,closeoverlay:k,modal:d.modal});if(!k){b(".jqmOverlay").click(function(){if(!f()){return false}hideModal("#"+h.themodal,{gb:"#gbox_"+C,jqm:d.jqModal,onClose:a.onClose});return false})}if(O){O(b("#"+y))}}else{b(e.p.colModel).each(function(W){var X=this.formoptions;J=Math.max(J,X?X.colpos||0:0);q=Math.max(q,X?X.rowpos||0:0)});var r=isNaN(d.dataheight)?d.dataheight:d.dataheight+"px";var M,T=b("
").data("disabled",false),A=b("
");b(T).append(A);M=b("");M[0].rp=0;b(A).append(M);if(a.topinfo){M=b(""+a.topinfo+"");M[0].rp=0;b(A).append(M)}if(N){N(b("#"+y))}var z=s(c,e,A,J),l="",m="",g=""+d.bSubmit+"",t=""+d.bCancel+"";var Q="";if(a.bottominfo){Q+=""}Q+="
"+g+" "+t+"
"+a.bottominfo+"
";if(q>0){var x=[];b.each(b(A)[0].rows,function(W,X){x[W]=X});x.sort(function(X,W){if(X.rp>W.rp){return 1}if(X.rp").append(T).append(Q);createModal(h,P,d,"#gview_"+e.p.id,b("#gview_"+e.p.id)[0]);P=null;Q=null;jQuery("#"+h.themodal).keydown(function(W){if(b("#"+y).data("disabled")===true){return false}if(a.savekey[0]===true&&W.which==a.savekey[1]){b("#sData","#"+u+"_2").trigger("click");return false}if(W.which===27){if(!f()){return false}if(p){hideModal(this,{gb:d.gbox,jqm:d.jqModal,onClose:a.onClose})}return false}if(a.navkeys[0]===true){if(b("#id_g","#"+u).val()=="_empty"){return true}if(W.which==a.navkeys[1]){b("#pData","#"+u+"_2").trigger("click");return false}if(W.which==a.navkeys[2]){b("#nData","#"+u+"_2").trigger("click");return false}}});if(d.checkOnUpdate){b("a.ui-jqdialog-titlebar-close span","#"+h.themodal).removeClass("jqmClose");b("a.ui-jqdialog-titlebar-close","#"+h.themodal).unbind("click").click(function(){if(!f()){return false}hideModal("#"+h.themodal,{gb:"#gbox_"+C,jqm:d.jqModal,onClose:a.onClose});return false})}d.saveicon=b.extend([true,"left","ui-icon-disk"],d.saveicon);d.closeicon=b.extend([true,"left","ui-icon-close"],d.closeicon);if(d.saveicon[0]==true){b("#sData","#"+u+"_2").addClass(d.saveicon[1]=="right"?"fm-button-icon-right":"fm-button-icon-left").append("")}if(d.closeicon[0]==true){b("#cData","#"+u+"_2").addClass(d.closeicon[1]=="right"?"fm-button-icon-right":"fm-button-icon-left").append("")}if(a.checkOnSubmit||a.checkOnUpdate){g=""+d.bYes+"";m=""+d.bNo+"";t=""+d.bExit+"";var G,w=d.zIndex||999;w++;if(b.browser.msie&&b.browser.version==6){G=''}else{G=""}b("
"+d.saveData+"

"+g+m+t+"
").insertAfter("#"+y);b("#sNew","#"+h.themodal).click(function(){j([true,"",""]);b("#"+y).data("disabled",false);b(".confirm","#"+h.themodal).hide();return false});b("#nNew","#"+h.themodal).click(function(){b(".confirm","#"+h.themodal).hide();b("#"+y).data("disabled",false);setTimeout(function(){b(":input","#"+y)[0].focus()},0);return false});b("#cNew","#"+h.themodal).click(function(){b(".confirm","#"+h.themodal).hide();b("#"+y).data("disabled",false);hideModal("#"+h.themodal,{gb:"#gbox_"+C,jqm:d.jqModal,onClose:a.onClose});return false})}if(o){o(b("#"+y))}if(c=="_empty"){b("#pData,#nData","#"+u+"_2").hide()}else{b("#pData,#nData","#"+u+"_2").show()}if(D){D(b("#"+y))}b("#"+h.themodal).data("onClose",a.onClose);viewModal("#"+h.themodal,{gbox:"#gbox_"+C,jqm:d.jqModal,closeoverlay:k,modal:d.modal});if(!k){b(".jqmOverlay").click(function(){if(!f()){return false}hideModal("#"+h.themodal,{gb:"#gbox_"+C,jqm:d.jqModal,onClose:a.onClose});return false})}if(O){O(b("#"+y))}b(".fm-button","#"+h.themodal).hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")});b("#sData","#"+u+"_2").click(function(W){E={};R={};b("#FormError","#"+u).hide();U();if(E.id=="_empty"){j()}else{if(d.checkOnSubmit===true){H=b.extend({},E,R);B=K(H,a._savedData);if(B){b("#"+y).data("disabled",true);b(".confirm","#"+h.themodal).show()}else{j()}}else{j()}}return false});b("#cData","#"+u+"_2").click(function(W){if(!f()){return false}hideModal("#"+h.themodal,{gb:"#gbox_"+C,jqm:d.jqModal,onClose:a.onClose});return false});b("#nData","#"+u+"_2").click(function(W){if(!f()){return false}b("#FormError","#"+u).hide();var X=V();X[0]=parseInt(X[0]);if(X[0]!=-1&&X[1][X[0]+1]){if(b.isFunction(d.onclickPgButtons)){d.onclickPgButtons("next",b("#"+y),X[1][X[0]])}n(X[1][X[0]+1],e,y);b(e).setSelection(X[1][X[0]+1]);if(b.isFunction(d.afterclickPgButtons)){d.afterclickPgButtons("next",b("#"+y),X[1][X[0]+1])}L(X[0]+1,X[1].length-1)}return false});b("#pData","#"+u+"_2").click(function(X){if(!f()){return false}b("#FormError","#"+u).hide();var W=V();if(W[0]!=-1&&W[1][W[0]-1]){if(b.isFunction(d.onclickPgButtons)){d.onclickPgButtons("prev",b("#"+y),W[1][W[0]])}n(W[1][W[0]-1],e,y);b(e).setSelection(W[1][W[0]-1]);if(b.isFunction(d.afterclickPgButtons)){d.afterclickPgButtons("prev",b("#"+y),W[1][W[0]-1])}L(W[0]-1,W[1].length-1)}return false})}var S=V();L(S[0],S[1].length-1);function L(X,Y,W){if(X==0){b("#pData","#"+u+"_2").addClass("ui-state-disabled")}else{b("#pData","#"+u+"_2").removeClass("ui-state-disabled")}if(X==Y){b("#nData","#"+u+"_2").addClass("ui-state-disabled")}else{b("#nData","#"+u+"_2").removeClass("ui-state-disabled")}}function V(){var X=b(e).getDataIDs(),W=b("#id_g","#"+u).val(),Y=b.inArray(W,X);return[Y,X]}function f(){var W=true;b("#FormError","#"+u).hide();if(a.checkOnUpdate){E={};R={};U();H=b.extend({},E,R);B=K(H,a._savedData);if(B){b("#"+y).data("disabled",true);b(".confirm","#"+h.themodal).show();W=false}}return W}function U(){b(".FormElement","#"+u).each(function(X){switch(b(this).get(0).type){case"checkbox":if(b(this).attr("checked")){E[this.name]=b(this).val()}else{var W=b(this).attr("offval");E[this.name]=W;R[this.name]=W}break;case"select-one":E[this.name]=b("option:selected",this).val();R[this.name]=b("option:selected",this).text();break;case"select-multiple":E[this.name]=b(this).val();if(E[this.name]){E[this.name]=E[this.name].join(",")}else{E[this.name]=""}var Y=[];b("option:selected",this).each(function(Z,aa){Y[Z]=b(aa).text()});R[this.name]=Y.join(",");break;case"password":case"text":case"textarea":case"button":E[this.name]=b(this).val();E[this.name]=!e.p.autoencode?E[this.name]:b.jgrid.htmlEncode(E[this.name]);break}});return true}function s(Z,af,ac,ak){var W,X,ah,ai=0,am,an,ag,al=[],ad=false,ae,Y,aa="  ",ab="";for(var aj=1;aj<=ak;aj++){ab+=aa}if(Z!="_empty"){ad=b(af).getInd(Z)}b(af.p.colModel).each(function(ar){W=this.name;if(this.editrules&&this.editrules.edithidden==true){X=false}else{X=this.hidden===true?true:false}an=X?"style='display:none'":"";if(W!=="cb"&&W!=="subgrid"&&this.editable===true&&W!=="rn"){if(ad===false){am=""}else{if(W==af.p.ExpandColumn&&af.p.treeGrid===true){am=b("td:eq("+ar+")",af.rows[ad]).text()}else{try{am=b.unformat(b("td:eq("+ar+")",af.rows[ad]),{colModel:this},ar)}catch(ap){am=b("td:eq("+ar+")",af.rows[ad]).html()}}}var aq=b.extend({},this.editoptions||{},{id:W,name:W});frmopt=b.extend({},{elmprefix:"",elmsuffix:"",rowabove:false,rowcontent:""},this.formoptions||{}),ae=parseInt(frmopt.rowpos)||ai+1,Y=parseInt((parseInt(frmopt.colpos)||1)*2);if(Z=="_empty"&&aq.defaultValue){am=b.isFunction(aq.defaultValue)?aq.defaultValue():aq.defaultValue}if(!this.edittype){this.edittype="text"}ag=createEl(this.edittype,aq,am);if(am==""&&this.edittype=="checkbox"){am=b(ag).attr("offval")}if(a.checkOnSubmit||a.checkOnUpdate){a._savedData[W]=am}b(ag).addClass("FormElement");ah=b(ac).find("tr[rowpos="+ae+"]");if(frmopt.rowabove){var at=b(""+frmopt.rowcontent+"");b(ac).append(at);at[0].rp=ae}if(ah.length==0){ah=b("").addClass("FormData").attr("id","tr_"+W);b(ah).append(ab);b(ac).append(ah);ah[0].rp=ae}b("td:eq("+(Y-2)+")",ah[0]).html(typeof frmopt.label==="undefined"?af.p.colNames[ar]:frmopt.label);b("td:eq("+(Y-1)+")",ah[0]).append(frmopt.elmprefix).append(ag).append(frmopt.elmsuffix);al[ai]=ar;ai++}});if(ai>0){var ao=b("");ao[0].rp=ai+999;b(ac).append(ao);if(a.checkOnSubmit||a.checkOnUpdate){a._savedData.id=Z}}return al}function n(X,ad,Z){var ai,af,aa=0,ae,ac,W,ab,ag;if(a.checkOnSubmit||a.checkOnUpdate){a._savedData={};a._savedData.id=X}var ah=ad.p.colModel;if(X=="_empty"){b(ah).each(function(aj){ai=this.name.replace(".","\\.");W=b.extend({},this.editoptions||{});ac=b("#"+ai,"#"+Z);if(ac[0]!=null){ab="";if(W.defaultValue){ab=b.isFunction(W.defaultValue)?W.defaultValue():W.defaultValue;if(ac[0].type=="checkbox"){ag=ab.toLowerCase();if(ag.search(/(false|0|no|off|undefined)/i)<0&&ag!==""){ac[0].checked=true;ac[0].defaultChecked=true;ac[0].value=ab}else{ac.attr({checked:"",defaultChecked:""})}}else{ac.val(ab)}}else{if(ac[0].type=="checkbox"){ac[0].checked=false;ac[0].defaultChecked=false;ab=b(ac).attr("offval")}else{if(ac[0].type.substr(0,6)=="select"){ac[0].selectedIndex=0}else{ac.val(ab)}}}if(a.checkOnSubmit===true||a.checkOnUpdate){a._savedData[ai]=ab}}});b("#id_g","#"+Z).val("_empty");return}var Y=b(ad).getInd(X,true);if(!Y){return}b("td",Y).each(function(ak){ai=ah[ak].name.replace(".","\\.");if(ah[ak].editrules&&ah[ak].editrules.edithidden===true){af=false}else{af=ah[ak].hidden===true?true:false}if(ai!=="cb"&&ai!=="subgrid"&&ah[ak].editable===true){if(ai==ad.p.ExpandColumn&&ad.p.treeGrid===true){ae=b(this).text()}else{try{ae=b.unformat(this,{colModel:ah[ak]},ak)}catch(aj){ae=b(this).html()}}if(a.checkOnSubmit===true||a.checkOnUpdate){a._savedData[ai]=ae}switch(ah[ak].edittype){case"password":case"text":case"button":case"image":ae=b.jgrid.htmlDecode(ae);b("#"+ai,"#"+Z).val(ae);break;case"textarea":if(ae==" "||ae==" "||(ae.length==1&&ae.charCodeAt(0)==160)){ae=""}b("#"+ai,"#"+Z).val(ae);break;case"select":b("#"+ai+" option","#"+Z).each(function(al){if(!ah[ak].editoptions.multiple&&(ae==b(this).text()||ae==b(this).val())){this.selected=true}else{if(ah[ak].editoptions.multiple){if(b.inArray(b(this).text(),ae.split(","))>-1||b.inArray(b(this).val(),ae.split(","))>-1){this.selected=true}else{this.selected=false}}else{this.selected=false}}});break;case"checkbox":ae=ae.toLowerCase();if(ae.search(/(false|0|no|off|undefined)/i)<0&&ae!==""){b("#"+ai,"#"+Z).attr("checked",true);b("#"+ai,"#"+Z).attr("defaultChecked",true)}else{b("#"+ai,"#"+Z).attr("checked",false);b("#"+ai,"#"+Z).attr("defaultChecked","")}break}aa++}});if(aa>0){b("#id_g","#"+u).val(X)}}function j(){var Z,X=[true,"",""],W={};for(var Y in E){X=checkValues(E[Y],Y,e);if(X[0]==false){break}}if(X[0]){if(b.isFunction(a.onclickSubmit)){W=a.onclickSubmit(a,E)||{}}if(b.isFunction(a.beforeSubmit)){X=a.beforeSubmit(E,b("#"+y))}}v=a.url?a.url:e.p.editurl;if(X[0]){if(!v){X[0]=false;X[1]+=" "+b.jgrid.errors.nourl}}if(X[0]===false){b("#FormError>td","#"+u).html(X[1]);b("#FormError","#"+u).show();return}if(!d.processing){d.processing=true;b("#sData","#"+u+"_2").addClass("ui-state-active");E.oper=E.id=="_empty"?"add":"edit";E=b.extend(E,a.editData,W);b.ajax({url:v,type:a.mtype,data:E,complete:function(ab,aa){if(aa!="success"){X[0]=false;if(b.isFunction(a.errorTextFormat)){X[1]=a.errorTextFormat(ab)}else{X[1]=aa+" Status: '"+ab.statusText+"'. Error code: "+ab.status}}else{if(b.isFunction(a.afterSubmit)){X=a.afterSubmit(ab,E)}}if(X[0]===false){b("#FormError>td","#"+u).html(X[1]);b("#FormError","#"+u).show()}else{E=b.extend(E,R);if(E.id=="_empty"){if(!X[2]){X[2]=parseInt(e.p.records)+1}E.id=X[2];if(a.closeAfterAdd){if(a.reloadAfterSubmit){b(e).trigger("reloadGrid")}else{b(e).addRowData(X[2],E,d.addedrow);b(e).setSelection(X[2])}hideModal("#"+h.themodal,{gb:"#gbox_"+C,jqm:d.jqModal,onClose:a.onClose})}else{if(a.clearAfterAdd){if(a.reloadAfterSubmit){b(e).trigger("reloadGrid")}else{b(e).addRowData(X[2],E,d.addedrow)}n("_empty",e,y)}else{if(a.reloadAfterSubmit){b(e).trigger("reloadGrid")}else{b(e).addRowData(X[2],E,d.addedrow)}}}}else{if(a.reloadAfterSubmit){b(e).trigger("reloadGrid");if(!a.closeAfterEdit){setTimeout(function(){b(e).setSelection(E.id)},1000)}}else{if(e.p.treeGrid===true){b(e).setTreeRow(E.id,E)}else{b(e).setRowData(E.id,E)}}if(a.closeAfterEdit){hideModal("#"+h.themodal,{gb:"#gbox_"+C,jqm:d.jqModal,onClose:a.onClose})}}if(b.isFunction(a.afterComplete)){Z=ab;setTimeout(function(){a.afterComplete(Z,E,b("#"+y));Z=null},500)}}d.processing=false;if(a.checkOnSubmit||a.checkOnUpdate){b("#"+y).data("disabled",false);if(a._savedData.id!="_empty"){a._savedData=E}}b("#sData","#"+u+"_2").removeClass("ui-state-active");try{b(":input:visible","#"+y)[0].focus()}catch(ac){}},error:function(ac,aa,ab){b("#FormError>td","#"+u).html(aa+" : "+ab);b("#FormError","#"+u).show();d.processing=false;b("#"+y).data("disabled",false);b("#sData","#"+u+"_2").removeClass("ui-state-active")}})}}function K(Z,W){var X=false,Y;for(Y in Z){if(Z[Y]!=W[Y]){X=true;break}}return X}})},viewGridRow:function(c,d){d=b.extend({top:0,left:0,width:0,height:"auto",dataheight:"auto",modal:false,drag:true,resize:true,jqModal:true,closeOnEscape:false,labelswidth:"30%",closeicon:[],navkeys:[false,38,40],onClose:null},b.jgrid.view,d||{});return this.each(function(){var x=this;if(!x.grid||!c){return}if(!d.imgpath){d.imgpath=x.p.imgpath}var r=x.p.id,z="ViewGrid_"+r,s="ViewTbl_"+r,j={themodal:"viewmod"+r,modalhead:"viewhd"+r,modalcontent:"viewcnt"+r,scrollelm:z},g=1,e=0;if(b("#"+j.themodal).html()!=null){b(".ui-jqdialog-title","#"+j.modalhead).html(d.caption);b("#FormError","#"+s).hide();m(c,x);viewModal("#"+j.themodal,{gbox:"#gbox_"+r,jqm:d.jqModal,jqM:false,modal:d.modal});k()}else{b(x.p.colModel).each(function(D){var E=this.formoptions;g=Math.max(g,E?E.colpos||0:0);e=Math.max(e,E?E.rowpos||0:0)});var y=isNaN(d.dataheight)?d.dataheight:d.dataheight+"px";var w,B=b("
"),l=b("
");b(B).append(l);var v=n(c,x,l,g),t="",u="",C=""+d.bClose+"";if(e>0){var f=[];b.each(b(l)[0].rows,function(D,E){f[D]=E});f.sort(function(E,D){if(E.rp>D.rp){return 1}if(E.rp").append(B).append("
"+C+"
");createModal(j,A,d,"#gview_"+x.p.id,b("#gview_"+x.p.id)[0]);A=null;jQuery("#"+j.themodal).keydown(function(D){if(D.which===27){if(q){hideModal(this,{gb:d.gbox,jqm:d.jqModal,onClose:d.onClose})}return false}if(d.navkeys[0]===true){if(D.which===d.navkeys[1]){b("#pData","#"+s+"_2").trigger("click");return false}if(D.which===d.navkeys[2]){b("#nData","#"+s+"_2").trigger("click");return false}}});d.closeicon=b.extend([true,"left","ui-icon-close"],d.closeicon);if(d.closeicon[0]==true){b("#cData","#"+s+"_2").addClass(d.closeicon[1]=="right"?"fm-button-icon-right":"fm-button-icon-left").append("")}viewModal("#"+j.themodal,{gbox:"#gbox_"+r,jqm:d.jqModal,modal:d.modal});b(".fm-button:not(.ui-state-disabled)","#"+s+"_2").hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")});k();b("#cData","#"+s+"_2").click(function(D){hideModal("#"+j.themodal,{gb:"#gbox_"+r,jqm:d.jqModal,onClose:d.onClose});return false});b("#nData","#"+s+"_2").click(function(D){b("#FormError","#"+s).hide();var E=h();E[0]=parseInt(E[0]);if(E[0]!=-1&&E[1][E[0]+1]){if(b.isFunction(d.onclickPgButtons)){d.onclickPgButtons("next",b("#"+z),E[1][E[0]])}m(E[1][E[0]+1],x);b(x).setSelection(E[1][E[0]+1]);if(b.isFunction(d.afterclickPgButtons)){d.afterclickPgButtons("next",b("#"+z),E[1][E[0]+1])}o(E[0]+1,E[1].length-1)}k();return false});b("#pData","#"+s+"_2").click(function(E){b("#FormError","#"+s).hide();var D=h();if(D[0]!=-1&&D[1][D[0]-1]){if(b.isFunction(d.onclickPgButtons)){d.onclickPgButtons("prev",b("#"+z),D[1][D[0]])}m(D[1][D[0]-1],x);b(x).setSelection(D[1][D[0]-1]);if(b.isFunction(d.afterclickPgButtons)){d.afterclickPgButtons("prev",b("#"+z),D[1][D[0]-1])}o(D[0]-1,D[1].length-1)}k();return false})}function k(){if(d.closeOnEscape===true||d.navkeys[0]===true){setTimeout(function(){b(".ui-jqdialog-titlebar-close","#"+j.modalhead).focus()},0)}}var p=h();o(p[0],p[1].length-1);function o(E,F,D){if(E==0){b("#pData","#"+s+"_2").addClass("ui-state-disabled")}else{b("#pData","#"+s+"_2").removeClass("ui-state-disabled")}if(E==F){b("#nData","#"+s+"_2").addClass("ui-state-disabled")}else{b("#nData","#"+s+"_2").removeClass("ui-state-disabled")}}function h(){var E=b(x).getDataIDs(),D=b("#id_g","#"+s).val(),F=b.inArray(D,E);return[F,E]}function n(J,P,N,V){var F,I,Q,Y,D,T=0,X,Z,W=[],O=false,L="  ",M="",G="  ",K=["integer","number","currency"],S=0,R=0,H,E;for(var U=1;U<=V;U++){M+=U==1?L:G}b(P.p.colModel).each(function(ab){if(this.editrules&&this.editrules.edithidden===true){I=false}else{I=this.hidden===true?true:false}if(!I&&this.align==="right"){if(this.formatter&&b.inArray(this.formatter,K)!==-1){S=Math.max(S,parseInt(this.width,10))}else{R=Math.max(R,parseInt(this.width,10))}}});H=S!==0?S:R!==0?R:0;O=b(P).getInd(J);b(P.p.colModel).each(function(ac){F=this.name;E=false;if(this.editrules&&this.editrules.edithidden===true){I=false}else{I=this.hidden===true?true:false}Z=I?"style='display:none'":"";if(F!=="cb"&&F!=="subgrid"&&this.editable===true){if(O===false){X=""}else{if(F==P.p.ExpandColumn&&P.p.treeGrid===true){X=b("td:eq("+ac+")",P.rows[O]).text()}else{X=b("td:eq("+ac+")",P.rows[O]).html()}}E=this.align==="right"&&H!==0?true:false;var ab=b.extend({},this.editoptions||{},{id:F,name:F}),ag=b.extend({},{rowabove:false,rowcontent:""},this.formoptions||{}),ad=parseInt(ag.rowpos)||T+1,af=parseInt((parseInt(ag.colpos)||1)*2);if(ag.rowabove){var ae=b(""+ag.rowcontent+"");b(N).append(ae);ae[0].rp=ad}Q=b(N).find("tr[rowpos="+ad+"]");if(Q.length==0){Q=b("").addClass("FormData").attr("id","trv_"+F);b(Q).append(M);b(N).append(Q);Q[0].rp=ad}b("td:eq("+(af-2)+")",Q[0]).html(""+(typeof ag.label==="undefined"?P.p.colNames[ac]:ag.label)+"");b("td:eq("+(af-1)+")",Q[0]).append(""+X+"").attr("id","v_"+F);if(E){b("td:eq("+(af-1)+") span",Q[0]).css({"text-align":"right",width:H+"px"})}W[T]=ac;T++}});if(T>0){var aa=b("");aa[0].rp=T+99;b(N).append(aa)}return W}function m(H,J){var D,K,G=0,F,E,I;I=b(J).getInd(H,true);if(!I){return}b("td",I).each(function(L){D=J.p.colModel[L].name.replace(".","\\.");if(J.p.colModel[L].editrules&&J.p.colModel[L].editrules.edithidden===true){K=false}else{K=J.p.colModel[L].hidden===true?true:false}if(D!=="cb"&&D!=="subgrid"&&J.p.colModel[L].editable===true){if(D==J.p.ExpandColumn&&J.p.treeGrid===true){F=b(this).text()}else{F=b(this).html()}E=b.extend({},J.p.colModel[L].editoptions||{});D="v_"+D;b("#"+D+" span","#"+s).html(F);if(K){b("#"+D,"#"+s).parents("tr:first").hide()}G++}});if(G>0){b("#id_g","#"+s).val(H)}}})},delGridRow:function(c,d){d=b.extend({top:0,left:0,width:240,height:"auto",dataheight:"auto",modal:false,drag:true,resize:true,url:"",mtype:"POST",reloadAfterSubmit:true,beforeShowForm:null,afterShowForm:null,beforeSubmit:null,onclickSubmit:null,afterSubmit:null,jqModal:true,closeOnEscape:false,delData:{},delicon:[],cancelicon:[],onClose:null},b.jgrid.del,d||{});a=d;return this.each(function(){var m=this;if(!m.grid){return}if(!c){return}var n=typeof d.beforeShowForm==="function"?true:false,g=typeof d.afterShowForm==="function"?true:false,e=m.p.id,f={},k="DelTbl_"+e,h={themodal:"delmod"+e,modalhead:"delhd"+e,modalcontent:"delcnt"+e,scrollelm:k};if(isArray(c)){c=c.join()}if(b("#"+h.themodal).html()!=null){b("#DelData>td","#"+k).text(c);b("#DelError","#"+k).hide();if(d.processing===true){d.processing=false;b("#dData","#"+k).removeClass("ui-state-active")}if(n){d.beforeShowForm(b("#"+k))}viewModal("#"+h.themodal,{gbox:"#gbox_"+e,jqm:d.jqModal,jqM:false,modal:d.modal});if(g){d.afterShowForm(b("#"+k))}}else{var o=isNaN(d.dataheight)?d.dataheight:d.dataheight+"px";var l="
";l+="";l+="";l+="";l+='";l+="
'+d.msg+"
 
";var j=""+d.bSubmit+"",p=""+d.bCancel+"";l+="
"+j+" "+p+"
";d.gbox="#gbox_"+e;createModal(h,l,d,"#gview_"+m.p.id,b("#gview_"+m.p.id)[0]);b(".fm-button","#"+k+"_2").hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")});d.delicon=b.extend([true,"left","ui-icon-scissors"],d.delicon);d.cancelicon=b.extend([true,"left","ui-icon-cancel"],d.cancelicon);if(d.delicon[0]==true){b("#dData","#"+k+"_2").addClass(d.delicon[1]=="right"?"fm-button-icon-right":"fm-button-icon-left").append("")}if(d.cancelicon[0]==true){b("#eData","#"+k+"_2").addClass(d.cancelicon[1]=="right"?"fm-button-icon-right":"fm-button-icon-left").append("")}b("#dData","#"+k+"_2").click(function(t){var r=[true,""];f={};var s=b("#DelData>td","#"+k).text();if(typeof d.onclickSubmit==="function"){f=d.onclickSubmit(a)||{}}if(typeof d.beforeSubmit==="function"){r=d.beforeSubmit(s)}var q=a.url?a.url:m.p.editurl;if(!q){r[0]=false;r[1]+=" "+b.jgrid.errors.nourl}if(r[0]===false){b("#DelError>td","#"+k).html(r[1]);b("#DelError","#"+k).show()}else{if(!d.processing){d.processing=true;b(this).addClass("ui-state-active");var u=b.extend({oper:"del",id:s},d.delData,f);b.ajax({url:q,type:d.mtype,data:u,complete:function(y,w){if(w!="success"){r[0]=false;if(b.isFunction(a.errorTextFormat)){r[1]=a.errorTextFormat(y)}else{r[1]=w+" Status: '"+y.statusText+"'. Error code: "+y.status}}else{if(typeof a.afterSubmit==="function"){r=a.afterSubmit(y,s)}}if(r[0]===false){b("#DelError>td","#"+k).html(r[1]);b("#DelError","#"+k).show()}else{if(a.reloadAfterSubmit){if(m.p.treeGrid){b(m).setGridParam({treeANode:0,datatype:m.p.treedatatype})}b(m).trigger("reloadGrid")}else{var v=[];v=s.split(",");if(m.p.treeGrid===true){try{b(m).delTreeNode(v[0])}catch(z){}}else{for(var x=0;xtd","#"+k).html(v+" : "+w);b("#DelError","#"+k).show();d.processing=false;b("#dData","#"+k+"_2").removeClass("ui-state-active")}})}}return false});b("#eData","#"+k+"_2").click(function(q){hideModal("#"+h.themodal,{gb:"#gbox_"+e,jqm:d.jqModal,onClose:a.onClose});return false});if(n){d.beforeShowForm(b("#"+k))}viewModal("#"+h.themodal,{gbox:"#gbox_"+e,jqm:d.jqModal,modal:d.modal});if(g){d.afterShowForm(b("#"+k))}}if(d.closeOnEscape===true){setTimeout(function(){b(".ui-jqdialog-titlebar-close","#"+h.modalhead).focus()},0)}})},navGrid:function(f,h,e,g,d,c,j){h=b.extend({edit:true,editicon:"ui-icon-pencil",add:true,addicon:"ui-icon-plus",del:true,delicon:"ui-icon-trash",search:true,searchicon:"ui-icon-search",refresh:true,refreshicon:"ui-icon-refresh",refreshstate:"firstpage",view:false,viewicon:"ui-icon-document",position:"left",closeOnEscape:true,afterRefresh:null},b.jgrid.nav,h||{});return this.each(function(){var k={themodal:"alertmod",modalhead:"alerthd",modalcontent:"alertcnt"},o=this,n,t,p,l;if(!o.grid){return}if(b("#"+k.themodal).html()==null){if(typeof window.innerWidth!="undefined"){n=window.innerWidth,t=window.innerHeight}else{if(typeof document.documentElement!="undefined"&&typeof document.documentElement.clientWidth!="undefined"&&document.documentElement.clientWidth!=0){n=document.documentElement.clientWidth,t=document.documentElement.clientHeight}else{n=1024;t=768}}createModal(k,"
"+h.alerttext+"
",{gbox:"#gbox_"+o.p.id,jqModal:true,drag:true,resize:true,caption:h.alertcap,top:t/2-25,left:n/2-100,width:200,height:"auto",closeOnEscape:h.closeOnEscape},"","",true)}var q,r=b(""),s="",m=b(o.p.pager).attr("id")||"pager";if(h.add){g=g||{};q=b("");b(q).append("
"+h.addtext+"
");b("tr",r).append(q);b(q,r).attr({title:h.addtitle||"",id:g.id||"add_"+o.p.id}).click(function(){if(typeof h.addfunc=="function"){h.addfunc()}else{b(o).editGridRow("new",g)}return false}).hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")});q=null}if(h.edit){q=b("");e=e||{};b(q).append("
"+h.edittext+"
");b("tr",r).append(q);b(q,r).attr({title:h.edittitle||"",id:e.id||"edit_"+o.p.id}).click(function(){var u=o.p.selrow;if(u){if(typeof h.editfunc=="function"){h.editfunc(u)}else{b(o).editGridRow(u,e)}}else{viewModal("#"+k.themodal,{gbox:"#gbox_"+o.p.id,jqm:true});b("#jqg_alrt").focus()}return false}).hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")});q=null}if(h.view){q=b("");j=j||{};b(q).append("
"+h.viewtext+"
");b("tr",r).append(q);b(q,r).attr({title:h.viewtitle||"",id:j.id||"view_"+o.p.id}).click(function(){var u=o.p.selrow;if(u){b(o).viewGridRow(u,j)}else{viewModal("#"+k.themodal,{gbox:"#gbox_"+o.p.id,jqm:true});b("#jqg_alrt").focus()}return false}).hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")});q=null}if(h.del){q=b("");d=d||{};b(q).append("
"+h.deltext+"
");b("tr",r).append(q);b(q,r).attr({title:h.deltitle||"",id:d.id||"del_"+o.p.id}).click(function(){var u;if(o.p.multiselect){u=o.p.selarrrow;if(u.length==0){u=null}}else{u=o.p.selrow}if(u){b(o).delGridRow(u,d)}else{viewModal("#"+k.themodal,{gbox:"#gbox_"+o.p.id,jqm:true});b("#jqg_alrt").focus()}return false}).hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")});q=null}if(h.add||h.edit||h.del||h.view){b("tr",r).append(s)}if(h.search){q=b("");c=c||{};b(q).append("
"+h.searchtext+"
");b("tr",r).append(q);b(q,r).attr({title:h.searchtitle||"",id:c.id||"search_"+o.p.id}).click(function(){b(o).searchGrid(c);return false}).hover(function(){b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")});q=null}if(h.refresh){q=b("");b(q).append("
"+h.refreshtext+"
");b("tr",r).append(q);b(q,r).attr({title:h.refreshtitle||"",id:"refresh_"+o.p.id}).click(function(){o.p.search=false;try{var v=o.p.id;b("#fbox_"+v).searchFilter().reset()}catch(w){}switch(h.refreshstate){case"firstpage":o.p.page=1;b(o).trigger("reloadGrid");break;case"current":var u=o.p.multiselect===true?o.p.selarrrow:o.p.selrow;b(o).trigger("reloadGrid");setTimeout(function(){if(o.p.multiselect===true){if(u.length>0){for(var x=0;x