appsRepeatable={j:{},n:{},init:function(a){this.j.id=this.n.id=jQuery("#"+a).children().eq(0).children("input").size();that=this;jQuery("#"+a).children().each(function(b,d){if(d.id){divTag=jQuery("#"+d.id);if(divTag.attr("class")=="zfsub"){divTag.children("input").each(function(f,e){inputTag=jQuery("#"+e.id);inputTag.attr("pos",f+1);if(inputTag.attr("name").indexOf("[]")<0){inputTag.attr("name",inputTag.attr("name")+"[]")}inputTag.bind("keydown",that,function(g){return g.data.tab(g)})})}}})},del:function(b,a){if(this.n.id==1){alert("You can't remove this element");return}this.n.id--;item=jQuery("#"+b);jQuery("#"+b).children().each(function(d,e){if(e.id){divTag=jQuery("#"+e.id);c=divTag.children("input").size();if(divTag.attr("class")=="zfsub"){divTag.children("input").each(function(g,f){inputTag=jQuery("#"+f.id);if(inputTag.attr("pos")==a||(a==1&&g==0)){if(g>0){inputTag.prev().remove()}else{inputTag.next().remove()}inputTag.remove()}})}if(divTag.attr("class")=="zftablecontrol"){divTag.children("input").each(function(g,f){inputTag=jQuery("#"+f.id);if(inputTag.attr("pos")==a||(a==1&&g==0)){if(g>0){inputTag.prev().remove()}else{inputTag.next().remove()}inputTag.remove()}})}}})},add:function(d,b){this.j.id++;this.n.id++;that=this;var a="";item=jQuery("#"+d);jQuery("#"+d).children().each(function(e,f){if(f.id){divTag=jQuery("#"+f.id);if(divTag.attr("class")=="zfsub"){divTag.children("input").each(function(h,g){inputTag=jQuery("#"+g.id);if(inputTag.attr("pos")==b||(b==1&&h==0)){newInputTag=jQuery("<input>");key=divTag.attr("id")+"_"+that.j.id;newInputTag.attr("id",divTag.attr("id")+"_"+that.j.id);newInputTag.attr("pos",that.j.id);newInputTag.attr("class",inputTag.attr("class"));newInputTag.attr("type",inputTag.attr("type"));newInputTag.bind("keydown",that,function(i){return i.data.tab(i)});name=inputTag.attr("name");newInputTag.attr("name",name);if(inputTag.attr("size")>0){newInputTag.attr("size",inputTag.attr("size"))}if(inputTag.attr("maxlength")>0){newInputTag.attr("maxlength",inputTag.attr("maxlength"))}inputTag.after(newInputTag);newInputTag.before(jQuery("<br />"));if(e==0){newInputTag.focus()}}})}if(divTag.attr("class")=="zftablecontrol"){divTag.children("input").each(function(h,g){inputTag=jQuery("#"+g.id);if(inputTag.attr("pos")==b||(b==1&&h==0)){newInputTag=jQuery("<input>");newInputTag.attr("id",divTag.attr("id")+"_"+that.j.id);if(inputTag.attr("value")=="+"){action="appsRepeatable.add('"+d+"',"+that.j.id+")"}else{action="appsRepeatable.del('"+d+"',"+that.j.id+")"}newInputTag.attr("onclick",action);newInputTag.attr("pos",that.j.id);newInputTag.attr("class",inputTag.attr("class"));newInputTag.attr("value",inputTag.attr("value"));newInputTag.attr("type",inputTag.attr("type"));inputTag.after(newInputTag);newInputTag.before(jQuery("<br />"))}})}}})},tab:function(b){var a=jQuery(b.target);pos=a.attr("pos");if(b.keyCode=="9"&&!b.shiftKey){p=a.parent();s=p.next();if(s.attr("class")=="zfsub"){s.children("input").each(function(e,d){c=jQuery("#"+d.id);if(c.attr("pos")==pos){c.focus()}})}else{s=p.parent().children().eq(0);s.children("input").each(function(e,d){c=jQuery("#"+d.id);if(c.attr("pos")==pos){if(c.next()&&c.next().next()){c.next().next().focus()}else{return true}}})}return false}if(b.keyCode=="9"&&b.shiftKey){p=a.parent();s=p.prev();if(s.attr("class")=="zfsub"){s.children("input").each(function(e,d){c=jQuery("#"+d.id);if(c.attr("pos")==pos){c.focus()}})}else{s=p.parent().children().eq(-4);s.children("input").each(function(e,d){c=jQuery("#"+d.id);if(c.attr("pos")==pos){if(c.next()&&c.prev().prev()){c.prev().prev().focus()}else{return true}}})}return false}}};
