var ogTbodyMovable=(function(){var h=new Array("SEQ");var f="";var c="";var j="";var a="";var b=false;dragObj=new Object();dragObj.dragFlag=false;dragObj.offsetX=dragObj.offsetY=0;dragObj.mouseX=dragObj.mouseY=0;dragObj.height=dragObj.width=0;dragObj.target=null;function d(p,s){if(p.tagName.toUpperCase()=="TBODY"){var u=p}else{var u=$(p).parents("tbody").get(0)}var v=$(u).closest("table");var n=$(u).prev("tbody");for(i in j){if($(n).hasClass(j[i])){return}}if(!s&&f){var o=$(v).children("tbody").index(u);for(i in f){$("."+f[i]+" ,#"+f[i]).each(function(){var w=this;if(this.tagName.toUpperCase()!="TABLE"){w=$(this).children("table").get(0)}if($(w)!=$(v)){d($(w).children("tbody").get(o),true)}})}}if(n.length==1){for(i in h){if(typeof h[i]=="string"){if($(u).find("input[name^="+h[i]+"]").length>0&&$(n).find("input[name^="+h[i]+"]").length>0){var t=$(u).find("input[name^="+h[i]+"]").get(0);var m=$(n).find("input[name^="+h[i]+"]").get(0);var q=t.value;var r=m.value;if(a!=null&&h[i]==a&&Number(r)!=NaN){t.value=Number(r)-1}else{t.value=r;m.value=q}}}}$(u).after(n);return true}return false}function g(n,r){if(n.tagName.toUpperCase()=="TBODY"){var u=n}else{var u=$(n).parents("tbody").get(0)}var v=$(u).closest("table");var o=$(u).next("tbody");for(i in j){if($(o).hasClass(j[i])){return}}if(!r&&f){var m=$(v).children("tbody").index(u);for(i in f){$("."+f[i]+" ,#"+f[i]).each(function(){var w=this;if(this.tagName.toUpperCase()!="TABLE"){w=$(this).children("table").get(0)}if($(w)!=$(v)){g($(w).children("tbody").get(m),true)}})}}if(o.length==1){for(i in h){if(typeof h[i]=="string"){if($(u).find("input[name^="+h[i]+"]").length>0&&$(o).find("input[name^="+h[i]+"]").length>0){var s=$(u).find("input[name^="+h[i]+"]").get(0);var t=$(o).find("input[name^="+h[i]+"]").get(0);var p=s.value;var q=t.value;if(a!=null&&h[i]==a&&Number(q)!=NaN){s.value=Number(q)+1}else{s.value=q;t.value=p}}}}$(u).before(o);return true}return false}function l(t,n){var p,o,r,q;var v=(n)?n:((window.event)?window.event:null);var u=(v.target||v.srcElement);var s=u.parentNode.tagName;if(!(s=="TD"||s=="TR"||s=="TBODY")){return true}var m=$(u).parents("tbody").get(0);if(m){for(i in c){if($(m).hasClass(c[i])){return true}}b=true;if(document.all){p=window.event.clientX+document.body.scrollLeft;o=window.event.clientY+document.body.scrollTop;r=p-$(m).offset().left;q=o-$(m).offset().top}else{p=n.pageX;o=n.pageY;r=p-$(m).offset().left;q=o-$(m).offset().top}dragObj.dragFlag=true;dragObj.target=m;dragObj.height=m.offsetHeight;dragObj.width=m.offsetWidth;dragObj.offsetX=r;dragObj.offsetY=q;dragObj.mouseY=o;dragObj.mouseX=p}document.body.style.cursor="move";return false}function e(){b=false;dragObj.dragFlag=false;dragObj.offsetX=dragObj.offsetX=0;dragObj.mouseX=dragObj.mouseY=0;dragObj.height=dragObj.width=0;dragObj.target=null;document.body.style.cursor="auto"}function k(m){var o,n,p;if(!b){return true}if(document.all){n=window.event.clientY+document.body.scrollTop;p=n-$(dragObj.target).offset().top}else{n=m.pageY;p=n-$(dragObj.target).offset().top}if(!dragObj.dragFlag){return}if(dragObj.mouseY-n>dragObj.offsetY){if(d(dragObj.target)){dragObj.offsetY=n-$(dragObj.target).offset().top;dragObj.mouseY=n}}else{if(n-dragObj.mouseY>dragObj.height-dragObj.offsetY){if(g(dragObj.target)){dragObj.offsetY=n-$(dragObj.target).offset().top;dragObj.mouseY=n}}}return false}return function(o,m,n){switch(m){case"UP":d(o);break;case"DOWN":g(o);break;case"DRAGON":l(o,n);break;case"DRAGOFF":e();break;case"DRAG":k(n);break;case"SEQCLM":h=o.split(",");break;case"SYNCRO":f=o.split(",");break;case"NODRAG":c=o.split(",");break;case"NOMOVE":j=o.split(",");break;case"ADJUST":a=o;default:return}}})();$(function(){if($("span.tbodyMovable").length>0){var c=$("span.tbodyMovable").get(0);var f=c.getAttribute("seqclm");var d=c.getAttribute("sync");var b=c.getAttribute("noDrag");var e=c.getAttribute("noMove");var a=c.getAttribute("adjustSeq");if(f){ogTbodyMovable(f,"SEQCLM")}if(d){ogTbodyMovable(d,"SYNCRO")}if(b){ogTbodyMovable(b,"NODRAG")}if(e){ogTbodyMovable(e,"NOMOVE")}if(a){ogTbodyMovable(a,"ADJUST")}}$("#viewTable").live("mousedown",function(g){ogTbodyMovable(this,"DRAGON",g||window.event)});$("#viewTable").live("mousemove",function(g){ogTbodyMovable(this,"DRAG",g||window.event)});$("#viewTable").live("mouseup",function(g){ogTbodyMovable(this,"DRAGOFF",g||window.event)})});