//drag drop function for ie4+ and NS6////
/////////////////////////////////
var ns4=document.layers;
var ie4=document.all;
var ns6=document.getElementById&&!document.all;

function drag_drop(e){
	if (!e) var e = window.event;
	if (ie4&&dragapproved) {
		crossobj.style.left=tempx+e.clientX-offsetx;
		crossobj.style.top=tempy+e.clientY-offsety;
		return false
	} else if (ns6&&dragapproved) {
		crossobj.style.left=String(Number(tempx+e.clientX-offsetx)+"px");
		crossobj.style.top=String(Number(tempy+e.clientY-offsety)+"px");
		return false;
	}
}

function initializedrag(e) {
	if (!e) var e = window.event;
	crossobj = ns6 ? document.getElementById("dragwin") : document.all.dragwin;
	var firedobj = ns6 ? e.target : e.srcElement;
	var topelement=ns6 ? "html" : document.compatMode && document.compatMode!= "BackCompat" ? "documentElement" : "body";
	
	if (typeof document.onselectstart!="undefined") {
		this.onselectstart=new Function ("return false");
	}
	else{
		document.onmousedown=new Function ("return false");
		//document.onmouseup=new Function ("return true");
	}
	
	while (firedobj.tagName != topelement.toUpperCase() && firedobj.id!="dragbar") {
		firedobj=ns6? firedobj.parentNode : firedobj.parentElement
	}
	if (firedobj.id=="dragbar") {
		offsetx= ie4 ? e.clientX : e.clientX
		offsety= ie4 ? e.clientY : e.clientY
		
		tempx=parseInt(crossobj.style.left)
		tempy=parseInt(crossobj.style.top)
		
		dragapproved=true
		document.onmousemove=drag_drop
	}
}
document.onmouseup=new Function("dragapproved=false; return true");

////drag drop functions end here//////


