
	debug_microtime		= new Array ();

	function profile ( identificator, flag ) {

		date_		= new Date ();
		microtime	= date_.getTime ();

		if (flag == 'start') {			
			debug_microtime [identificator]	= new Array ();
			debug_microtime [identificator]['start'] = microtime;
		} else {
			debug_microtime [identificator]['end']	= microtime;
			
			difference	= (( microtime - debug_microtime [identificator]["start"] ) / 1000 );
			
			if (flag === 'reset') {
				//debug_microtime = new Array ();
				flag = "true";
			}

			if (flag == 'true') {
				//$postfix = ($no_measures > 1) ? " #".$no_measures : "";
				
				alert ( identificator + '\ntime: ' + difference );
			}

			return difference;
		}	
	}
	
			/*********************************************
			*	make_array_alert - function creates alerted debug string out of an array
			*
			*	@param		array		array to be converted to debug string
			*	@param		level		recursive depth of an array
			*	@access		private
			*	@return		string		converted debug string
			*	
			*	v1.0		Reizo June 2002
			*/
			function _make_array_alert (in_array, level) {
				var tab = '';
				for (var i = 0; i <= level; i++) {
					tab += '\t';
				}
				var alert_str = '';
				var i = 0;
				for (el in in_array) {
					switch (typeof in_array[el]) {
						case 'number':
						case 'string':	alert_str += (i == 0 ? ' ' : '\n' + tab) + '[' + el + '] => ' + in_array [el];
										break;
						case 'object':	alert_str += (i == 0 ? '' : '\n' + tab) + '[' + el + '] => array {\n' + tab + '\t' + _make_array_alert(in_array[el], level+1) + '}';
					}
					i++;
				}
				return alert_str;
			}
	
	/*********************************************
	*	jsDebug - JavaScript Alert debuging function
	*
	*	@param		mixed		variable to debug
	*	@param		int			number of rows in page of debug alert
	*	@access		public
	*	@return		boolean		always true
	*	
	*	v0.87		Reizo June 2002
	*/
	function dbg (a, rows_in_page) {
		var alert_str;
		var comment;
		
		var res = typeof a;
		switch (res) {
			case 'number': 	
			case 'string': 	alert_str = res + ' : ' + a;
							break;
			case 'object': 	alert_str = (a.length != null ? 'array {\n\t' + _make_array_alert(a, 0) + '}' : 'Object is not an array !');
							break;
		}
		
		var rows = new Array();
		rows = alert_str.split('\n');
		var rows_length = rows.length;
		
		if (!rows_in_page) rows_in_page = 50;
		
		for (var page = 0; rows_in_page*page < rows_length; page++) {
			var page_alert_str = '';
			for (var i = page*rows_in_page; i < (page+1)*rows_in_page && i < rows_length; i++) {
				page_alert_str += '\n' + rows[i];
			}
			alert((comment ? comment : '') + '\tpage ' + (page  + 1) + ' of ' + Math.ceil(rows_length/rows_in_page) + '\n' + page_alert_str); //+ '\n\nJS debuger v0.87');
		}
		
		return true;
	}
	
	
	var _jsDebugConsole;
			
			function _debugCreateConsole ()
			{
				_jsDebugConsole = window.open("","console","width=560,height=600,resizable,scrollbars=yes");
				_jsDebugConsole.document.write("<html><title>JavaScript Debug Console</title><body bgcolor=#ffffff>");
				_jsDebugConsole.document.write("<div id=\'divContent\' style=\'width:100%;height:100%;font-size:12px;font-family:courier\'></div>");
				_jsDebugConsole.document.write("</body></html>");
				_jsDebugConsole.document.close();
			}

			function _debugToConsole (txt, type, title, style)
			{
				if (!_jsDebugConsole || _jsDebugConsole.closed)
					_debugCreateConsole ();
				
				
				if (!style)
					style = 'append';
				
				var oldTxt = '';	
				if (style == 'append')
					oldTxt = _jsDebugConsole.divContent.innerHTML;
					
				var fill = '<pre>';
				if (title)
					fill = '<pre><font color=\'#FF0000\'>' + title + ' - ' + type + '</font><br>';
					
				_jsDebugConsole.divContent.innerHTML = fill + txt + oldTxt;
			}
	
	
	function debug (variable, label, style)
	{
		var type = typeof (variable);
		var fill;
		
		switch (type)
		{
			case 'string':
				fill = '\'' + variable + '\'';
				break;
			case 'number':
			case 'boolean':
				fill = variable;
				break;
			case 'object':
				fill = _debugArray (variable);
				break;
		}
		
		_debugToConsole (fill, type, label, style);
	}
	
	
			function _debugArray (variable, level)
			{
				if (!level)
					level = 0;
			
				var tab = '';
				for (var i = 0; i < level; i++)
					tab += '\t';
					
				var fill = '';
				
				for (var n in variable)
				{
					switch (typeof variable [n])
					{
						case 'number':
						case 'boolean':
							fill += tab + '[' + n + '] => ' + variable [n] + '\n';
							break;
						case 'string':
							fill += tab + '[' + n + '] => \'' + variable [n] + '\'\n';
							break;
							
						case 'object':
							fill += tab + '[' + n + '] => array {\n';
							fill += _debugArray (variable [n], level + 1);
							fill += tab + '}\n';
							
							break;
							
						default:
							break;
					}
				}
				
				return fill;
			}