(function(){"use strict";u8.Crm.FieldTableWalker=function(n){this._columnCount=n||3;this._row=new Array(this._columnCount);this.nextRow();this.columnIndex=this.rowIndex=0;this._rowspan=this._colspan=1};$.extend(u8.Crm.FieldTableWalker.prototype,{find:function(n,t){this._setSpans(n,t);while((this.columnIndex=this._findInRow(this._colspan))<0){this.nextRow()}this._lastOperation="find"},walk:function(n,t){if(arguments.length>0){this._setSpans(n,t)}if(this._lastOperation=="walk"){this.find(this._colspan,this._rowspan)}for(var i=this.columnIndex;i<this.columnIndex+this._colspan;i++){this._row[i]=this._rowspan}this.columnIndex+=this._colspan;this.find(1,1);this._lastOperation="walk"},nextRow:function(n){var t=-1;var i=[];var s=this;function o(){if(n){return i.length<s._columnCount}return t<0}do{for(var h=0;h<this._columnCount;h++){if(this._row[h]>1){this._row[h]--}else{this._row[h]=0;if(t<0){t=h}if(i.indexOf(h)<0){i.push(h)}}}this.rowIndex++}while(o());this.columnIndex=n?0:t},_setSpans:function(n,t){this._colspan=Math.min(n||1,this._columnCount);this._rowspan=t||1},_findInRow:function(n){var t=this._row;var i=undefined;var s=0;for(var o=this.columnIndex;o<t.length;o++){var h=t[o]===0;i=h&&s===0?o:i;s=h?s+1:0;if(s==n){return i}}return-1}})})();