var trace = function (str) {
	if (!document.getElementById("trc")) {
		body  = document.getElementsByTagName("body").item(0);
		trtitle = document.createElement("span");
		trtitle.style.display = (ns6) ? 'table-cell' : 'block';
		trtitle.style.styleFloat = 'left';
		trtitle.style.styleClear = 'none';
		trtitle.style.width = (ns6) ? 'auto' : 'auto';
		trtitle.style.lineHeight = '20px';
		trtitle.style.paddingLeft = '5px';
		trtitle.style.textAlign = 'left';
		trtitle.style.cursor = 'default';
		trtitle.style.fontFamily = 'Tahoma, Verdana, Arial, sans';
		trtitle.style.fontWeight = 'bold';
		trtitle.style.fontSize = '11px';
		trtitle.style.color = '#ffffff';
		trtitle.appendChild(document.createTextNode("Trace"));
		
		trdiv = document.createElement("div");
		trdiv.style.display = 'block';
		trdiv.style.position = 'absolute';
		//trdiv.style.position = (document.all) ? 'absolute' : 'fixed';
		trdiv.style.zIndex = '9999';
		//trdiv.style.bottom = '0px';
		trdiv.style.border = '2px outset #090';
		trdiv.style.margin = '0';
		trdiv.style.right = 'auto';
		//if (document.all) trdiv.style.width = 'auto';
		trdiv.style.top = '200px';
		trdiv.style.left = '5px';
		trdiv.style.backgroundColor = '#090';
		
		trdiv.style.opacity = '0.75';
		trdiv.style.MozOpacity = '0.75';
		trdiv.style.filter = 'Alpha(opacity=75)';
		trdiv.id = 'dragwin';

		
		trtxt = document.createElement("textarea");
		trtxt.id = "trc";
		trtxt.cols = 30;
		trtxt.rows = 20;
		trtxt.paused = false;
		trtxt.style.font = "12px 'Courier New'";
		trtxt.style.color = "#000000";
		trtxt.style.border = '1px inset #090';
		//trtxt.style.backgroundColor = "#000000";
		trtxt.style.background = "#ffffff";
		trtxt._width = "250px";
		trtxt._fullwidth = "600px";
		trtxt.style.width = 
		trtxt.style.minWidth = trtxt._width;
		trtxt._height = "300px";
		trtxt._fullheight = "400px";
		trtxt.style.height = trtxt._height;
		if (document.all) {
			trtxt.style.scrollbarTrackColor="#ffffff";
			trtxt.style.scrollbarFaceColor="#cccccc";
			trtxt.style.scrollbarArrowColor="#000000";
			trtxt.style.scrollbarHighlightColor="#dddddd";
			trtxt.style.scrollbar3dlightColor="#009900";
			trtxt.style.scrollbarShadowColor="#666666";
			trtxt.style.scrollbarDarkshadowColor="#009900";
		}
		
		trdragbar = document.createElement("div");
		trdragbar.style.display =  (ns6) ? 'table' : 'block';
		if (!document.all) trdragbar.style.width = trtxt._width;
		trdragbar.style.cursor = 'default';
		trdragbar.style.textAlign = 'right';
		trdragbar.align = 'right';
		trdragbar.id = 'dragbar';
		trdragbar.onmousedown = initializedrag;
		trdragbar.onmouseover = function(){trdiv.style.backgroundColor = '#0c0';}
		trdragbar.onmouseout = function(){trdiv.style.backgroundColor = '#090';}
		
		trbuttons = document.createElement("span");
		trbuttons.style.display =  (ns6) ? 'table-cell' : 'block';
		if (ns6) trbuttons.style.width = '150px';
		
		trclose = document.createElement("input");
		trclose.type = "button";
		trclose.value = String.fromCharCode(215);
		trclose.style.fontWeight = 'bold';
		trclose.style.fontFamily = 'Arial Black, Verdana, Tahoma, Arial';
		trclose.style.width = trclose.style.height = '20px';
		trclose.style.fontSize = '11px';
		trclose.title = "Bezárás";
		trclose.onclick = function() {
			body.removeChild(trdiv);
			delete trdiv
		}
		
		trresize = document.createElement("input");
		trresize.type = "button";
		trresize.value = String.fromCharCode(9633);
		//trresize.style.fontWeight = 'bold';
		//trresize.style.fontFamily = 'Arial Black, Verdana, Tahoma, Arial';
		trresize.style.width = trresize.style.height = '20px';
		trresize.style.font = "bold 11px/16px 'Arial Black', Verdana, Tahoma, Arial";
		if (document.all) {
			trresize.value = String.fromCharCode(49);
			trresize.style.fontWeight = 'normal';
			trresize.style.fontFamily = 'Webdings';
			trresize.style.width = trclose.style.height = '20px';
			trresize.style.fontSize = '11px';	
		}
		trresize.fullsize = false;
		trresize.title = (trresize.fullsize) ? "Kis méret" : "Teljes méret";
		trresize.onclick = function() {
			this.fullsize = !this.fullsize;
			if (this.fullsize) {
				this.value = (document.all) ? String.fromCharCode(50) : String.fromCharCode(9643);
				this.title = "Kis méret";
				trtxt.style.width =
				trtxt.style.minWidth = trtxt._fullwidth;
				trtxt.style.height = trtxt._fullheight;
				if (!document.all) trdragbar.style.width = trtxt._fullwidth;
				
			} else {
				this.value = (document.all) ? String.fromCharCode(49) : String.fromCharCode(9633);	
				this.title = "Teljes méret";
				trtxt.style.width =
				trtxt.style.minWidth = trtxt._width;
				trtxt.style.height = trtxt._height;
				if (!document.all) trdragbar.style.width = trtxt._width;
			}
		}
		
		trdel = document.createElement("input");
		trdel.type = "button";
		trdel.value = "Töröl";
		trdel.style.height = '20px';
		trdel.style.fontSize = '11px';
		trdel.style.styleClear = 'none';
		trdel.onclick = function() {trtxt.value = '';}
		
		trpause = document.createElement("input");
		trpause.type = "button";
		trpause.value = "Szünet";
		trpause.style.height = '20px';
		trpause.style.fontSize = '11px';
		trpause.style.styleClear = 'none';
		trpause.onclick = function() {
			trtxt.paused = !trtxt.paused;
			trpause.value = (!trtxt.paused) ? "Szünet" : "Folytat";
		}
		
		trbuttons.appendChild(trpause);
		trbuttons.appendChild(trdel);
		trbuttons.appendChild(trresize);
		trbuttons.appendChild(trclose);
		
		trdragbar.appendChild(trtitle);
		trdragbar.appendChild(trbuttons);
		
		trdiv.appendChild(trdragbar);
		trdiv.appendChild(trtxt);
		//body.appendChild(trdiv);
		//
		try {
			body.insertBefore(trdiv, body.firstChild);	
		} catch(e) {
			window.setTimeout(function(){trace(str)},5);
		}
	}
	if (!trtxt.paused) {
		trtxt.value += str+"\n";
		trtxt.scrollTop = trtxt.scrollHeight;
	}
}
