function ErrorTracer()
{
	var ctrl = false;
	var enter = false; 
	this.addr = "";
	this.ajax = true;
	this.debug = false;
	this.onError = null;
	var that = this;
	
	// --------------------- public functions ------------------------
	this.Init = function(params)
	{
		window.document.onkeydown = function(e)
		{
			if(!e) e = window.event;
			if(e.keyCode == 17) ctrl = true;
			else if(e.keyCode == 13) enter = true;
		}
		window.document.onkeyup = function(e)
		{
			if(!e) e = window.event;
			if(e.keyCode == 17 && !enter) ctrl = false;
			if(ctrl == true && e.keyCode == 13)
			{ 
				if(/*@cc_on 1 | @*/ 0) txt = document.selection.createRange().text;
				else txt = window.getSelection().toString();
				if(txt == '') return;
				if(that.onError) that.onError(txt);
			}
			if(e.keyCode == 13)
			{ 
				if(ctrl) ctrl = false;
				enter = false;
			}
		}
		that.addr = params.addr == undefined ? "" : params.addr;
		that.ajax = params.ajax == undefined ? true : params.ajax;
		that.debug = params.debug == undefined ? false : params.debug;
	};
	//---------------------------------------
	this.sendError = function(txt,desc)
	{
		var httpRequester = that.ajax ? getHTTPRequestObject() : false;
		if(httpRequester)
		{
			httpRequester.open("GET",that.addr + "?str=" + encodeURIComponent(txt) + "&url=" + document.location + "&desc=" + encodeURIComponent(desc),true);
			httpRequester.send(null);
		}
		else
		{
			var body = document.getElementsByTagName('body');
			if(body)
			{
				var div_container = document.createElement("DIV");
				div_container.innerHTML = "<iframe style='" + (that.debug == true ? "width:100px;height:100px;" : "width:0px;height:0px;") + "' src='" + that.addr + "?str=" + encodeURIComponent(txt) + "&url=" + document.location + "&desc=" + encodeURIComponent(desc) + "'></iframe>";
				body[0].appendChild(div_container);
			}
		}
	};
	// ------------------ private functions ------------------------
	function getHTTPRequestObject() 
	{
  		var xmlHttpRequest;
  		/*@cc_on
  		@if (@_jscript_version >= 5)
  		try 
  		{
    		xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
  		}catch (exception1) 
  		{
    		try 
    		{
      			xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    		}catch (exception2) 
    		{
      			xmlHttpRequest = false;
    		}
  		}
  		@else
    		xmlhttpRequest = false;
  		@end @*/
  		if (!xmlHttpRequest && typeof XMLHttpRequest != 'undefined') 
  		{
    		try 
    		{
      			xmlHttpRequest = new XMLHttpRequest();
    		}catch (exception) 
    		{
      			xmlHttpRequest = false;
    		}
  		}
  		return xmlHttpRequest;
	};
	//-----------------------------------------
}