function Trace(){
	this.m_bSilentMode = false;
	//////////////////////////////////////////////////////////////////////////////////////////////////////////// D U M P
	// D U M P
	this.Dump = function(oObject, bReturn){
		if(this.m_bSilentMode) return;
		//var sResult = "<pre>";
		var sValue;
		var sResult = "<table border=0>";
		for (var i in oObject) {
			sResult += '<tr>';
			sResult += '<td width="10"></td>';
			sName = typeof(oObject) +"::"+ i;
			sObjectType = typeof(oObject[i]);
			sColor = "#800000";
			try{
				sValue = oObject[i];
			}catch(e){
				sValue = '';
				sObjectType = '<div style="color:#008000">[function]</div>';
				bIsFunction = true;
				sName += "()";
				sColor = "#800000; font-weight:bold";
			}
			if(typeof(oObject[i]) == 'function') sName += "()";
			sResult += '<td style="font-family:Tahoma; font-size:11px; color:#000080; padding-right:10px" align="right">'+ sObjectType +'</td>';
			sResult += '<td style="font-family:Tahoma; font-size:11px; color:'+ sColor +'; padding-right:20px"> '+ sName + '</td>';
			sResult += '<td style="font-family:Tahoma; font-size:11px; color:#000080"> '+ sValue + '</td>';
			sResult += '</tr>';
			try{
				if(i == 'attributes' || i == 'childNodes'){
					for(j = 0; j < sValue.length; j++){
						sPrefix = (j == (sValue.length - 1)) ? '<div style="font-family:Terminal;display:inline; font-size:15px">А-</div>' : '<div style="font-family:Terminal;display:inline; font-size:15px">Г-</div>';
						sResult += '<tr>';
						sResult += '<td width="10"></td>';
						sResult += '<td style="font-family:Tahoma; font-size:11px; color:#000080; padding-right:10px" align="right"></td>';
						sResult += '<td style="font-family:Tahoma; font-size:11px; color:#000000; padding-left:10px; font-weight:normal" valign="top">'+ sPrefix +' '+ typeof(sValue.item(j)) +'.item('+ j +')</td>';
						sResult += '<td style="font-family:Tahoma; font-size:11px; color:#000080"> '+sValue.item(j) + '</td>';
						sResult += '</tr>';
					}
				}
			}catch(e){
				sResult += e;
			}
		}
		sResult += "</table>";
		if(bReturn) return sResult;
		
		if(!document.all.DebugDiv){
			oDiv = document.createElement('DIV');
			oDiv.id = 'DebugDiv';
			oDiv.style.cssText = "font-family: Tahoma; font-size: 11px; color: #000080; background-color: #F6F6F6; border: 1px solid #000000; padding-bottom:30px";
			document.body.appendChild(oDiv);
		}
		oDiv.innerHTML += "&lt;DEBUG INFO :: "+ oObject +"&gt;<br>";
		oDiv.innerHTML += sResult;
		oDiv.innerHTML += "&lt;/DEBUG INFO :: "+ oObject +"&gt;<br>";
		
		oDiv.style.position = 'absolute';
		oDiv.style.top = '5px';
		oDiv.style.left = '5px';
		oDiv.style.zIndex = 100;
		oDiv.ondblclick = new Function("this.removeNode(true);");
	}
	//////////////////////////////////////////////////////////////////////////////////////////////////////////// C R E A T E   D E B U G   L A Y E R
	// C R E A T E   D E B U G   L A Y E R
	this.CreateDebugLayer = function(Document){
		if(!Document) Document = document;
		var oDiv = Document.createElement('DIV');
		oDiv.style.fontFamily = 'Tahoma';
		oDiv.id = '_DebugLayer';
		oDiv.style.fontSize = '11px';
		oDiv.style.paddingLeft = '10px'
		oDiv.style.margin = '0px'
		oDiv.style.border = '1px solid #000000';
		oDiv.style.backgroundColor = '#F6F6F6';
		oDiv.style.padding = '10px';
		oDiv.style.width = '600px';
		oDiv.style.position = 'absolute';
		// position the layer
		var DebugLayers = Document.all('_DebugLayer');
		if(DebugLayers == null){
			oDiv.style.top = '5px';
			oDiv.style.left = '5px';
		}else{
			if(typeof DebugLayers.length == 'undefined'){
				var TopLayer = DebugLayers;
			}else{
				var TopLayer = DebugLayers[DebugLayers.length - 1];
			}
			oDiv.style.top = (TopLayer.style.posTop + 20) +'px';
			oDiv.style.left = (TopLayer.style.posLeft + 20) +'px';
		}
		
		oDiv.style.zIndex = 100;
		oDiv.overflow = 'scroll';
		oDiv.ondblclick = new Function("this.removeNode(true);");
		var oFont = Document.createElement('font');
		oFont.style.display = 'block';
		oFont.style.width = '100%';
		oFont.style.border = '1px solid #949494';
		oFont.style.padding = '3px';
		oFont.style.marginBottom = '10px';
		oFont.style.backgroundColor = '#D4D4D4';
		oFont.style.color = '#636363';
		oFont.style.fontWeight = 'bold';
		oFont.appendChild(CreateText("Debug", false, false, Document));
		oFont = oDiv.appendChild(oFont);
		return Document.body.appendChild(oDiv);
	}
	//////////////////////////////////////////////////////////////////////////////////////////////////////////// C R E A T E   I N F O   L A Y E R
	// C R E A T E   I N F O   L A Y E R
	this.CreateInfoLayer = function(sString, bHtml){
		if(typeof(bHtml) == 'undefined') 
			bHtml = false;
		var oText = document.createElement('DIV');
		if(bHtml)
			oText.innerHTML = sString;
		else
			oText.appendChild(CreateText(sString));
		oText.contentEditable = true;
		return oText;
	}
	//////////////////////////////////////////////////////////////////////////////////////////////////////////// E C H O
	// E C H O
	this.Echo1 = function(sString){
		if(this.m_bSilentMode) return;
		var oDiv = this.CreateDebugLayer();
		oDiv.style.position = "";
		oDiv.style.padding = "1px 2px 1px 2px";
		oDiv.style.margin = "1px 0px 0px 1px";
		oDiv.style.border = "1px solid #D4D4D4";
		oDiv.innerHTML = sString;
	}
	//////////////////////////////////////////////////////////////////////////////////////////////////////////// E C H O
	// E C H O
	this.Echo = function(sString, bHtml){
		if(typeof(bHtml) == 'undefined') 
			bHtml = false;
		if(this.m_bSilentMode) return;
		var oDiv = this.CreateDebugLayer();
		//oDiv.style.display = 'none';
		var oText = this.CreateInfoLayer(sString, bHtml);
		oDiv.appendChild(oText);
		//oDiv.style.top = '0px';
		//oDiv.style.left = '0px';
	}
	//////////////////////////////////////////////////////////////////////////////////////////////////////////// D U M P   W I N D O W
	// D U M P   W I N D O W
	this.DumpWindow = function(sUrl){
		if(this.m_bSilentMode) return;
		var oDiv = this.CreateDebugLayer();
		var oFont = document.createElement('font');
		oFont.style.color = '#AA0000';
		oFont.style.fontWeight = 'bold';
		oFont.contentEditable = true;
		oFont.appendChild(CreateText('RPC Call: '));
		oFont.appendChild(document.createElement('BR'));
		oDiv.appendChild(oFont);
		var nLength = (sUrl.length > 200) ? 200 : sUrl.length;
		oDiv.appendChild(this.CreateInfoLayer(sUrl.substring(0, nLength)));
		oDiv.appendChild(document.createElement('BR'));
		oDiv.appendChild(document.createElement('BR'));
		var oFont = document.createElement('font');
		oFont.style.color = '#AA0000';
		oFont.style.fontWeight = 'bold';
		oFont.appendChild(CreateText('RPC Result: '));
		oFont.style.cursor = 'hand';
		
		oFont.onmouseover = new Function('this.style.textDecoration="underline";');
		oFont.onmouseout = new Function('this.style.textDecoration="none";');
		oFont = oDiv.appendChild(oFont);
		var oInfoLayer = this.CreateInfoLayer('');
		var oIFrame = document.createElement('IFRAME');
		oFont.onclick = new Function('window.open("'+ sUrl.replace(/"/gi, '\'') +'")');
		//oFont.onclick = new Function('this.parentNode.all.'+ oIFrame.uniqueID +'.src= "'+ sUrl +'";');
		oIFrame.style.width = "100%";
		oIFrame.style.height = "400px";
		//oIFrame.setAttribute("src", sUrl);
		oIFrame.src = sUrl;
		
		oDiv.appendChild(oInfoLayer.appendChild(oIFrame));
		//oIFrame.contentWindow.document.contentEditable = true;
	}
	//////////////////////////////////////////////////////////////////////////////////////////////////////////// D U M P   S O U R C E
	// D U M P   S O U R C E
	this.DumpSource = function(oDumpDocument){
		if(this.m_bSilentMode) return;
		if(!oDumpDocument) oDumpDocument = window.document;
		
		var Popup = window.createPopup();
		var Document = Popup.document;
		
		//var oDiv = Document.createElement('DIV');
		//oDiv.style.position = 'absolute';
		//oDiv.style.top = '0px';
		//oDiv.style.left = '0px';
		//oDiv.style.zIndex = 100;
		Document.body.style.border = '1px solid #000000';
		Document.body.style.backgroundColor = '#F6F6F6';
		Document.body.style.padding = '10px';
		//oDiv.style.width = '100%';
		//oDiv.style.height = '100%';
		var oTextArea = Document.createElement("TEXTAREA");
		oTextArea.style.fontFamily = 'Tahoma';
		oTextArea.style.fontSize = '11px';
		oTextArea.style.width = '100%';
		oTextArea.style.height = '100%';
		oTextArea.innerText = oDumpDocument.firstChild.outerHTML;
		oTextArea = Document.body.appendChild(oTextArea);
		oTextArea.style.display = 'block';
		//oTextArea.ondblclick = new Function("event.cancelBubble = true;");
		//oDiv = Document.body.appendChild(oDiv);
		//oDiv.scrollIntoView();
		//oDiv.ondblclick = new Function("this.removeNode(true);");
		Popup.show(5, 5, 910, 610, Document.body); 
	}
	//////////////////////////////////////////////////////////////////////////////////////////////////////////// S E T   S I L E N T   M O D E
	// S E T   S I L E N T   M O D E
	this.SetSilentMode = function(bSilent){
		if(typeof(bSilent) == 'undefined') bSilent = true;
		this.m_bSilentMode = bSilent;
	}
}
