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