
	if ( !qFlux )
		{ var qFlux = {}; }
	qFlux.browser = {};
	qFlux.browser.listCount = 16;
	qFlux.browser.listStep = qFlux.browser.listCount * 21 + 11;
	qFlux.browser.scroll = 0;
	qFlux.browser.focus = 0;
	qFlux.browser.interval = 0;
	qFlux.browser.text = {};
	qFlux.browser.map = {};
	qFlux.browser.color = {};
	qFlux.browser.color['neutral'] = [70, 80, 100];
	qFlux.browser.color['start'] = [90, 130, 90];
	qFlux.browser.color['end'] = [90, 100, 130];
	qFlux.browser.color['objective'] = [150, 130, 80];
	qFlux.browser.color['focus'] = [200, 130, 50];
	qFlux.browser.color['location_focus'] = [210, 20, 0];
	qFlux.browser.color['location_confirm'] = [50, 150, 50];
	qFlux.browser.color['location_wowhead'] = [160, 120, 50];
	qFlux.browser.color['container'] = [50, 50, 50];
	qFlux.browser.color['include'] = [0, 80, 0];
	
	//####################################################################################################
	
	qFlux.wheelQueue.push([['id','quest_list'],'qFlux.browser.questMouseWheel']);
	qFlux.wheelQueue.push([['id','quest_slider'],'qFlux.browser.questMouseWheel']);
	qFlux.wheelQueue.push([['id','quest_thumb'],'qFlux.browser.questMouseWheel']);
	qFlux.wheelQueue.push([['className','quest'],'qFlux.browser.questMouseWheel']);
	qFlux.mouseQueue.push([['id','quest_thumb'],0,'qFlux.browser.listSliderMove']);
	
	//####################################################################################################
	
	qFlux.browser.showQuestList = function()
		{
			var container = document.getElementById('quest_list');
			while ( container.firstChild )
				{ container.removeChild(container.firstChild); }
			if ( qFlux.map.map == 'Cosmic' || qFlux.map.map == 'World' || qFlux.map.map == 28 || qFlux.map.map == 39 || qFlux.map.map == 5 || qFlux.map.map == 46 )
				{
					document.getElementById('quest_none').style.display = 'block';
					return;
				}
			document.getElementById('quest_none').style.display = 'none';
			var index = qFlux.browser.scroll < 0 ? 0 : qFlux.browser.scroll;
			while ( qFlux.browser.link[index] )
				{
					var data = qFlux.browser.quest[qFlux.browser.link[index]];
					node = document.createElement('div');
					node.className = 'quest';
					node.index = index;
					node.onmousedown = qFlux.browser.focusQuest;
					node.innerHTML = data[0].length > 25 ? data[0].slice(0, 25) + '...' : data[0];
					var color = qFlux.browser.color['neutral'];
					if ( index == qFlux.browser.focus )
						{ color = qFlux.browser.color['focus']; }
					node.style.borderColor = 'rgb(' + ( color[0] + 30 ) + ',' + ( color[1] + 30 ) + ',' + ( color[2] + 30 ) + ')';
					if ( qFlux.editor && qFlux.editor.content[qFlux.browser.link[index]] )
						{ color = qFlux.browser.color['include']; }
					node.style.color = 'rgb(' + ( color[0] + 100 ) + ',' + ( color[1] + 100 ) + ',' + ( color[2] + 100 ) + ')';
					container.appendChild(node);
					index++;
					if ( index >= qFlux.browser.scroll + qFlux.browser.listCount )
						{ break; }
				}
		}
	
	//####################################################################################################
	
	qFlux.browser.questMouseWheel = function(target, delta)
		{
			if ( qFlux.browser.link.length < qFlux.browser.listCount )
				{ return; }
			var count = qFlux.browser.link.length - qFlux.browser.listCount;
			if ( delta < 0 )
				{
					if ( qFlux.browser.scroll < count )
						{ qFlux.browser.scroll += 1; }
				}
			else if ( qFlux.browser.scroll > 0 )
				{ qFlux.browser.scroll -= 1; }
			document.getElementById('quest_thumb').style.top = qFlux.browser.scroll * qFlux.browser.listStep/count + 3 + 'px';
			qFlux.browser.showQuestList();
		}
	
	//####################################################################################################

	qFlux.browser.focusQuest = function()
		{
			qFlux.browser.setListFocus(qFlux.browser.link[this.index]);
			qFlux.browser.showQuestStructure(qFlux.browser.link[this.index]);
			qFlux.browser.showQuestInfo(qFlux.browser.link[this.index]);
			qFlux.browser.setMapFocus('quest', qFlux.browser.link[this.index]);
			if ( qFlux.editor )
				{ qFlux.editor.focusQuest(qFlux.browser.link[this.index]); }
			if ( qFlux.maintenance )
				{
					qFlux.maintenance.type = 'quest';
					qFlux.maintenance.id = qFlux.browser.link[this.index];
				}
		}
	
	//####################################################################################################

	qFlux.browser.setListFocus = function(quest)
		{
			qFlux.browser.focus = -1;
			for ( var i in qFlux.browser.link )
				{
					if ( qFlux.browser.link[i] == quest )
						{
							qFlux.browser.focus = i;
							break;
						}
				}
			qFlux.browser.setListSlider(qFlux.browser.link.length);
			qFlux.browser.showQuestList();
		}
	
	//####################################################################################################

	qFlux.browser.setListSlider = function(count)
		{
			if ( count <= qFlux.browser.listCount )
				{
					qFlux.browser.scroll = 0;
					document.getElementById('quest_slider').style.display = 'none';
					return;
				}
			document.getElementById('quest_slider').style.display = 'block';
			if ( qFlux.browser.focus < qFlux.browser.scroll || qFlux.browser.focus > qFlux.browser.scroll + (qFlux.browser.listCount - 1) )
				{
					if ( qFlux.browser.focus <= 0 )
						{ qFlux.browser.scroll = 0; }
					else if ( qFlux.browser.focus < count - (qFlux.browser.listCount - 1) )
						{ qFlux.browser.scroll = qFlux.browser.focus - 1; }
					else
						{ qFlux.browser.scroll = count - qFlux.browser.listCount; }
				}
			else if ( qFlux.browser.scroll + qFlux.browser.listCount > count )
				{ qFlux.browser.scroll = count - qFlux.browser.listCount; }
			document.getElementById('quest_thumb').style.top = qFlux.browser.scroll * qFlux.browser.listStep/(count - qFlux.browser.listCount) + 3 + 'px';
		}
	
	//####################################################################################################
	
	qFlux.browser.listSliderMouseDown = function(event)
		{
			if ( event == null )
				{ event = window.event; }
			var target = ( event.target == null ? event.srcElement : event.target );
			var top = event.clientY - qFlux.absTop(target) - 10;
			if ( target.id != 'quest_slider' )
				{ return; }
			target = document.getElementById('quest_thumb');
			qFlux.dragElement = target;
			qFlux.browser.listSliderMove(null, 0, top);
			qFlux.dragStartX = event.clientX;
			qFlux.dragStartY = event.clientY;
			qFlux.dragOffsetX = 3;
			qFlux.dragOffsetY = top;
			qFlux.dragZ = target.style.zIndex;
			target.style.zIndex = 9;
			target.ondragstart = function() { return false; };
			document.onmousemove = qFlux.mouseMove;
			document.body.focus();
			document.onselectstart = function () { return false; };
		}
	
	//####################################################################################################
	
	qFlux.browser.listSliderMove = function(event, left, top)
		{
			if ( top < 3 )
				{ top = 0; }
			else if ( top > qFlux.browser.listStep )
				{ top = qFlux.browser.listStep; }
			qFlux.dragElement.style.top = top + 3 + 'px';
			qFlux.browser.scroll = Math.round(top/qFlux.browser.listStep * (qFlux.browser.link.length - qFlux.browser.listCount));
			qFlux.browser.showQuestList();
		}

	//####################################################################################################
	
	qFlux.browser.assembleMapQuests = function(map)
		{
			qFlux.browser.link = [];
			for ( var id in qFlux.browser.quest )
				{
					if ( qFlux.browser.quest[id][7] == 0 )
						{ continue; }
					for ( var i in qFlux.browser.quest[id][7] )
						{
							if ( qFlux.browser.quest[id][7][i] == map )
								{
									qFlux.browser.link.push(id);
									break;
								}
						}
				}
			qFlux.browser.link.sort(qFlux.browser.sortLink);
		}
	
	//####################################################################################################

	qFlux.browser.sortLink = function(a, b)
		{ return ( qFlux.browser.quest[a][0] == qFlux.browser.quest[b][0] ) ? 0 : ( qFlux.browser.quest[a][0] > qFlux.browser.quest[b][0] ) ? 1 : -1; }

	//####################################################################################################

	qFlux.browser.clearSelection = function()
		{
			document.getElementById('detail_header').innerHTML = '';
			document.getElementById('detail_left').innerHTML = '';
			document.getElementById('detail_right').innerHTML = '';
			document.getElementById('detail_error').style.display = 'none';
			document.getElementById('detail_none').style.display = 'block';
		}
	
	//####################################################################################################
	
	qFlux.browser.showQuestStructure = function(id)
		{
			document.getElementById('detail_none').style.display = 'none';
			document.getElementById('error_create').style.display = 'none';
			document.getElementById('message_text').innerHTML = '';
			var quest = qFlux.browser.quest[id];
			qFlux.browser.messageType = 'quest';
			qFlux.browser.messageID = id;
			document.getElementById('detail_header').innerHTML = ( qFlux.maintenance ? '<div class=\"toggle_maintenance\" onmousedown=\"qFlux.maintenance.toggle()\"/></div>' : '' ) + quest[0] + '<a href=\"http://' + ( qFlux.browser.language != 'en' ? qFlux.browser.language : 'www' ) + '.wowhead.com/?quest=' + id + '\"><img src="transparent.gif" class="wowhead"/></a><small>' + qFlux.browser.text['quest'] + ' ' + qFlux.browser.text['contribute'] + ' <b>' + qFlux.browser.author[qFlux.browser.quest[id][1]] + '</b></small>';
			document.getElementById('detail_error').style.display = 'block';
			document.getElementById('error_note').style.display = 'block';
			var types = ['npc', 'item', 'object', 'string'];
			var container = document.getElementById('detail_left');
			while ( container.firstChild )
				{ container.removeChild(container.firstChild); }
			container.style.display = 'block';
			if ( quest[13] != 0 )
				{
					node = document.createElement('h5');
					node.innerHTML = qFlux.browser.text['condition'];
					container.appendChild(node);
					var faction = ['neutral', 'alliance', 'horde'];
					for ( var i in quest[13] )
						{
							var condition = qFlux.browser.quest[quest[13][i]];
							node = qFlux.browser.createDetailNode('quest', 'neutral', quest[13][i], ( condition[9] > 0 ? qFlux.browser.text[faction[condition[9]]] + ': ' : '' ) + condition[0]);
							container.appendChild(node);
						}
				}
			var node = document.createElement('h5');
			node.innerHTML = qFlux.browser.text['structure'];
			container.appendChild(node);
			node = qFlux.browser.createDetailNode(types[quest[2]], 'start', quest[3], qFlux.browser[types[quest[2]]][quest[3]][0], id);
			container.appendChild(node);
			if ( qFlux.browser.quest[id][6] != 0 )
				{
					var subtype = ['#1','#2','#3','#4','#5'];
					for ( var i in quest[6] )
						{
							var objective = quest[6][i];
							node = qFlux.browser.createDetailNode(types[objective[0]], subtype[i], objective[1], ( objective[2] ? objective[2] + ' x ': '' ) + qFlux.browser[types[objective[0]]][objective[1]][0], id);
							container.appendChild(node);
						}
				}
			node = qFlux.browser.createDetailNode(types[quest[4]], 'end', quest[5], qFlux.browser[types[quest[4]]][quest[5]][0], id);
			container.appendChild(node);
			followUp = false;
			for ( var i in qFlux.browser.quest )
				{
					if ( qFlux.browser.quest[i][13] == 0 )
						{ continue; }
					for ( var n in qFlux.browser.quest[i][13] )
						{
							if ( qFlux.browser.quest[i][13][n] == id )
								{
									if ( !followUp )
										{
											node = document.createElement('h5');
											node.innerHTML = qFlux.browser.text['followup'];
											container.appendChild(node);
											followUp = true;
										}
									node = qFlux.browser.createDetailNode('quest', 'neutral', i, qFlux.browser.quest[i][0]);
									container.appendChild(node);
								}
						}
				}
		}
	
	//####################################################################################################
	
	qFlux.browser.showQuestInfo = function(id)
		{
			var quest = qFlux.browser.quest[id];
			var container = document.getElementById('detail_right');
			while ( container.firstChild )
				{ container.removeChild(container.firstChild); }
			container.style.display = 'block';
			node = document.createElement('h5');
			node.innerHTML = qFlux.browser.text['fact'];
			container.appendChild(node);
			var list = document.createElement('ul');
			container.appendChild(list);
			var faction = ['neutral', 'alliance', 'horde'];
			node = document.createElement('li');
			node.innerHTML = qFlux.browser.text[faction[quest[9]]];
			list.appendChild(node);
			if ( quest[10] != 0 )
				{
					var race = [ 0, 'Human', 'Dwarf', 'NightElf', 'Gnome', 'Draenei', 'Orc', 'Scourge', 'Tauren', 'Troll', 'BloodElf' ];
					node = document.createElement('li');
					node.innerHTML = (quest[10][1] > 0 ? qFlux.browser.text['all_but_race'] + ' ' : '' ) + '<span>' + qFlux.browser.text[race[quest[10][0]]] + '</span>';
					list.appendChild(node);
				}
			if ( quest[11] != 0 )
				{
					var class = [ 0, 'WARRIOR', 'PALADIN', 'HUNTER', 'ROGUE', 'PRIEST', 'DEATHKNIGHT', 'SHAMAN', 'MAGE', 'WARLOCK', 'DRUID' ];
					node = document.createElement('li');
					node.innerHTML = (quest[11][1] > 0 ? qFlux.browser.text['all_but_class'] + ' ' : '' ) + '<span>' + qFlux.browser.text[class[quest[11][0]]] + '</span>';
					list.appendChild(node);
				}
			if ( quest[12] != 0 )
				{
					var skill = [ 0, 'Blacksmithing', 'Leatherworking', 'Alchemy', 'Herbalism', 'Mining', 'Tailoring', 'Engineering', 'Enchanting', 'Skinning', 'Jewelcrafting', 'Inscription', 'FirstAid', 'Cooking', 'Fishing' ];
					node = document.createElement('li');
					node.innerHTML = (quest[12][1] > 0 ? qFlux.browser.text['all_but_skill'] + ' ' : '' ) + '<span>' + qFlux.browser.text[skill[quest[12][0]]] + '</span>';
					list.appendChild(node);
				}
			node = document.createElement('li');
			node.innerHTML = quest[7] != 0 ? qFlux.browser.text['level'] + ' ' + quest[8] : qFlux.browser.text['level_none'];
			list.appendChild(node);
			node = document.createElement('li');
			node.innerHTML = quest[14] > 0 ? quest[14] + ' ' + qFlux.browser.text['experience'] : qFlux.browser.text['experience_none'];
			list.appendChild(node);
			if ( quest[15] != 0 )
				{
					for ( var i in quest[15] )
						{
							node = document.createElement('li');
							node.innerHTML = quest[15][i][1] + ' ' + qFlux.browser.faction[quest[15][i][0]];
							list.appendChild(node);
						}
				}
		}
	
	//####################################################################################################

	qFlux.browser.showObject = function(type, id, count)
		{
			document.getElementById('detail_none').style.display = 'none';
			document.getElementById('error_create').style.display = 'none';
			document.getElementById('message_text').innerHTML = '';
			var types = ['npc', 'item', 'object', 'string', 'event'];
			qFlux.browser.messageType = type;
			qFlux.browser.messageID = id;
			document.getElementById('detail_header').innerHTML = ( qFlux.maintenance && ( !qFlux.editor || qFlux.editor.focus < 0 ) ? '<div class=\"toggle_maintenance\" onmousedown=\"qFlux.maintenance.toggle()\"/></div>' : '' ) + ( count != null ? count + ' x ' : '' ) + qFlux.browser[type][id][0] + '<small>' + qFlux.browser.text[( type == 'string' ? types[qFlux.browser[type][id][3]] : type )] + ' ' + qFlux.browser.text['contribute'] + ' <b>' + qFlux.browser.author[qFlux.browser[type][id][1]] + '</b></small>';
			document.getElementById('detail_error').style.display = 'block';
			document.getElementById('error_note').style.display = 'block';
			var container = document.getElementById('detail_left');
			while ( container.firstChild )
				{ container.removeChild(container.firstChild); }
			container.style.display = 'block';
			container = document.getElementById('detail_right');
			while ( container.firstChild )
				{ container.removeChild(container.firstChild); }
			container.style.display = 'block';
			var nodes = qFlux.browser.getObjectData(type, id);
			var setting = {};
			setting.start = ['left', 'neutral', 'start'];
			setting.end = ['right', 'neutral', 'end'];
			setting.objective = ['left', 'neutral', 'objective'];
			setting.container = ['left', 'container', 'container'];
			setting.contained = ['left', 'container', 'contained'];
			for ( var i in nodes )
				{
					if ( nodes[i].length == 0 )
						{ continue; }
					container = document.getElementById('detail_' + setting[i][0]);
					node = document.createElement('h5');
					node.innerHTML = qFlux.browser.text[setting[i][2]];
					container.appendChild(node);
					for ( var n in nodes[i] )
						{
							node = qFlux.browser.createDetailNode(nodes[i][n][0], setting[i][1], nodes[i][n][1], qFlux.browser[nodes[i][n][0]][nodes[i][n][1]][0]);
							container.appendChild(node);
						}
				}
		}
	
	//####################################################################################################

	qFlux.browser.getObjectData = function(type, id)
		{
			var types = ['npc', 'item', 'object', 'string', 'event'];
			var result = { start:[], end:[], objective:[], container:[], contained:[] };
			for ( var quest in qFlux.browser.quest )
				{
					if ( types[qFlux.browser.quest[quest][2]] == type && qFlux.browser.quest[quest][3] == id )
						{ result.start.push(['quest', quest]); }
					if ( types[qFlux.browser.quest[quest][4]] == type && qFlux.browser.quest[quest][5] == id )
						{ result.end.push(['quest', quest]); }
					for ( var objective in qFlux.browser.quest[quest][6] )
						{
							if ( types[qFlux.browser.quest[quest][6][objective][0]] == type && qFlux.browser.quest[quest][6][objective][1] == id )
								{ result.objective.push(['quest', quest]); }
						}
				}
			if ( type == 'item' )
				{
					if ( qFlux.browser[type][id][2] )
						{
							for ( var i in qFlux.browser[type][id][2] )
								{ result.contained.push([types[qFlux.browser[type][id][2][i][0]], qFlux.browser[type][id][2][i][1]]); }
						}
				}
			else
				{
					for ( var i in qFlux.browser.item )
						{
							if ( !qFlux.browser.item[i][2] )
								{ continue; }
							for ( var n in qFlux.browser.item[i][2] )
								{
									if ( types[qFlux.browser.item[i][2][n][0]] == type && qFlux.browser.item[i][2][n][1] == id )
										{ result.container.push(['item', i]); }
								}
						}
				}
			return result;
		}
	
	//####################################################################################################
	
	qFlux.browser.createDetailNode = function(type, subtype, id, text, quest)
		{
			var node = document.createElement('p');
			var color;
			node.innerHTML = text.length > 28 ? text.slice(0, 28) + '...' : text;
			node.className = 'object';
			if ( subtype == 'start' || subtype == 'end' || subtype == 'neutral' || subtype == 'container' )
				{ color = qFlux.browser.color[subtype]; }
			else
				{ color = qFlux.browser.color.objective; }
			if ( subtype == 'neutral' )
				{
					node.style.backgroundColor = 'transparent';
					if ( type == 'quest' && qFlux.editor )
						{
							if ( qFlux.editor.focus >= 0 && qFlux.editor.task[qFlux.editor.focus][0] < 4 && qFlux.editor.task[qFlux.editor.focus][1] == id )
								{ color = qFlux.browser.color['focus']; }
						}
				}
			else
				{ node.style.backgroundColor = 'rgb(' + color[0] + ',' + color[1] + ',' + color[2] + ')'; }
			node.style.borderColor = 'rgb(' + ( color[0] + 50 ) + ',' + ( color[1] + 50 ) + ',' + ( color[2] + 50 ) + ')';
			if (  type == 'quest' && qFlux.editor && qFlux.editor.content[id] )
				{ color = qFlux.browser.color['include']; }
			node.style.color = 'rgb(' + ( color[0] + 100 ) + ',' + ( color[1] + 100 ) + ',' + ( color[2] + 100 ) + ')';
			node.targetType = type;
			node.targetID = id;
			if ( quest != null )
				{
					node.quest = quest;
					if ( subtype == 'start' || subtype == 'end' )
						{ node.phase = subtype; }
					else
						{ node.phase = Number(subtype.substr(1,1)); }
						
				}
			node.onmousedown = qFlux.browser.nodeMouseDown;
			return node;
		}
	
	//####################################################################################################
	
	qFlux.browser.nodeMouseDown = function()
		{
			if ( this.targetType == 'quest' )
				{
					
					if ( qFlux.editor )
						{ qFlux.editor.focusQuest(this.targetID); }
					qFlux.browser.setListFocus(this.targetID);
					qFlux.browser.showQuestStructure(this.targetID);
					qFlux.browser.showQuestInfo(this.targetID);
					qFlux.browser.setMapFocus('quest', this.targetID);
				}
			else
				{
					var count;
					if ( qFlux.editor && qFlux.editor.focusQuestTask(this.quest, this.phase) )
						{
							qFlux.browser.setListFocus(this.quest);
							if ( this.phase != 'start' && this.phase != 'end' && qFlux.browser.quest[this.quest][6][this.phase - 1][2] )
								{ count = qFlux.browser.quest[this.quest][6][this.phase - 1][2]; }
						}
					else
						{ qFlux.browser.setListFocus(0); }
					qFlux.browser.showObject(this.targetType, this.targetID, count ? count : null );
					qFlux.browser.setMapFocus(this.targetType, this.targetID);
				}
			if ( qFlux.maintenance )
				{
					qFlux.maintenance.type = this.targetType;
					qFlux.maintenance.id = this.targetID;
				}
		}
	
	//####################################################################################################
	
	qFlux.browser.showStatus = function(type, text, time)
		{
			qFlux.browser.status = text;
			var status = document.getElementById('status');
			status.innerHTML = '<p>' + qFlux.browser.status + '</p>';
			if ( type == 'error' )
				{ status.style.backgroundColor = 'rgb(255,150,100)'; }
			else
				{ status.style.backgroundColor = 'rgb(210,210,210)'; }
			status.style.display = 'block';
			if ( time )
				{
					if ( time > 0 )
						{ window.setTimeout("qFlux.browser.clearStatus()", time); }
				}
			else
				{ qFlux.browser.intervalHandler = window.setInterval("qFlux.browser.statusProgress()", 150); }
		}
	
	//####################################################################################################
	
	qFlux.browser.clearStatus = function()
		{
			qFlux.browser.status = null;
			document.getElementById('status').style.display = 'none';
			if ( qFlux.browser.intervalHandler != null )
				{
					window.clearInterval(qFlux.browser.intervalHandler);
					qFlux.browser.intervalHandler = null;
					qFlux.browser.interval = 0;
				}
		}
	
	//####################################################################################################
	
	qFlux.browser.statusProgress = function()
		{
			if ( qFlux.browser.interval > 5 )
				{ qFlux.browser.interval = 0; }
			var interval = ' ';
			for ( var i = 1; i <= qFlux.browser.interval; i++ )
				{ interval += '.'; }
			document.getElementById('status').innerHTML = '<p>' + qFlux.browser.status + interval + '</p>';
			qFlux.browser.interval++;
		}
	
	//####################################################################################################
	
	qFlux.browser.toggleDetailMessage = function()
		{
			document.getElementById('message_text').value = '';
			var container = document.getElementById('error_create');
			if ( !container.style.display || container.style.display == 'none' )
				{
					document.getElementById('error_note').style.display = 'none';
					container.style.display = 'block';
				}
			else
				{
					container.style.display = 'none';
					document.getElementById('error_note').style.display = 'block';
				}
		}
	
	//####################################################################################################
	
	qFlux.browser.sendDetailMessage = function()
		{
			var text = document.getElementById('message_text').value;
			qFlux.browser.toggleDetailMessage();
			if ( text == '' || text.length < 3 )
				{ return; }
			else if ( text.length > 1024 )
				{ text = text.slice(0, 1024); }
			qFlux.xmlHttpRequest('browser.php', 'action=message&guide=' + qFlux.browser.id + '&type=' + qFlux.browser.messageType + '&id=' + qFlux.browser.messageID + '&text=' + text, 'qFlux.browser.receiveDetailMessage');
		}
	
	//####################################################################################################
	
	qFlux.browser.receiveDetailMessage = function()
		{
			if ( xmlHttp.readyState != 4 && xmlHttp.readyState != 'complete' )
				{ return; }
			qFlux.xmlHttpSend();
		}

	//####################################################################################################
	
	qFlux.browser.requestMap = function(map)
		{
			if ( qFlux.browser.map[map][3] )
				{ qFlux.browser.selectMap(map); }
			else
				{
					qFlux.xmlHttpRequest('browser.php', 'action=map&map=' + qFlux.browser.map[map][0] + ( qFlux.editor ? '&guide=' + qFlux.editor.id : '' ), 'qFlux.browser.receiveMap');
					qFlux.browser.showStatus('server', qFlux.browser.text['map']);
				}
		}
	
	//####################################################################################################

	qFlux.browser.receiveMap = function()
		{
			if ( xmlHttp.readyState != 4 && xmlHttp.readyState != 'complete' )
				{ return; }
			qFlux.browser.clearStatus();
			if ( xmlHttp.responseText == 'database' )
				{ qFlux.browser.showStatus('error', qFlux.browser.text['database'], 5000); }
			else if ( xmlHttp.responseText != '' )
				{
					eval(xmlHttp.responseText);
					qFlux.browser.processData(result[1]);
					qFlux.browser.map[result[0]][3] = true;
					qFlux.browser.selectMap(result[0]);
				}
			else
				{ qFlux.browser.showStatus('error', qFlux.browser.text['server'], 5000); }
			qFlux.xmlHttpSend();
		}
	
	//####################################################################################################
	
	qFlux.browser.processData = function(data)
		{
			for ( var type in data )
				{
					if ( !qFlux.browser[type] )
						{ qFlux.browser[type] = {}; }
					for ( var id in data[type] )
						{
							if ( type == 'quest' || type == 'item' || type == 'author' )
								{ qFlux.browser[type][id] = data[type][id]; }
							else if ( !data[type][id][2] )
								{ qFlux.browser[type][id] = data[type][id]; }
							else
								{
									var map = qFlux.map.translate(data[type][id][2]);
									if ( type == 'string' && data[type][id][3] )
										{ qFlux.browser[type][id] = [data[type][id][0], data[type][id][1], map, data[type][id][3]]; }
									else
										{ qFlux.browser[type][id] = [data[type][id][0], data[type][id][1], map]; }
								}
						}
				}
		}
	
	//####################################################################################################

	qFlux.browser.selectMap = function(map)
		{
			qFlux.map.select(map, qFlux.browser.map[map][0]);
			qFlux.browser.header();
			if ( qFlux.maintenance && document.getElementById('container_maintenance').style.display == 'block' )
				{
					document.getElementById('container_maintenance').style.display = 'none';
					document.getElementById('container_location').style.display = 'none';
					document.getElementById('map_option').style.display = 'block';
					document.getElementById('container_quest').style.display = 'block';
					if ( qFlux.editor )
						{
							document.getElementById('container_detail').style.display = 'block';
							document.getElementById('container_task').style.display = 'block';
							document.getElementById('container_guide').style.display = 'block';
						}
					else
						{
							document.getElementById('detail_left').style.display = 'block';
							document.getElementById('detail_right').style.display = 'block';
							document.getElementById('detail_error').style.display = 'block';
						}
				}
			if ( qFlux.browser.map[map][2] != 0 && qFlux.browser.map[map][2] != 'Cosmic' && qFlux.browser.map[map][2] != 'World' )
				{
					qFlux.map.isLocked = false;
					qFlux.browser.showZone();
					qFlux.browser.assembleMapQuests(map);
					if ( qFlux.editor && qFlux.editor.focus >= 0 )
						{
							if ( qFlux.editor.task[qFlux.editor.focus][0] < 4 )
								{ qFlux.browser.setListFocus(qFlux.editor.task[qFlux.editor.focus][1]); }
							else
								{
									qFlux.browser.setListFocus(0);
									if ( qFlux.editor.task[qFlux.editor.focus][0] == 5 )
										{ qFlux.editor.toggleMapSelection(); }
								}
						}
					else
						{ qFlux.browser.setListFocus(0); }
				}
			else
				{
					qFlux.browser.clearSelection();
					qFlux.map.isLocked = true;
					qFlux.browser.showContinent();
					qFlux.browser.link = [];
					qFlux.browser.setListFocus(0);
					if ( qFlux.editor )
						{
							if ( qFlux.editor.focus >= 0 )
								{
									if ( qFlux.editor.task[qFlux.editor.focus][0] < 4 )
										{
											qFlux.editor.focus = -1;
											qFlux.editor.setListSlider(qFlux.editor.task.length);
											qFlux.editor.showTaskList();
											qFlux.editor.showAssemble();
										}
									else if ( qFlux.editor.task[qFlux.editor.focus][0] == 5 )
										{ qFlux.editor.toggleMapSelection(); }
								}
							else
								{
									qFlux.editor.quest = 0;
									qFlux.editor.showTaskList();
									qFlux.editor.showAssemble();
								}
						}
				}
		}
	
	//####################################################################################################
	
	qFlux.browser.header = function()
		{
			var header = document.getElementById('map_header');
			while ( header.firstChild )
				{ header.removeChild(header.firstChild); }
			qFlux.browser.headerNode('Cosmic');
			if ( qFlux.map.map == 'Cosmic' )
				{ return; }
			if ( qFlux.browser.map[qFlux.map.map][2] == 39 || qFlux.browser.map[qFlux.map.map][2] == 5 || qFlux.browser.map[qFlux.map.map][2] == 46 )
				{ qFlux.browser.headerNode('World'); }
			if ( qFlux.browser.map[qFlux.map.map][2] != 'Cosmic' )
				{ qFlux.browser.headerNode(qFlux.browser.map[qFlux.map.map][2]); }	
			qFlux.browser.headerNode(qFlux.map.map);
		}
	
	//####################################################################################################

	qFlux.browser.headerNode = function(map)
		{
			var header = document.getElementById('map_header');
			if ( map != 'Cosmic' )
				{
					var image = document.createElement('img');
					image.src = 'transparent.gif';
					header.appendChild(image);
				}
			var node = document.createElement('span');
			node.innerHTML = qFlux.browser.map[map][1];
			node.onmousedown = function() { qFlux.browser.selectMap(map) };
			header.appendChild(node);
		}
	
	//####################################################################################################
	
	qFlux.browser.showContinent = function()
		{
			var container = document.getElementById('map');
			var index = 0;
			for ( var i in qFlux.browser.map )
				{
					if ( qFlux.browser.map[i][2] != qFlux.map.map )
						{ continue; }
					var style = 'neutral';
					if ( qFlux.browser.map[i][4] > 0 )
						{ style = 'objective'; }
					qFlux.map.point(index, qFlux.browser.map[i][5], qFlux.browser.map[i][6], style, 'zone', i, qFlux.browser.zoneMouseOver, qFlux.browser.zoneMouseOut, qFlux.browser.zoneMouseDown);
					index++;
				}
		}
	
	//####################################################################################################
	
	qFlux.browser.zoneMouseOver = function(event)
		{
			if ( event == null )
				{ event = window.event; }
			var target = ( event.target == null ? event.srcElement : event.target );
			target.style.backgroundPosition = qFlux.map.color['focus'];
			target.style.zIndex = 3;
			var tooltip = document.getElementById('tooltip');
			while ( tooltip.firstChild )
				{ tooltip.removeChild(tooltip.firstChild); }
			var node = document.createElement('div');
			tooltip.appendChild(node);
			node = document.createElement('h4');
			node.innerHTML = qFlux.browser.map[this.linkID][1];
			tooltip.appendChild(node);
			node = document.createElement('p');
			node.innerHTML = qFlux.browser.map[this.linkID][7] != qFlux.browser.map[this.linkID][8] ? qFlux.browser.text['level'] + ' ' + qFlux.browser.map[this.linkID][7] + ' - ' + qFlux.browser.map[this.linkID][8] : qFlux.browser.text['level'] + ' ' + qFlux.browser.map[this.linkID][7];
			tooltip.appendChild(node);
			node = document.createElement('p');
			node.innerHTML = qFlux.browser.map[this.linkID][4] == 0 ? qFlux.browser.text['available_none'] : qFlux.browser.map[this.linkID][4] + ' ' + qFlux.browser.text['available'];
			tooltip.appendChild(node);
			tooltip.style.top = target.offsetTop + document.getElementById('map').offsetTop - tooltip.offsetHeight + 20 + 'px';
			tooltip.style.left = target.offsetLeft + document.getElementById('map').offsetLeft - tooltip.offsetWidth - 10 + 'px';
			tooltip.style.display = 'block';
		}
	
	//####################################################################################################
	
	qFlux.browser.zoneMouseOut = function(event)
		{
			document.getElementById('tooltip').style.display = 'none';
			if ( event == null )
				{ event = window.event; }
			var target = ( event.target == null ? event.srcElement : event.target );
			target.style.backgroundPosition = qFlux.map.color[target.color];
		}
	
	//####################################################################################################
	
	qFlux.browser.zoneMouseDown = function()
		{ qFlux.browser.requestMap(this.linkID); }
	
	//####################################################################################################
	
	qFlux.browser.showZone = function()
		{
			qFlux.map.clear();
			var types = ['npc', 'item', 'object', 'string'];
			var focus = {};
			if ( qFlux.browser.mapType == 'quest' )
				{
					var quest = qFlux.browser.quest[qFlux.browser.mapID];
					focus = qFlux.browser.assembleMapFocus(focus, types[quest[2]], quest[3], 'start');
					focus = qFlux.browser.assembleMapFocus(focus, types[quest[4]], quest[5], 'end');
					if ( quest[6] != 0 )
						{
							for ( var i in quest[6] )
								{ focus = qFlux.browser.assembleMapFocus(focus, types[quest[6][i][0]], quest[6][i][1], 'objective'); }
						}
				}
			else if ( qFlux.browser.mapType != null )
				{ focus = qFlux.browser.assembleMapFocus(focus, qFlux.browser.mapType, qFlux.browser.mapID, 'focus'); }
			var group = ['npc', 'object', 'string'];
			var index = 0;
			qFlux.browser.area = 0;
			for ( var i in group )
				{
					if ( !qFlux.browser[group[i]] )
						{ continue; }
					for ( var n in qFlux.browser[group[i]] )
						{
							var object = qFlux.browser[group[i]][n];
							if ( !object[2] || object[2][0][0] != qFlux.map.map )
								{ continue; }
							if ( focus[group[i]] && focus[group[i]][n] )
								{
									qFlux.map.point(index, object[2][0][1], object[2][0][2], focus[group[i]][n], group[i], n, qFlux.browser.mapTooltip, qFlux.browser.mapMouseOut, qFlux.browser.mapMouseDown)
									if ( qFlux.browser[group[i]][n][2][1] )
										{ qFlux.browser.area = qFlux.map.area(qFlux.browser.area, qFlux.browser[group[i]][n][2]); }
								}
							else if ( qFlux.browser.isFocus != true )
								{ qFlux.map.point(index, object[2][0][1], object[2][0][2], 'neutral', group[i], n, qFlux.browser.mapTooltip, qFlux.browser.mapMouseOut, qFlux.browser.mapMouseDown); }
							index++;
						}
				}
			if ( qFlux.editor && qFlux.editor.focus >= 0 && qFlux.editor.task[qFlux.editor.focus][0] == 5 && qFlux.editor.task[qFlux.editor.focus][1] == qFlux.map.map )
				{ document.getElementById('map_node').style.display = 'block'; }
		}
	
	//####################################################################################################
	
	qFlux.browser.assembleMapFocus = function(focus, type, id, color)
		{
			if ( !qFlux.browser[type][id][2] )
				{ return focus; }
			var types = ['npc', 'item', 'object', 'string'];
			var data = [];
			if ( type == 'item' )
				{
					var container = qFlux.browser.item[id][2];
					for ( var i in container )
						{ data.push([[types[container[i][0]]], [container[i][1]]]); }
				}
			else
				{ data.push([type, id]); }
			for ( var i in data )
				{
					if ( !focus[data[i][0]] )
						{ focus[data[i][0]] = {}; }
					else if ( color == 'end' && focus[data[i][0]][data[i][1]] && focus[data[i][0]][data[i][1]] == 'start' )
						{ color = 'transfer'; }
					focus[data[i][0]][data[i][1]] = color;
				}
			return focus;
		}
	
	//####################################################################################################
	
	qFlux.browser.setMapFocus = function(type, id)
		{
			qFlux.browser.mapType = null;
			qFlux.browser.mapID = null;
			var types = ['npc', 'item', 'object', 'string'];
			var map = qFlux.map.map;
			if ( type == 'quest' )
				{
					var change = true;
					if ( qFlux.browser.quest[id][7] != 0 )
						{
							for ( var i in qFlux.browser.quest[id][7] )
								{
									if ( qFlux.browser.quest[id][7][i] == map )
										{
											change = false;
											break;
										}
								}
						}
					if ( change )
						{ map = qFlux.browser.getObjectMap(types[qFlux.browser.quest[id][2]], qFlux.browser.quest[id][3]); }
				}
			else
				{ map = qFlux.browser.getObjectMap(type, id); }
			qFlux.browser.mapType = type;
			qFlux.browser.mapID = id;
			if ( map == null )
				{ return; }
			if ( map != qFlux.map.map )
				{
					if ( !qFlux.maintenance || document.getElementById('container_maintenance').style.display != 'block' )
						{ qFlux.browser.requestMap(map); }
					else
						{
							qFlux.map.select(map, qFlux.browser.map[map][0]);
							qFlux.browser.header();
							qFlux.browser.showZone();
						}
				}
			else
				{ qFlux.browser.showZone(); }
		}
	
	//####################################################################################################
	
	qFlux.browser.getObjectMap = function(type, id)
		{
			if ( !qFlux.browser[type] || !qFlux.browser[type][id] || !qFlux.browser[type][id][2] )
				{ return; }
			var data = qFlux.browser[type][id];
			if ( type == 'item' )
				{
					var types = ['npc', 'item', 'object', 'string'];
					for ( var i in data[2] )
						{
							var map = qFlux.browser.getObjectMap(types[data[2][i][0]], data[2][i][1]);
							if ( map != null )
								{ return map; }
						}
				}
			else
				{ return data[2][0][0]; }
		}
	
	//####################################################################################################
	
	qFlux.browser.mapTooltip = function(event)
		{
			if ( !qFlux.browser[this.linkType][this.linkID][2] )
				{ return; }
			if ( event == null )
				{ event = window.event; }
			var target = ( event.target == null ? event.srcElement : event.target );
			target.style.backgroundPosition = qFlux.map.color['focus'];
			target.style.zIndex = 5;
			var types = ['npc', 'item', 'object', 'string', 'event'];
			var title = { npc:'Character', item:'Item', object:'Object', event:'Event', quest:'Quest' };
			var type = this.linkType;
			var id = this.linkID;
			var tooltip = document.getElementById('tooltip');
			while ( tooltip.firstChild )
				{ tooltip.removeChild(tooltip.firstChild); }
			var node = document.createElement('div');
			tooltip.appendChild(node);
			node = document.createElement('h4');
			node.innerHTML = qFlux.browser[this.linkType][this.linkID][0];
			tooltip.appendChild(node);
			var nodes = qFlux.browser.getObjectData(this.linkType, this.linkID);
			var setting = {};
			setting.start = ['left', 'start', 'start'];
			setting.end = ['right', 'end', 'end'];
			setting.objective = ['left', 'objective', 'objective'];
			setting.container = ['left', 'container', 'container'];
			setting.contained = ['left', 'container', 'contained'];
			for ( var i in nodes )
				{
					if ( nodes[i].length == 0 )
						{ continue; }
					var container = document.getElementById('detail_' + setting[i][0]);
					node = document.createElement('h5');
					node.innerHTML = qFlux.browser.text[setting[i][2]];
					tooltip.appendChild(node);
					list = document.createElement('ul');
					tooltip.appendChild(list);
					for ( var n in nodes[i] )
						{
							node = document.createElement('li');
							node.innerHTML = ( nodes[i][n][0] == 'quest' ? '<b>' + qFlux.browser[nodes[i][n][0]][nodes[i][n][1]][8] + '+</b>' : '' ) + qFlux.browser[nodes[i][n][0]][nodes[i][n][1]][0];
							list.appendChild(node);
						}
				}
			tooltip.style.display = 'block';
			var top = target.offsetTop + document.getElementById('map').offsetTop - tooltip.offsetHeight + 20;
			if ( top < 10 )
				{ top = 10; }
			tooltip.style.top = top + 'px';
			tooltip.style.left = target.offsetLeft + document.getElementById('map').offsetLeft - tooltip.offsetWidth - 10 + 'px';
			if ( this.linkType != 'item' && qFlux.browser[this.linkType][this.linkID][2][1] && this.color == 'neutral' )
				{ qFlux.map.area(qFlux.browser.area, qFlux.browser[this.linkType][this.linkID][2]); }
		}
	
	//####################################################################################################
	
	qFlux.browser.mapMouseOut = function(event)
		{
			document.getElementById('tooltip').style.display = 'none';
			if ( event == null )
				{ event = window.event; }
			var target = ( event.target == null ? event.srcElement : event.target );
			target.style.backgroundPosition = qFlux.map.color[target.color];
			if ( target.style == 'neutral' )
				{ target.style.zIndex = 1; }
			else
				{ target.style.zIndex = 3; }
			if ( target.color != 'neutral' )
				{ return; }
			var container = document.getElementById('map');
			for ( var i in container.childNodes )
				{
					if ( container.childNodes[i].className == 'area' && container.childNodes[i].index >= qFlux.browser.area )
						{ container.childNodes[i].style.display = 'none'; }
				}
		}
	
	//####################################################################################################
	
	qFlux.browser.mapMouseDown = function()
		{
			if ( qFlux.maintenance )
				{
					qFlux.maintenance.type = this.linkType;
					qFlux.maintenance.id = this.linkID;
					if ( document.getElementById('container_maintenance').style.display == 'block' )
						{ qFlux.maintenance.show(); }
				}
			qFlux.browser.setListFocus(0);
			if ( !qFlux.maintenance || document.getElementById('container_maintenance').style.display != 'block' )
				{ qFlux.browser.showObject(this.linkType, this.linkID); }
			qFlux.browser.mapType = this.linkType;
			qFlux.browser.mapID = this.linkID;
			qFlux.browser.showZone();
			if ( qFlux.editor && ( !qFlux.maintenance || !document.getElementById('container_maintenance').style.display == 'block' ) )
				{ qFlux.editor.showAssemble(); }
		}
	
	//####################################################################################################

	qFlux.browser.mapOption = function(option)
		{
			qFlux.browser[option] = !qFlux.browser[option];
			if ( qFlux.browser[option] )
				{ document.getElementById('map_' + option).checked = true; }
			else
				{ document.getElementById('map_' + option).checked = false; }
			if ( qFlux.map.map != 'Cosmic' && qFlux.browser.map[qFlux.map.map][2] != 'Cosmic' && qFlux.browser.map[qFlux.map.map][2] != 'World' )
				{ qFlux.browser.showZone(); }
		}

