<script language="JavaScript" type="text/javascript"> /*<![CDATA[*/
var zxcDObj;
var zxcDTable=[];
function zxcInitDragRow(zxcid){
var zxctable=document.getElementById(zxcid);
zxcDTable.push([zxctable,zxctable.rows[0].cells.length]);
zxcclone=zxcES(zxctable.cloneNode(true),{position:'absolute'},document.getElementsByTagName('BODY')[0]);
var zxctbdy=zxcclone.getElementsByTagName('TBODY')[0];
while (zxctbdy.firstChild) zxctbdy.removeChild(zxctbdy.firstChild);
var zxcrows=zxctable.rows;
for (var zxc0=0;zxc0<zxcrows.length;zxc0++){
zxcrows[zxc0].clone=zxcclone;
zxcrows[zxc0].table=zxctable;
zxcAddEvt(zxcrows[zxc0],'zxcDragRowSrt','mousedown');
}
}
function zxcDragRowSrt(zxcevt){
if (this.table.rows.length<1) return;
document.onselectstart=function(event){window.event.returnValue=false; }
var zxcclone=zxcES(this.cloneNode(true),{left:zxcPos(this)[0]+'px',top:zxcPos(this)[1]+'px'},this.clone.getElementsByTagName('TBODY')[0]);
zxcES(this.clone,{left:zxcPos(this)[0]+'px',top:zxcPos(this)[1]+'px'});
var zxccells=this.cells;
for (var zxc0=0;zxc0<zxccells.length;zxc0++) zxcES(zxcclone.cells[zxc0],{width:zxccells[zxc0].width});
zxcDObj=[this.clone,this.clone.offsetLeft-zxcMse(zxcevt)[0],this.clone.offsetTop-zxcMse(zxcevt)[1],this];
}
function zxcDragRow(zxcevt){
if (zxcDObj){
zxcES(zxcDObj[0],{left:(zxcMse(zxcevt)[0]+zxcDObj[1])+'px',top:zxcMse(zxcevt)[1]+zxcDObj[2]+'px'});
return false;
}
}
function zxcRowMseUp(){
document.onselectstart=null;
if (!zxcDObj) return;
for (var zxc0=0;zxc0<zxcDTable.length;zxc0++){
var zxctpos=zxcPos(zxcDTable[zxc0][0]);
if (zxcDObj[3]&&zxcDTable[zxc0][1]==zxcDObj[3].cells.length&&zxctpos[0]-10<zxcDObj[0].offsetLeft&&zxctpos[0]+zxcDTable[zxc0][0].offsetWidth>zxcDObj[0].offsetLeft&& zxctpos[1]-zxcDObj[3].offsetHeight<zxcDObj[0].offsetTop &&zxctpos[1]+zxcDTable[zxc0][0].offsetHeight>zxcDObj[0].offsetTop){
var zxctrs=zxcDTable[zxc0][0].rows;
for (var zxc0a=0;zxc0a<zxcDTable[zxc0][1];zxc0a++) zxcES(zxcDObj[3].cells[zxc0a],{width:zxcDTable[zxc0][0].rows[0].cells[zxc0a].offsetWidth+'px'})
for (var zxc0b=0;zxc0b<zxctrs.length;zxc0b++){
if (zxcPos(zxctrs[zxc0b])[1]>zxcPos(zxcDObj[0])[1]&&zxctrs[zxc0b]!=zxcDObj[3]){
zxctrs[0].parentNode.insertBefore(zxcDObj[3],zxctrs[zxc0b]);
zxcDObj[3]=null;
break;
}
}
if (zxcDObj[3]) zxctrs[0].parentNode.appendChild(zxcDObj[3]);
}
}
var zxctr=zxcDObj[0].getElementsByTagName('TR')[0];
if (zxctr) zxctr.parentNode.removeChild(zxctr);
zxcDObj=false;
}
function zxcMse(e){
if (!document.all){ return [e.clientX+zxcDocS()[0],e.clientY+zxcDocS()[1]] }
else { return [event.clientX,event.clientY]; }
}
function zxcDocS(){
if (!document.body.scrollTop){ return [document.documentElement.scrollLeft,document.documentElement.scrollTop]; }
else { return [document.body.scrollLeft,zxcsy=document.body.scrollTop]; }
}
function zxcES(zxcele,zxcstyle,zxcp,zxctxt){
if (typeof(zxcele)=='string'){ zxcele=document.createElement(zxcele); }
for (key in zxcstyle){ zxcele.style[key]=zxcstyle[key]; }
if (zxcp){ zxcp.appendChild(zxcele); }
if (zxctxt){ zxcele.appendChild(document.createTextNode(zxctxt)); }
return zxcele;
}
function zxcPos(zxcobj){
zxclft=zxcobj.offsetLeft;
zxctop=zxcobj.offsetTop;
while(zxcobj.offsetParent!=null){
zxcpar=zxcobj.offsetParent;
zxclft+=zxcpar.offsetLeft;
zxctop+=zxcpar.offsetTop;
zxcobj=zxcpar;
}
return [zxclft,zxctop];
}
function zxcEventAdd(zxco,zxct,zxcf) {
if ( zxco.addEventListener ){ zxco.addEventListener(zxct, function(e){ return zxco[zxcf](e);}, false); }
else if ( zxco.attachEvent ){ zxco.attachEvent('on'+zxct,function(e){ return zxco[zxcf](e); }); }
else {
var zxcPrev=zxco["on" + zxct];
if (zxcPrev){ zxco['on'+zxct]=function(e){ zxcPrev(e); zxco[zxcf](e); }; }
else { zxco['on'+zxct]=zxco[zxcf]; }
}
}
function zxcAddEvt(zxcobj,zxcfun,zxcevt){
if (zxcobj['zxcadd'+zxcfun+zxcevt]) return;
zxcobj['zxcadd'+zxcfun+zxcevt]=window[zxcfun];
zxcEventAdd(zxcobj,zxcevt,'zxcadd'+zxcfun+zxcevt);
}
zxcAddEvt(document,'zxcDragRow','mousemove');
zxcAddEvt(document,'zxcRowMseUp','mouseup');
/*]]>*/
<body onload="zxcInitDragRow('dragDropTable')">
<table id="dragDropTable" border="2" cellpadding="2" cellspacing="0">
<td><img src="javascript:iconForDragging;" width="16" height="16" ondragstart="startedDragging();"></td>
<td><img src="javascript:iconForDragging;" width="16" height="16" ondragstart="startedDragging();"></td>
<td><img src="javascript:iconForDragging;" width="16" height="16" ondragstart="startedDragging();"></td>