function PatternRepeater(e,c,b,a,f,d){this.existingContainer=b;this.clonePattern=e;this.cloneContainer=c;this.currIndex=0;this.patternIndexReplace=a;this.displayStyle=f;this.positionStyle=d}PatternRepeater.prototype.AppendItem=function(a,d,e){if(a>-1&&a==this.currIndex||a==-1){if(a==-1)a=this.currIndex;a++;var f=document.getElementById(this.clonePattern),b=f.cloneNode(true);this.AppendRowIndex(b,a);b.style.visibility="visible";b.style.display=this.displayStyle;b.style.position=this.positionStyle;var c=document.getElementById(this.cloneContainer);if(c.tagName=="TABLE")c=this.GetChildNodesByTagName(c,"TBODY")[0];c.appendChild(b);this.currIndex=a;d!=null&&d(a,e);return b}};PatternRepeater.prototype.AppendItemWithValues=function(a,e,f,j,h,i){if(a>-1&&a==this.currIndex||a==-1){if(a==-1)a=this.currIndex;a++;var g=document.getElementById(this.clonePattern),b=g.cloneNode(true);this.AppendRowIndex(b,a);b.style.visibility="visible";b.style.display=this.displayStyle;b.style.position=this.positionStyle;if(b.childElementCount>0){var d=b.getElementsByTagName("input");d[0].value=j;d[1].value=h;d[3].value=i}var c=document.getElementById(this.cloneContainer);if(c.tagName=="TABLE")c=this.GetChildNodesByTagName(c,"TBODY")[0];c.appendChild(b);this.currIndex=a;e!=null&&e(a,f);return b}};PatternRepeater.prototype.GetChildNodesByTagName=function(e,b){b=b.toUpperCase();for(var a=[],c=0;c<e.childNodes.length;c++){var d=e.childNodes[c];if(d.tagName==b)a[a.length]=d}return a};PatternRepeater.prototype.RemoveItem=function(b){var a=document.getElementById(this.clonePattern+b);a&&RemoveNode(a);a=document.getElementById(this.existingContainer+"_"+b);a&&RemoveNode(a)};function RemoveNode(a){var b=navigator.userAgent.toLowerCase();if(b.indexOf("firefox")!=-1)a.parentNode.removeChild(a);else a.removeNode(true)}PatternRepeater.prototype.AppendRowIndex=function(a,c){if(!document.all){var g=document.createElement("table");g.appendChild(a)}a.id=a.id+c;a.name=a.name+c;for(var d=0;d<a.childNodes.length;d++){var e=a.childNodes[d],b=a;if(e.tagName=="TD")b=e;if(b.innerHTML&&b.innerHTML.indexOf(this.patternIndexReplace)>0){var f=new RegExp(this.patternIndexReplace,"g");b.innerHTML=b.innerHTML.replace(f,c)}}}
