var Util=new Object();Util.getUserAgent=navigator.userAgent;Util.isGecko=Util.getUserAgent.indexOf("Gecko")!=-1;Util.isOpera=Util.getUserAgent.indexOf("Opera")!=-1;Util.isIE7=Util.getUserAgent.indexOf("MSIE 7.")!=-1;Util.isFF=Util.getUserAgent.indexOf("Firefox")!=-1;Util.getOffset=function(a,c){var b=0;while(a!=null){b+=a["offset"+(c?"Left":"Top")];a=a.offsetParent}return b};Util.bindFunction=function(a,b){return function(){return a[b].apply(a,arguments)}};Util.re_calcOff=function(b){for(var a=0;a<Util.dragArray.length;a++){var c=Util.dragArray[a];c.elm.pagePosLeft=Util.getOffset(c.elm,true);c.elm.pagePosTop=Util.getOffset(c.elm,false)}var d=b.elm.nextSibling;while(d){d.pagePosTop-=b.elm.offsetHeight;d=d.nextSibling}};Util.hide=function(){Util.rootElement.style.display="none"};Util.show=function(){Util.rootElement.style.display=""};ghostElement=null;getGhostElement=function(a){if(!ghostElement){ghostElement=document.createElement("DIV");ghostElement.className=a.modboxClassName;ghostElement.backgroundColor="";ghostElement.style.border="2px dashed #aaa";ghostElement.innerHTML="&nbsp;"}return ghostElement};function draggable(a){this._dragStart=start_Drag;this._drag=when_Drag;this._dragEnd=end_Drag;this._afterDrag=after_Drag;this.isDragging=false;this.elm=a;this.modboxClassName=a.className;this.header=document.getElementById(a.id+"_h");this.hasIFrame=this.elm.getElementsByTagName("IFRAME").length>0;if(this.header){this.header.style.cursor="move";Drag.init(this.header,this.elm);this.elm.onDragStart=Util.bindFunction(this,"_dragStart");this.elm.onDrag=Util.bindFunction(this,"_drag");this.elm.onDragEnd=Util.bindFunction(this,"_dragEnd")}}function start_Drag(){Util.re_calcOff(this);this.origNextSibling=this.elm.nextSibling;var a=getGhostElement(this);var c=this.elm.offsetHeight;if(Util.isGecko){c-=parseInt(a.style.borderTopWidth)*2}var d=this.elm.offsetWidth;var b=Util.getOffset(this.elm,true);if(Util.isIE7){b-=146}var e=Util.getOffset(this.elm,false);Util.hide();a.style.height=c+"px";this.elm.parentNode.insertBefore(a,this.elm.nextSibling);this.elm.style.width=d+"px";this.elm.style.position="absolute";this.elm.style.zIndex=100;this.elm.style.left=b+"px";this.elm.style.top=e+"px";Util.show();this.isDragging=false;return false}function when_Drag(g,f){if(!this.isDragging){this.elm.style.filter="alpha(opacity=70)";this.elm.style.opacity=0.7;this.isDragging=true}var a=null;var c=100000000;for(var e=0;e<Util.dragArray.length;e++){var h=Util.dragArray[e];var b=Math.sqrt(Math.pow(g-h.elm.pagePosLeft,2)+Math.pow(f-h.elm.pagePosTop,2));if(h==this){continue}if(isNaN(b)){continue}if(b<c){c=b;a=h}}var d=getGhostElement(this);if(a!=null&&d.nextSibling!=a.elm){a.elm.parentNode.insertBefore(d,a.elm);if(Util.isOpera){document.body.style.display="none";document.body.style.display=""}}}function end_Drag(){if(this._afterDrag()){var e=this.elm.parentNode;if(e!=null){var a=e.cellIndex/2+1;var f=a;if(NaN==f){f=1}var c="";var b="";for(var g=0;g<e.childNodes.length;g++){var d=e.childNodes[g];if(d.tagName=="DIV"&&d.className.indexOf("modbox")!=-1){if(d.attributes.section!=null){if(c==""){c=d.attributes.section.nodeValue}else{c=c+";"+d.attributes.section.nodeValue}}if(d.attributes.subsection!=null){if(b==""){b=d.attributes.subsection.nodeValue}else{b=b+";"+d.attributes.subsection.nodeValue}}}}if(!xmlhttpLayOut){xmlhttpLayOut=initAjax()}if(xmlhttpLayOut!=null){xmlhttpLayOut.open("post","action_save_sections_layout.asp",true);xmlhttpLayOut.onreadystatechange=function(){if(4==xmlhttpLayOut.readyState){if(200==xmlhttpLayOut.status){var h=xmlhttpLayOut.responseText;if(h=="error_section_user_id"){location.reload()}}else{if(0!=xmlhttpLayOut.status){alert(xmlhttpLayOut.status)}}}};xmlhttpLayOut.setRequestHeader("Content-type","application/x-www-form-urlencoded");xmlhttpLayOut.send("pageid="+escape(get_query_string_param("id"))+"&postion_left="+escape(f)+"&sections="+escape(c)+"&sub_sections="+escape(b))}}}return true}function after_Drag(){var a=false;Util.hide();this.elm.style.position="";this.elm.style.width="";this.elm.style.zIndex="";this.elm.style.filter="";this.elm.style.opacity="";var b=getGhostElement(this);if(b.nextSibling!=this.origNextSibling){b.parentNode.insertBefore(this.elm,b.nextSibling);a=true}b.parentNode.removeChild(b);Util.show();if(Util.isOpera){document.body.style.display="none";document.body.style.display=""}return a}var Drag={obj:null,init:function(b,a){b.onmousedown=Drag.start;b.obj=a;if(isNaN(parseInt(a.style.left))){a.style.left="0px"}if(isNaN(parseInt(a.style.top))){a.style.top="0px"}a.onDragStart=new Function();a.onDragEnd=new Function();a.onDrag=new Function()},start:function(b){var a=Drag.obj=this.obj;var c=Util.isFF?b.target:window.event.srcElement;if(c.id!=a.id+"_h"&&c.id!=a.id+"_n"){return false}b=Drag.fixE(b);if(b.which!=1){return true}a.onDragStart();a.lastMouseX=b.clientX;a.lastMouseY=b.clientY;document.onmouseup=Drag.end;document.onmousemove=Drag.drag;return false},drag:function(h){h=Drag.fixE(h);if(h.which==0){return Drag.end()}var g=Drag.obj;var f=h.clientY;var e=h.clientX;if(g.lastMouseX==e&&g.lastMouseY==f){return false}var d=parseInt(g.style.top);var c=parseInt(g.style.left);var b,a;b=c+e-g.lastMouseX;a=d+f-g.lastMouseY;g.style.left=b+"px";g.style.top=a+"px";g.lastMouseX=e;g.lastMouseY=f;g.onDrag(b,a);return false},end:function(b){b=Drag.fixE(b);document.onmousemove=null;document.onmouseup=null;var a=Drag.obj.onDragEnd();Drag.obj=null;return a},fixE:function(a){if(typeof a=="undefined"){a=window.event}if(typeof a.layerX=="undefined"){a.layerX=a.offsetX}if(typeof a.layerY=="undefined"){a.layerY=a.offsetY}if(typeof a.which=="undefined"){a.which=a.button}return a}};var _IG_initDrag=function(e){Util.rootElement=e;Util._rows=Util.rootElement.tBodies[0].rows[0];Util.column=Util._rows.cells;Util.dragArray=new Array();var b=0;for(var d=0;d<Util.column.length;d++){var f=Util.column[d];for(var c=0;c<f.childNodes.length;c++){var a=f.childNodes[c];if(a.tagName=="DIV"&&(a.className.indexOf("modbox")>-1||a.className=="dm")){Util.dragArray[b]=new draggable(a);b++}}}};var xmlhttpLayOut=null;function initAjax(){var c=null;try{c=new ActiveXObject("Msxml2.XMLHTTP")}catch(b){try{c=new ActiveXObject("Microsoft.XMLHTTP")}catch(a){c=false}}if(!c&&typeof XMLHttpRequest!="undefined"){c=new XMLHttpRequest()}return c};
