//	Michal Kusyn, Interval.cz, 2002


//	--- Detection --- 

 IE= null; //IE5+
 NS= null; // Mozilla 0.9.1+
 OPERA = null; // Opera 7
 IE55 = null;
 IE5 = null;
 IE6=null;
	
 ua = navigator.appName.toLowerCase();

if (document.getElementById && document.childNodes)
{
 if(ua.indexOf('explorer')>-1 && !document.addEventListener) IE=true;
 if(ua.indexOf('netscape')>-1 && !document.all) NS=true;
 if(ua.indexOf('opera')>-1) OPERA=true;
}
 if(!IE && !NS && !OPERA && document.addEventListener) OPERA=true;

 ua = navigator.userAgent.toLowerCase();
 if(IE && ua.indexOf('5.5')>-1) IE55=true;
 if(IE && ua.indexOf('5.0')>-1) IE5=true;
 if(IE && !IE5 && !IE55) IE6=true;
  
 function test_prohlizec()
 { if(!IE && !NS && !OPERA) 
	self.location = "javascript:alert('Chyba v dokumentu "+self.location+" . Prohlizec nepodporuje metody standardu W3C DOM a neni mozno dokument spravne zobrazit.')";}

 function test_metoda(name)
 { eval("what="+name); if(!what)
	self.location = "javascript:alert('Chyba v dokumentu "+self.location+" . Prohlizec nepodporuje metodu "+name+" a neni mozno dokument spravne zobrazit.')";}  



//	--- Drag&Drop System ---
var dragobj;

	
function m_down(event,object)
{
	var w,x;
	w=presun;dragobj=w;
	x=w.style;
	

	x.zIndex = "100";
	if(!x.left) x.left= "0px";
	if(!x.top)  x.top = "0px";

	// Zapamatuj pozici mysi pri klikntuti
	w.clickX = event.clientX;
	w.clickY = event.clientY;

	// Zapamatuj pozici objektu pri klikntuti
	w.left= parseInt(x.left); 
	w.top = parseInt(x.top);


 	// Zacni sledovat pohyb mysi
	with (document)	{
	if(IE)
	{	
		attachEvent('onmousemove', m_move); 
		attachEvent('onmouseup', m_up); 		
	}

	if(NS || OPERA) 
	{
		addEventListener('mousemove', m_move, true);
		addEventListener('mouseup', m_up, true); 		
	}
		}

return stopEvent(event);
}

function m_move(event)
{
	// Spocti rozdil mezi puvodni pozici mysi pri stisku a nynejsi pozici a zavolej proceduru objektu pro presun 
	dragobj.ondragdrop(event.clientX-dragobj.clickX,event.clientY-dragobj.clickY, event);
	return stopEvent(event);
}

function m_up(event)
{
	// Ukonci sledovani mysi
	with (document)	{
	if(IE)
	{
		detachEvent('onmousemove', m_move); 	
		detachEvent('onmouseup', m_up); 
	}

	if(NS || OPERA)
	{
		removeEventListener('mousemove', m_move, true); 
		removeEventListener('mouseup', m_up, true); 
	}
			}
	if(IE || NS || OPERA)
		if(dragobj.ondragend)dragobj.ondragend(event);


	pohybkonec()	//pp
	stopDrag()	//pp

	return stopEvent(event);	
}


// Prirad objektu moznost presunu
function startDrag(what)
{
//	var x=what.style.position;
//	if(x!="relative" && x!="absolute") {x="relative";}
//	what.className+=" mmm"
	var w=presun;
	w.onmousedown = presun1;

	w.drag = 1;


}

// Odeber objektu moznost presunu 
function stopDrag(what)
{
//	what.className-=" mmm"
	var w=presun;
	w.style.display = "none";
	w.onmousedown = null;
	w.drag = 0;
}

// Zastav sireni udalosti
function stopEvent(event)
{
	if(IE)		{event.cancelBubble = true; return false;}
	if(NS || OPERA)	{event.stopPropagation(); event.preventDefault(); return false;}
}

