/*
	File: gbtx_debug.js
	
	This optional file contains the debugging module for use with gbtx.  If
	you include this module after the standard <gbtx_core.js> module, you
	will receive debugging messages, including errors, that occur during
	the processing of your gbtx requests.
	
	Title: gbtx debugging module
	
	Please see <copyright.inc.php> for a detailed description, copyright
	and license information.
*/

/*
	@package gbtx
	@version $Id: gbtx_debug_uncompressed.js 327 2007-02-28 16:55:26Z calltoconstruct $
	@copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson
	@license http://www.gbtxproject.org/bsd_license.txt BSD License
*/

try
{
	/*
		Class: gbtx.debug

		This object contains the variables and functions used to display process state
		messages and to trap error conditions and report them to the user via
		a secondary browser window or alert messages as necessary.
	*/
	if ('undefined' == typeof gbtx)
		throw { name: 'SequenceError', message: 'Error: gbtx core was not detected, debug module disabled.' }
		
	if ('undefined' == typeof gbtx.debug)
		gbtx.debug = {}

	/*
		String: workId
		
		Stores a 'unique' identifier for this session so that an existing debugging
		window can be detected, else one will be created.
	*/
	gbtx.debug.workId = 'gbtxWork'+ new Date().getTime();

	/*
		String: windowSource
		
		The default URL that is given to the debugging window upon creation.
	*/
	gbtx.debug.windowSource = 'about:blank';

	/*
		String: windowID
		
		A 'unique' name used to identify the debugging window that is attached
		to this gbtx session.
	*/
	gbtx.debug.windowID = 'gbtx_debug_'+gbtx.debug.workId;

	/*
		String: windowStyle
		
		The parameters that will be used to create the debugging window.
	*/
	if ('undefined' == typeof gbtx.debug.windowStyle)
		gbtx.debug.windowStyle = 
			'width=800,' +
			'height=500,' +
			'scrollbars=yes,' +
			'resizable=yes,' +
			'status=yes';
			
	/*
		String: windowTemplate
		
		The HTML template and CSS style information used to populate the
		debugging window upon creation.
	*/
	if ('undefined' == typeof gbtx.debug.windowTemplate)
		gbtx.debug.windowTemplate =
			'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' +
			'<html><head>' +
			'<title>gbtx debug output</title>' +
			'<style type="text/css">' +
			'/* <![CDATA[ */' +
			'.debugEntry { margin: 3px; padding: 3px; border-top: 1px solid #999999; } ' +
			'.debugDate { font-weight: bold; margin: 2px; } ' +
			'.debugText { margin: 2px; } ' +
			'.warningText { margin: 2px; font-weight: bold; } ' +
			'.errorText { margin: 2px; font-weight: bold; color: #ff7777; }' +
			'/* ]]> */' +
			'</style>' +
			'</head><body>' +
			'<h2>gbtx debug output</h2>' +
			'<div id="debugTag"></div>' +
			'</body></html>';

	/*
		Object: window
		
		A reference to the debugging window, once constructed, where messages will
		be displayed throughout the request process.  This is constructed internally
		as needed.
	*/

	/*
		Array: text
	*/
	gbtx.debug.text = [];
	gbtx.debug.text[100] = 'WARNING: ';
	gbtx.debug.text[101] = 'ERROR: ';
	gbtx.debug.text[102] = 'gbtx DEBUG MESSAGE:\n';
	gbtx.debug.text[103] = '...\n[LONG RESPONSE]\n...';
	gbtx.debug.text[104] = 'SENDING REQUEST';
	gbtx.debug.text[105] = 'SENT [';
	gbtx.debug.text[106] = ' bytes]';
	gbtx.debug.text[107] = 'CALLING: ';
	gbtx.debug.text[108] = 'URI: ';
	gbtx.debug.text[109] = 'INITIALIZING REQUEST';
	gbtx.debug.text[110] = 'PROCESSING PARAMETERS [';
	gbtx.debug.text[111] = ']';
	gbtx.debug.text[112] = 'NO PARAMETERS TO PROCESS';
	gbtx.debug.text[113] = 'PREPARING REQUEST';
	gbtx.debug.text[114] = 'STARTING gbtx CALL (deprecated: use gbtx.request instead)';
	gbtx.debug.text[115] = 'STARTING gbtx REQUEST';
	gbtx.debug.text[116] = 'No response processor is available to process the response from the server.\n';
	gbtx.debug.text[117] = '.\nCheck for error messages from the server.';
	gbtx.debug.text[118] = 'RECEIVED [status: ';
	gbtx.debug.text[119] = ', size: ';
	gbtx.debug.text[120] = ' bytes, time: ';
	gbtx.debug.text[121] = 'ms]:\n';
	gbtx.debug.text[122] = 'The server returned the following HTTP status: ';
	gbtx.debug.text[123] = '\nRECEIVED:\n';
	gbtx.debug.text[124] = 'The server returned a redirect to:<br />';
	gbtx.debug.text[125] = 'DONE [';
	gbtx.debug.text[126] = 'ms]';
	gbtx.debug.text[127] = 'INITIALIZING REQUEST OBJECT';
	/*
		Array: exceptions
	*/
	gbtx.debug.exceptions = [];
	gbtx.debug.exceptions[10001] = 'Invalid response XML: The response contains an unknown tag: {data}.';
	gbtx.debug.exceptions[10002] = 'GetRequestObject: XMLHttpRequest is not available, gbtx is disabled.';
	gbtx.debug.exceptions[10003] = 'Queue overflow: Cannot push object onto queue because it is full.';
	gbtx.debug.exceptions[10004] = 'Invalid response XML: The response contains an unexpected tag or text: {data}.';
	gbtx.debug.exceptions[10005] = 'Invalid request URI: Invalid or missing URI; autodetection failed; please specify a one explicitly.';
	gbtx.debug.exceptions[10006] = 'Invalid response command: Malformed response command received.';
	gbtx.debug.exceptions[10007] = 'Invalid response command: Command [{data}] is not a known command.';
	gbtx.debug.exceptions[10008] = 'Element with ID [{data}] not found in the document.';
	gbtx.debug.exceptions[10009] = 'Invalid request: Missing function name parameter.';
	gbtx.debug.exceptions[10010] = 'Invalid request: Missing function object parameter.';

	/*
		Function: getExceptionText
	*/
	gbtx.debug.getExceptionText = function(e) {
		if ('undefined' != typeof e.code) {
			if ('undefined' != typeof gbtx.debug.exceptions[e.code]) {
				var msg = gbtx.debug.exceptions[e.code];
				if ('undefined' != typeof e.data) {
					msg.replace('{data}', e.data);
				}

            return msg;

			}
		} else if ('undefined' != typeof e.name) {
			var msg = e.name;
			if ('undefined' != typeof e.message) {
				msg += ': ';
				msg += e.message;
			}

			return msg;

		}
		return 'An unknown error has occurred.';

	}

	/*
		Function: writeMessage
		
		Output a debug message to the debug window if available or send to an
		alert box.  If the debug window has not been created, attempt to 
		create it.
		
		text - (string):  The text to output.
		
		prefix - (string):  The prefix to use; this is prepended onto the 
			message; it should indicate the type of message (warning, error)
			
		cls - (stirng):  The className that will be applied to the message;
			invoking a style from the CSS provided in 
			<gbtx.debug.windowTemplate>.  Should be one of the following:
			- warningText
			- errorText
	*/
	gbtx.debug.writeMessage = function(text, prefix, cls) {

      try {
		} catch (e) {
			if (text.length > 1000) text = text.substr(0,1000) + gbtx.debug.text[102];
			alert(gbtx.debug.text[102] + text);
		}
	}

	/*
		Function: prepareDebugText
		
		Convert special characters to their HTML equivellents so they
		will show up in the <gbtx.debug.window>.
	*/
	gbtx.debug.prepareDebugText = function(text) {
		try {
			text = text.replace(/&/g, '&amp;')
				.replace(/</g, '&lt;')
				.replace(/>/g, '&gt;')
				.replace(/\n/g, '<br />');
			return text;
		} catch (e) {
			gbtx.debug.stringReplace = function(haystack, needle, newNeedle) {
				var segments = haystack.split(needle);
				haystack = '';
				for (var i = 0; i < segments.length; ++i) {
					if (0 != i)
						haystack += newNeedle;
					haystack += segments[i];
				}
				return haystack;
			}
			gbtx.debug.prepareDebugText = function(text) {
				text = gbtx.debug.stringReplace(text, '&', '&amp;');
				text = gbtx.debug.stringReplace(text, '<', '&lt;');
				text = gbtx.debug.stringReplace(text, '>', '&gt;');
				text = gbtx.debug.stringReplace(text, '\n', '<br />');
				return text;
			}
			gbtx.debug.prepareDebugText(text);
		}
	}

	/*
		Function: executeCommand
		
		Catch any exceptions that are thrown by a response command handler
		and display a message in the debugger.
		
		This is a wrapper function which surrounds the standard 
		<gbtx.executeCommand> function.
	*/
	gbtx.debug.executeCommand = gbtx.executeCommand;
	gbtx.executeCommand = function(args) {
		try {
			if ('undefined' == typeof args.cmd)
				throw { code: 10006 };
			if (false == gbtx.command.handler.isRegistered(args))
				throw { code: 10007, data: args.cmd };
			return gbtx.debug.executeCommand(args);
		} catch(e) {
			var msg = 'ExecuteCommand (';
			if ('undefined' != typeof args.sequence) {
				msg += '#';
				msg += args.sequence;
				msg += ', ';
			}
			if ('undefined' != typeof args.cmdFullName) {
				msg += '"';
				msg += args.cmdFullName;
				msg += '"';
			}
			msg += '):\n';
			msg += gbtx.debug.getExceptionText(e);
			msg += '\n';
			gbtx.debug.writeMessage(msg, gbtx.debug.text[101], 'errorText');

		}
		return true;
	}

	/*
		Function: parseAttributes
		
		Catch any exception thrown during the parsing of response
		command attributes and display an appropriate debug message.
		
		This is a wrapper around the standard <gbtx.parseAttributes>
		function.
	*/
	gbtx.debug.parseAttributes = gbtx.parseAttributes;
	gbtx.parseAttributes = function(child, obj) {
		try {
			gbtx.debug.parseAttributes(child, obj);
		} catch(e) {
			var msg = 'ParseAttributes:\n';
			msg += gbtx.debug.getExceptionText(e);
			msg += '\n';
         gbtx.debug.writeMessage(msg, gbtx.debug.text[101], 'errorText');
		}
	}

	gbtx.debug.commandHandler = gbtx.command.handler.unregister('dbg');
	gbtx.command.handler.register('dbg', function(args) {
		args.cmdFullName = 'debug message';
		gbtx.debug.writeMessage(args.data, gbtx.debug.text[100], 'warningText');
		return gbtx.debug.commandHandler(args);
	});


	/*
		Function: $
		
		Catch any exceptions thrown while attempting to locate an
		HTML element by it's unique name.
		
		This is a wrapper around the standard <gbtx.tools.$> function.
	*/
	gbtx.debug.$ = gbtx.tools.$;
	gbtx.tools.$ = function(sId) {
		try {
			var returnValue = gbtx.debug.$(sId);
			if ('object' != typeof returnValue)
				throw { code: 10008 };
		}
		catch (e) {
			var msg = '$:';
			msg += gbtx.debug.getExceptionText(e);
			msg += '\n';
			gbtx.debug.writeMessage(msg, gbtx.debug.text[100], 'warningText');
		}
		return returnValue;
	}

	/*
		Function: _objectToXML
		
		Generate a message indicating that a javascript object is
		being converted to xml.  Indicate the max depth and size.  Then
		display the size of the object upon completion.  Catch any 
		exceptions thrown during the conversion process.
		
		This is a wrapper around the standard <gbtx.tools._objectToXML>
		function.
	*/
	gbtx.debug._objectToXML = gbtx.tools._objectToXML;
	gbtx.tools._objectToXML = function(obj, guard) {
		try {
			if (0 == guard.size) {
				var msg = 'OBJECT TO XML: maxDepth = ';
				msg += guard.maxDepth;
				msg += ', maxSize = ';
				msg += guard.maxSize;
				gbtx.debug.writeMessage(msg);
			}
			var r = gbtx.debug._objectToXML(obj, guard);
			if (0 == guard.depth) {
				var msg = 'OBJECT TO XML: size = ';
				msg += guard.size;
				gbtx.debug.writeMessage(msg);
			}
			return r;
		} catch(e) {
			var msg = 'ObjectToXML: ';
			msg += gbtx.debug.getExceptionText(e);
			msg += '\n';
			gbtx.debug.writeMessage(msg, gbtx.debug.text[101], 'errorText');
   	}
		return '';
	}

	/*
		Function: _internalSend
		
		Generate a message indicating that the gbtx request is
		about the be sent to the server.
		
		This is a wrapper around the standard <gbtx._internalSend> 
		function.
	*/
	gbtx.debug._internalSend = gbtx._internalSend;
	gbtx._internalSend = function(oRequest) {
		try {
			gbtx.debug.writeMessage(gbtx.debug.text[104]);
			gbtx.debug.writeMessage(
				gbtx.debug.text[105] + 
				oRequest.requestData.length + 
				gbtx.debug.text[106]
				);
			oRequest.beginDate = new Date();
			gbtx.debug._internalSend(oRequest);
		} catch (e) {
			var msg = 'InternalSend: ';
			msg += gbtx.debug.getExceptionText(e);
			msg += '\n';
			gbtx.debug.writeMessage(msg, gbtx.debug.text[101], 'errorText');
			throw e;
		}
	}

	/*
		Function: submitRequest
		
		Generate a message indicating that a request is ready to be 
		submitted; providing the URL and the function being invoked.
		
		Catch any exceptions thrown and display a message.
		
		This is a wrapper around the standard <gbtx.submitRequest>
		function.
	*/
	gbtx.debug.submitRequest = gbtx.submitRequest;
	gbtx.submitRequest = function(oRequest) {

      var msg = oRequest.requestData;
		msg += ': ';
		text = decodeURIComponent(oRequest.requestData);
		text = text.replace(new RegExp('&xjx', 'g'), '\n&xjx');
		text = text.replace(new RegExp('<xjxobj>', 'g'), '\n<xjxobj>');
		text = text.replace(new RegExp('<e>', 'g'), '\n<e>');
		text = text.replace(new RegExp('</xjxobj>', 'g'), '\n</xjxobj>\n');
		msg += text;
		gbtx.debug.writeMessage(msg);
		msg = gbtx.debug.text[107];

		var separator = '\n';
		for (var mbr in oRequest.functionName) {
			msg += separator;
			msg += mbr;
			msg += ': ';
			msg += oRequest.functionName[mbr];
			separator = '\n';
		}
		msg += separator;
		msg += gbtx.debug.text[108];
		msg += separator;
		msg += oRequest.URI;
		gbtx.debug.writeMessage(msg);
		
		try {
			return gbtx.debug.submitRequest(oRequest);
		} catch (e) {
			gbtx.debug.writeMessage(e.message);
			if (0 < oRequest.retry)
				throw e;
		}
	}

	/*
		Function: initializeRequest
		
		Generate a message indicating that the request object is
		being initialized.
		
		This is a wrapper around the standard <gbtx.initializeRequest>
		function.
	*/
	gbtx.debug.initializeRequest = gbtx.initializeRequest;
	gbtx.initializeRequest = function(oRequest) {
		try {
			var msg = gbtx.debug.text[109];
			gbtx.debug.writeMessage(msg);
			return gbtx.debug.initializeRequest(oRequest);
		} catch (e) {
			var msg = 'InitializeRequest: ';
			msg += gbtx.debug.getExceptionText(e);
			msg += '\n';
			gbtx.debug.writeMessage(msg, gbtx.debug.text[101], 'errorText');
			throw e;
		}
	}

	/*
		Function: processParameters
		
		Generate a message indicating that the request object is
		being populated with the parameters provided.
		
		This is a wrapper around the standard <gbtx.processParameters>
		function.
	*/
	gbtx.debug.processParameters = gbtx.processParameters;
	gbtx.processParameters = function(oRequest) {
		try {
			if ('undefined' != typeof oRequest.parameters) {
				var msg = gbtx.debug.text[110];
				msg += oRequest.parameters.length;
				msg += gbtx.debug.text[111];
				gbtx.debug.writeMessage(msg);
			} else {
				var msg = gbtx.debug.text[112];
				gbtx.debug.writeMessage(msg);
			}
			return gbtx.debug.processParameters(oRequest);
		} catch (e) {
			var msg = 'ProcessParameters: ';
			msg += gbtx.debug.getExceptionText(e);
			msg += '\n';
			gbtx.debug.writeMessage(msg, gbtx.debug.text[101], 'errorText');
			throw e;
		}
	}

	/*
		Function: prepareRequest
		
		Generate a message indicating that the request is being
		prepared.  This may occur more than once for a request
		if it errors and a retry is attempted.
		
		This is a wrapper around the standard <gbtx.prepareRequest>
	*/
	gbtx.debug.prepareRequest = gbtx.prepareRequest;
	gbtx.prepareRequest = function(oRequest) {
		try {
			var msg = gbtx.debug.text[113];
			gbtx.debug.writeMessage(msg);
			return gbtx.debug.prepareRequest(oRequest);
		} catch (e) {
			var msg = 'PrepareRequest: ';
			msg += gbtx.debug.getExceptionText(e);
			msg += '\n';
			gbtx.debug.writeMessage(msg, gbtx.debug.text[101], 'errorText');
			throw e;
		}
	}

	/*
		Function: call
		
		Validates that a function name was provided, generates a message 
		indicating that a gbtx call is starting and sets a flag in the
		request object indicating that debugging is enabled for this call.
		
		This is a wrapper around the standard <gbtx.call> function.
	*/
	gbtx.debug.call = gbtx.call;
	gbtx.call = function() {
		try {
			gbtx.debug.writeMessage(gbtx.debug.text[114]);
			
			var numArgs = arguments.length;
			
			if (0 == numArgs)
				throw { code: 10009 };
			
			var functionName = arguments[0];
			var oOptions = {}
			if (1 < numArgs)
				oOptions = arguments[1];
			
			oOptions.debugging = true;
			
			return gbtx.debug.call(functionName, oOptions);
		} catch (e) {
			var msg = 'Call: ';
			msg += gbtx.debug.getExceptionText(e);
			msg += '\n';
			gbtx.debug.writeMessage(msg, gbtx.debug.text[101], 'errorText');
			throw e;
		}
	}

	/*
		Function: request
		
		Validates that a function name was provided, generates a message 
		indicating that a gbtx request is starting and sets a flag in the
		request object indicating that debugging is enabled for this request.
		
		This is a wrapper around the standard <gbtx.request> function.
	*/
	gbtx.debug.request = gbtx.request;
	gbtx.request = function() {
		try {
			gbtx.debug.writeMessage(gbtx.debug.text[115]);
			
			var numArgs = arguments.length;
			
			if (0 == numArgs)
				throw { code: 10010 };
			
			var oFunction = arguments[0];
			var oOptions = {}
			if (1 < numArgs)
				oOptions = arguments[1];
			
			oOptions.debugging = true;
			
			return gbtx.debug.request(oFunction, oOptions);
		} catch (e) {
			var msg = 'Request: ';
			msg += gbtx.debug.getExceptionText(e);
			msg += '\n';
			gbtx.debug.writeMessage(msg, gbtx.debug.text[101], 'errorText');
			throw e;
		}
	}

	/*
		Function: getResponseProcessor
		
		Generate an error message when no reponse processor is available
		to process the type of response returned from the server.
		
		This is a wrapper around the standard <gbtx.getResponseProcessor>
		function.
	*/
	gbtx.debug.getResponseProcessor = gbtx.getResponseProcessor;
	gbtx.getResponseProcessor = function(oRequest) {
		try {
			var fProc = gbtx.debug.getResponseProcessor(oRequest);
			
			if ('undefined' == typeof fProc) { 
				var msg = gbtx.debug.text[116];
				try {
					var contentType = oRequest.request.getResponseHeader('content-type');
					msg += "Content-Type: ";
					msg += contentType;
					if ('text/html' == contentType) {
						msg += gbtx.debug.text[117];
					}
				} catch (e) {
				}
				gbtx.debug.writeMessage(msg, gbtx.debug.text[101], 'errorText');
			}
			
			return fProc;
		} catch (e) {
			var msg = 'GetResponseProcessor: ';
			msg += gbtx.debug.getExceptionText(e);
			msg += '\n';
			gbtx.debug.writeMessage(msg, gbtx.debug.text[101], 'errorText');
			throw e;
		}
	}

	/*
		Function: responseReceived
		
		Generate a message indicating that a response has been received
		from the server; provide some statistical data regarding the
		response and the response time.
		
		Catch any exceptions that are thrown during the processing of
		the response and generate a message.
		
		This is a wrapper around the standard <gbtx.responseReceived>
		function.
	*/
	gbtx.debug.responseReceived = gbtx.responseReceived;
	gbtx.responseReceived = function(oRequest) {
		var xx = gbtx;
		var xt = xx.tools;
		var xd = xx.debug;
		
		var oRet;
		
		try {
			var status = oRequest.request.status;
			if (xt.arrayContainsValue(xx.responseSuccessCodes, status)) {
				var packet = oRequest.request.responseText;
				packet = packet.replace(new RegExp('<cmd', 'g'), '\n<cmd');
				packet = packet.replace(new RegExp('<xjx>', 'g'), '\n<xjx>');
				packet = packet.replace(new RegExp('<xjxobj>', 'g'), '\n<xjxobj>');
				packet = packet.replace(new RegExp('<e>', 'g'), '\n<e>');
				packet = packet.replace(new RegExp('</xjxobj>', 'g'), '\n</xjxobj>\n');
				packet = packet.replace(new RegExp('</xjx>', 'g'), '\n</xjx>');

            oRequest.midDate = new Date();
				var msg = gbtx.debug.text[118];
				msg += oRequest.request.status;
				msg += gbtx.debug.text[119];
				msg += packet.length;
				msg += gbtx.debug.text[120];
				msg += (oRequest.midDate - oRequest.beginDate);
				msg += gbtx.debug.text[121];
				msg += packet;

            //alert(packet.length+"\n"+packet);   // ahada burası
   			xd.writeMessage(msg);
			} else if (xt.arrayContainsValue(xx.responseErrorsForAlert, status)) {
				var msg = gbtx.debug.text[122];
				msg += status;
				msg += gbtx.debug.text[123];
				msg += oRequest.request.responseText;

				xd.writeMessage(msg, gbtx.debug.text[101], 'errorText');
			} else if (xt.arrayContainsValue(xx.responseRedirectCodes, status)) {
				var msg = gbtx.debug.text[124];
				msg += oRequest.request.getResponseHeader('location');
				xd.writeMessage(msg);

			}


			oRet = xd.responseReceived(oRequest);
		} catch (e) {
			var msg = 'ResponseReceived: ';
         msg += gbtx.debug.getExceptionText(e);
			msg += '\n';

			xd.writeMessage(msg, gbtx.debug.text[101], 'errorText');
            oRequest.midDate = new Date();
				var msg = gbtx.debug.text[118];

				msg += oRequest.request.status;
				msg += gbtx.debug.text[119];
				msg += packet.length;
				msg += gbtx.debug.text[120];
				msg += (oRequest.midDate - oRequest.beginDate);
				msg += gbtx.debug.text[121];
				msg += packet;


			 alert(msg);

		}

		return oRet;
	}

	/*
		Function: completeRequest
		
		Generate a message indicating that the request has completed
		and provide some statistics regarding the request and response.
		
		This is a wrapper around the standard <gbtx.completeResponse>
		function.
	*/
	gbtx.debug.completeResponse = gbtx.completeResponse;
	gbtx.completeResponse = function(oRequest) {
		try {
			var returnValue = gbtx.debug.completeResponse(oRequest);
			oRequest.endDate = new Date();
			var msg = gbtx.debug.text[125];
			msg += (oRequest.endDate - oRequest.beginDate);
			msg += gbtx.debug.text[126];
			gbtx.debug.writeMessage(msg);

			return returnValue;
		} catch (e) {
			var msg = 'CompleteResponse: ';
			msg += gbtx.debug.getExceptionText(e);
			msg += '\n';
			gbtx.debug.writeMessage(msg, gbtx.debug.text[101], 'errorText');
			throw e;
		}
	}

	/*
		Function: getRequestObject
		
		Generate a message indicating that the request object is 
		being initialized.
		
		Catch any exceptions that are thrown during the process or
		initializing a new request object.
		
		This is a wrapper around the standard <gbtx.getRequestObject>
		function.
	*/
	gbtx.debug.getRequestObject = gbtx.tools.getRequestObject;
	gbtx.tools.getRequestObject = function() {
		try {
			gbtx.debug.writeMessage(gbtx.debug.text[127]);
			return gbtx.debug.getRequestObject();
		} catch (e) {
			var msg = 'GetRequestObject: ';
			msg += gbtx.debug.getExceptionText(e);
			msg += '\n';
			gbtx.debug.writeMessage(msg, gbtx.debug.text[101], 'errorText');
			throw e;
		}
	}

	/*
		Function: assign
		
		Catch any exceptions thrown during the assignment and 
		display an error message.
		
		This is a wrapper around the standard <gbtx.dom.assign>
		function.
	*/
	if (gbtx.dom.assign) {
		gbtx.debug.assign = gbtx.dom.assign;
		gbtx.dom.assign = function(element, property, data) {
			try {
				return gbtx.debug.assign(element, property, data);
			} catch (e) {
				var msg = 'gbtx.dom.assign: ';
				msg += gbtx.debug.getExceptionText(e);
				msg += '\n';
				msg += 'Eval: element.';
				msg += property;
				msg += ' = data;\n';
				gbtx.debug.writeMessage(msg, gbtx.debug.text[101], 'errorText');
			}
			return true;
		}
	}

	/*
		Function: gbtx.tools.queue.retry
	*/
	if (gbtx.tools) {
		if (gbtx.tools.queue) {
			if (gbtx.tools.queue.retry) {
				if ('undefined' == typeof gbtx.debug.tools)
					gbtx.debug.tools = {};
				if ('undefined' == typeof gbtx.debug.tools.queue)
					gbtx.debug.tools.queue = {};
				gbtx.debug.tools.queue.retry = gbtx.tools.queue.retry;
				gbtx.tools.queue.retry = function(obj, count) {
					if (gbtx.debug.tools.queue.retry(obj, count))
						return true;
					// no 'exceeded' message for sleep command
					if (obj.cmd && 's' == obj.cmd)
						return false;
					gbtx.debug.writeMessage('Retry count exceeded.');
					return false;
				}
			}
		}
	}

	/*
		Boolean: isLoaded
		
		true - indicates that the debugging module is loaded
	*/
	gbtx.debug.isLoaded = true;

	/*
		Section: Redefine shortcuts.
		
		Must redefine these shortcuts so they point to the new debug (wrapper) versions:
		- <xjx.$>
		- <xjx.getFormValues>
		- <xjx.call>

		Must redefine these shortcuts as well:
		- <gbtx.$>
		- <gbtx.getFormValues>
	*/
	xjx = {}

	xjx.$ = gbtx.tools.$;
	xjx.getFormValues = gbtx.tools.getFormValues;
	xjx.call = gbtx.call;
	xjx.request = gbtx.request;

	gbtx.$ = gbtx.tools.$;
	gbtx.getFormValues = gbtx.tools.getFormValues;

} catch (e) {
	alert(e.name + ': ' + e.message);

}
