//	--- funkce objektu ---

function objGet(x)
{if (typeof x=='string') with (document){
	if (Boolean(getElementById))	x=getElementById(x);
else	if (Boolean(all))		x=eval('all.'+x);
else	if (Boolean(layers))		x=layers[x];
else	x=null;}return x;}
function objc(x,z) {objGet(x).className=z}


function schovej(imgid,id)
{var x,y;
x=objGet(id+"x1").style;y=objGet(id);
if (x.display=="none")
	{x.display="block";y.className="mvis";imgid.src="chevronUp.gif"}
else	{x.display="none"; y.className="mhid";imgid.src="chevronDown.gif"}
}

function move(posunx,posuny)
{var w=presun.style;
	w.left = this.left+posunx+ "px";
	w.top  = this.top +posuny+ "px";
}

function presun1(e)
{if(!e) var e=window.event;m_down(e);}

function presun2(e)
{if(!e) var e=window.event;pohybstart(e,this);}



function pohybstart(event,object)
{
	var w,o;w=presun;o=object;
	if (o.nodeName!='TH') o=o.parentNode;
	
	if (o.nodeName=='TH') {
	w.innerHTML = o.innerHTML
	o=o.parentNode.parentNode.parentNode;
	ulozeno[0]=o.id;
	w=w.style;
	w.width	 = o.offsetWidth -((IE||OPERA)?4:16)+"px";
	w.height = o.offsetHeight-((IE||OPERA)?4:16)+"px";
	w.top	 = o.offsetTop	 -((IE)?6:0)+"px";
	o=o.parentNode;
	w.left	 = o.offsetLeft	 +6+"px";
	w.innerHTML = "aaa"
	w.display= "block";
	ulozeno[1]=(o.id=="zzz")?"zzz":"yyy";
	objc("zzz","dragclass d1");
	objc("yyy","dragclass d1");
}

	m_down(event);
}


function pohybkonec(object)
{
var u,p,q,r,s, a1,a2,a3,a4,b1,b2,b3,b4;
var w,o;w=presun;

b1=w.offsetLeft;
b2=w.offsetTop;
b3=b1+w.offsetWidth;
b4=b2+w.offsetHeight;

// je v oblasti "zzz"? ano-presun ne-nic
o=objGet("zzz");
a1=o.offsetLeft;
a2=o.offsetTop;
a3=a1+o.offsetWidth;
a4=a2+o.offsetHeight;

s=false;
if (((a3>b1 && b1>a1) || (a3>b3 && b3>a1))
 && ((a4>b2 && b2>a2) || (a4>b4 && b4>a2)))
{
	if (w)
	{
		q=objGet(ulozeno[0]);
		r=objGet(ulozeno[1]);
		p=q.cloneNode(true);
		r.removeChild(q);
		o.appendChild(p);
		p.rows[0].cells[1].onmousedown = presun2;
		s=true;
	}
}
o.className="dragclass";

// je v oblasti "yyy"? ano-presun ne-nic
o=objGet("yyy");
a1=o.offsetLeft;
a2=o.offsetTop;
a3=a1+o.offsetWidth;
a4=a2+o.offsetHeight;

if (((a3>b1 && b1>a1) || (a3>b3 && b3>a1))
 && ((a4>b2 && b2>a2) || (a4>b4 && b4>a2)) && !s)
{
	if (w)
	{
		q=objGet(ulozeno[0]);
		r=objGet(ulozeno[1]);
		p=q.cloneNode(true);
		r.removeChild(q);
		o.appendChild(p);
		p.rows[0].cells[1].onmousedown = presun2;
	}
}
o.className="dragclass";

}


var ulozeno=[null,null];
var nazev="m"
var obj=null;
var obj2;

obj=document.createElement("DIV");
obj.id="mmm";
document.body.appendChild(obj);
var presun=obj;
obj.ondragdrop=move;
startDrag(obj,0);

for (var i=0;i<2;i++)
{
obj2=nazev+i;
obj=objGet(obj2);
obj.rows[0].cells[1].onmousedown = presun2;
}
