	var locTypes = [
		[42,"Item"],
		[40,"Milestone"],
		[46,"Mob"],
		[1,"NPC"],
		[14,"Auctioneer"],
		[27,"Bard"],
		[12,"Bowyer"],
		[25,"Burglar Trainer"],
		[31,"Captain Trainer"],
		[21,"Champion Trainer"],
		[35,"Clerk of Kinships"],
		[5,"Expert Cook"],
		[7,"Expert Jeweller"],
		[9,"Expert Metalsmith"],
		[39,"Expert Scholar"],
		[37,"Expert Tailor"],
		[30,"Expert Weaponcrafter"],
		[11,"Expert Woodworker"],
		[34,"Grocer"],
		[18,"Guardian Trainer"],
		[16,"Healer"],
		[44,"Heavy Armor Trader"],
		[19,"Hunter Trainer"],
		[24,"Light Armor Trader"],
		[22,"Loremaster Trainer"],
		[26,"Master of Apprentices"],
		[23,"Medium Armor Trader"],
		[20,"Ministrel Trainer"],
		[45,"Monster Player Trainer"],
		[33,"Notary"],
		[4,"Novice Cook"],
		[6,"Novice Jeweller"],
		[8,"Novice Metalsmith"],
		[38,"Novice Scholar"],
		[36,"Novice Tailor"],
		[29,"Novice Weaponcrafter"],
		[10,"Novice Woodworker"],
		[15,"Provisioner"],
		[13,"Stablemaster"],
		[17,"Supplier"],
		[32,"Tavern Keep"],
		[43,"Weapontrader"],
		[41,"POI"],
		[47,"POI"],
		[48,"POI"],
		[49,"POI"],
		[50,"POI"],
		[51,"POI"],
		[52,"POI"],
		[53,"POI"],
		[54,"POI"],
		[55,"POI"],
		[56,"POI"],
		[57,"POI"],
		[58,"POI"],
		[59,"POI"],
		[60,"POI"],
		[61,"POI"]
	]

	locPOIs = new Array();
	var currentMap = -1;

	var loc_index = 0;
	function AddlocPOIs(id,name,int_type,type,x,y,image){
		locPOIs[loc_index] = new Array(name,type,y,x,0,image,1,int_type,id,0);
		$("map_loc").adopt(new Element ("option",{value: loc_index}).set("html",name));
		loc_index++;
	}

	function loadMapOfRegion(num){
		$("map").innerHTML = "";
		$$(".tip").fade("hide");
		//alert(num);
		switch (num){
			case 0:
			var str = '<img src="base/picture/locations/main_0.jpg" width="1024" height="768" border="0" alt="" usemap="#main_0_Map">';
			str += '<map name="main_0_Map">';
			str += '<area shape="poly" title="Мглистые горы" coords="888,236, 985,236, 985,251, 955,267, 911,267, 887,250" class="mapTip" onclick="change_map(6)">';
			str += '<area shape="poly" title="Эттенские высоты" coords="773,281, 874,280, 873,294, 855,309, 787,310, 772,294" class="mapTip" onclick="change_map(15)">';
			str += '<area shape="poly" title="Троллистое плато" coords="811,364, 923,364, 923,376, 896,394, 835,394, 812,380" class="mapTip" onclick="change_map(10)">';
			str += '<area shape="poly" title="Пустоши" coords="681,354, 699,352, 768,353, 777,363, 775,376, 765,376, 681,376, 676,363" class="mapTip" onclick="change_map(7)">';
			str += '<area shape="poly" title="Земли Бри" coords="656,376, 669,385, 677,393, 681,406, 681,417, 675,424, 667,431, 642,434, 629,436, 621,436, 606,435, 590,434, 583,428, 578,415, 570,404, 573,397, 582,388, 592,384, 600,378" class="mapTip" onclick="change_map(5)">';
			str += '<area shape="poly" title="Ангмар" coords="692,125, 686,133, 687,141, 683,146, 681,154, 681,161, 686,167, 695,166, 698,169, 700,175, 707,183, 712,190, 717,196, 727,193, 731,199, 735,207, 744,211, 750,206, 756,204, 764,208, 770,207, 780,209, 779,197, 786,197, 794,190, 793,184, 787,184, 779,179, 778,169, 788,162, 788,153, 783,150,779,145, 779,141, 777,134, 779,126, 777,122, 777,115, 776,108, 769,106, 751,103, 746,98, 715,101, 711,105, 712,117, 709,125" class="mapTip" onclick="change_map(0)">';

			str += '<area shape="circle" title="Северное нагорье" coords="650, 250, 60" class="mapTip" onclick="change_map(9)">';
			str += '<area shape="circle" title="Эред Луин" coords="330, 280, 50" class="mapTip" onclick="change_map(14)">';
			str += '<area shape="circle" title="Форохель" coords="465, 130, 50" class="mapTip" onclick="change_map(11)">';
			str += '<area shape="circle" title="Эвендим" coords="500, 320, 60" class="mapTip" onclick="change_map(13)">';
			str += '<area shape="circle" title="Шир" coords="480, 410, 60" class="mapTip" onclick="change_map(12)">';
			str += '<area shape="circle" title="Эрегион" coords="920, 510, 60" class="mapTip" onclick="change_map(32)">';

			str += '</map>';
			$("map").innerHTML = str;

				break;
			case 1:
			var str = '<img src="base/picture/locations/main_1.jpg" width="1024" height="768" border="0" alt="" usemap="#main_1_Map">';
			str += '<map name="main_1_Map">';

			str += '<area shape="circle" title="Мглистые горы" coords="200, 280, 50" class="mapTip" onclick="change_map(6)">';
			str += '<area shape="circle" title="Мория" coords="280, 300, 50" class="mapTip" onclick="change_map(18)">';
			str += '<area shape="circle" title="Лотлориэн" coords="420, 330, 60" class="mapTip" onclick="change_map(27)">';
			str += '<area shape="circle" title="Лихолесье" coords="600, 170, 100" class="mapTip" onclick="change_map(29)">';

			str += '</map>';
			$("map").innerHTML = str;
			break;
		}
			var myTips = new Tips('.mapTip');
			myTips.addEvent('show', function(tip){
				tip.fade('in');
			});
			myTips.addEvent('hide', function(tip){
			    tip.fade('out');
			});
	}

	function show_region(name, show)
	{		if(show)
		{			$(name).setStyles({'z-index':'0'});
		}
		else
		{
			$(name).setStyles({'z-index':'-1'});
		}	}

	function addEventArea(id, imageId)
	{		$(id).addEvent('mousemove', function(){
			show_region(imageId, 1)
		});
//		$(id).addEvent('mouseout', function(){
//			show_region(imageId, 0)
//		});
	}

	function region(id)
	{		var coords = "";
		var imgname = "";
		var func = "";
		var title;
		var left;
		var top;
		switch(id)
		{		case "main_0":
				coords = "0,25, 10,22, 10,12, 65,0, 76,6, 80,12, 108,12, 115,18, 115,28, 104,42, 60,100, 50,100, 10,66, 0,46";
			title = "Карта Эриадора";
			func = "loadMapOfRegion(0)";
			left = 300;
			top = 80;
			break;
		case "main_1":
				coords = "0,25, 10,22, 10,12, 65,0, 76,6, 80,12, 108,12, 115,18, 115,28, 104,42, 60,100, 50,100, 10,66, 0,46";
			title = "Карта Рованиона";
			func = "loadMapOfRegion(1)";
			left = 680;
			top = 130;
			break;
		}

		var str = '<img title="'+title+'" id="'+id+'" onclick="'+func+'"  src="base/picture/locations/mini/'+id+'.gif" style="z-index:-1; cursor: hand; position: absolute; top:'+top+'px; left:'+left+'px" class="mapTip">'//		str += '<map name="map_'+id+'">';
//		str += '<area shape="poly" coords="'+coords+'" class="mapTip" onmouseout="show_region(\''+id+'\', 0)" >';
//		str += '</map>';
//		alert(str);
		return str;
	}

	function hideall()
	{		$$("img.mapTip").setStyles({'z-index':'-1'});	}

	function loadMainMap(){
		$("map").innerHTML = "";
		img = '<img src="base/picture/locations/main_map.jpg"';
		img += 'width="1024" height="768" border="0" alt=""';
		img += 'usemap="#main_map_Map">';
		img += '<map name="main_map_Map">';
		img += '<area shape="circle" id="area_main_0" coords="450, 220, 150" class="mapTip" onmouseover="show_region(\'main_0\', 1)">';
		img += '<area shape="poly" id="area_main_1" coords="675,140, 750,130, 860,235, 920,265, 965,360, 930,390, 950,450, 920,470, 740,515, 715,500, 760,440, 625,295, 700,220" class="mapTip">';
		img += '<area shape="poly" coords="0,0, 1024,0, 1024,768, 0,768" onmouseover="hideall()">';
		img += '</map>';
		$("map").innerHTML += region("main_0");
		$("map").innerHTML += region("main_1");
		$("map").innerHTML += img;
		addEventArea("area_main_0", "main_0");
		addEventArea("area_main_1", "main_1");

//		$("map").innerHTML += '<img title="Карта Рованиона" id="main_1" onclick="loadMapOfRegion(1)"  src="base/picture/locations/mini/main_1.gif" style="z-index:-1; cursor: hand; position: absolute; top:130px; left:680px" onmouseout="show_region(\'main_1\', 0)"  , 1)" class="mapTip">';
//		$("map").innerHTML += '<img title="Карта Эриадора" id="main_0" onclick="loadMapOfRegion(0)"  src="base/picture/locations/mini/main_0.gif" style="z-index:-1; cursor: hand; position: absolute; top:73px; left:310px" onmouseout="show_region(\'main_0\', 0)"  , 1)" class="mapTip">';
			var myTips = new Tips('.mapTip');
	}

	function showLocationInfo(id){
		idPOI = id.substr(4,(id.length - 4));
		if ($("highlight") != null){$("highlight").setStyle("display","none");}
		if ($("locDetails") != null){/*$("locDetails").setStyle("display","none");*/$("locDetails").fade("out");}
		if ($("locInfo") != null){
			$("locInfo").setStyle("display","none");
			$("locInfo").innerHTML = "";
			$("locInfo").setStyle("display","");
		}
		else {
			$("map").adopt(
				locInfo = new Element("div", {id: "locInfo"})
			);
		}

		locInfoMarker = new Element("img",{id: "locInfoMarker", src: $(id).src}).inject(locInfo);
		locInfoTitle = new Element("span",{id: "locInfoTitle", onclick: "showLocationDetails('"+id+"')"}).set("html","&nbsp;"+locPOIs[idPOI][0]).inject(locInfo);
		locInfo.innerHTML = locInfo.innerHTML + "<br>";

		for( var i=0; i<locPOIs.length; i++){
			if ((locPOIs[idPOI][2] == locPOIs[i][2]) && (locPOIs[idPOI][3] == locPOIs[i][3]) && (locPOIs[idPOI][8] != locPOIs[i][8]) && ($('cbx_' + locPOIs[i][7]).checked)){
				//alert(locPOIs[i][2]);
				var idP = "";
				idP = "loc_"+i;
				new Element("img",{id: "locInfoMarker", src: $(idP).src}).inject(locInfo);
				new Element("span",{id: "locInfoTitle", onclick: "showLocationDetails('"+idP+"')"}).set("html","&nbsp;"+locPOIs[i][0]).inject(locInfo);
				locInfo.innerHTML = locInfo.innerHTML + "<br>";
				//alert(locInfo.innerHTML);
			}
		}

		var offX = $(id).offsetLeft + 15;
		var offY = $(id).offsetTop - 6;

        if (offX + locInfo.offsetWidth >  $("map").offsetWidth) {
			offX = $(id).offsetLeft - locInfo.offsetWidth - 15;
        }

		$("locInfo").style.top = offY;
		$("locInfo").style.left = offX;

		$("locInfo").fade("hide");
		$("locInfo").fade("in");
	}

	function showLocationDetails(id) {		idPOI = id.substr(4,(id.length - 4));
		if ($("locInfo") != null){/*$("locInfo").setStyle("display","none");*/$("locInfo").fade("out");}
        var displayCoords;
/*
        if (locPOIs[idPOI][3] > 0)
			displayCoords = Math.abs(locPOIs[idPOI][3]) + "N ";
        else
			displayCoords = Math.abs(locPOIs[idPOI][3]) + "S ";
 */
		var map_id = $("map_id").value;
		map_v = map_id * 1;
		switch (map_v){
			case 0: igY = -1*locPOIs[idPOI][3]; break;
			case 1: igY = -1*locPOIs[idPOI][3]; break;
			case 2: igY = -1*locPOIs[idPOI][3]; break;
			case 3: igY = 1*locPOIs[idPOI][3]; break;
			case 4: igY = -1*locPOIs[idPOI][3]; break;
			case 5: igY = -1*locPOIs[idPOI][3]; break;
			case 6: igY = -1*locPOIs[idPOI][3]; break;
			case 7: igY = -1*locPOIs[idPOI][3]; break;
			case 8: igY = -1*locPOIs[idPOI][3]; break;
			case 9: igY = -1*locPOIs[idPOI][3]; break;
			case 10: igY = -1*locPOIs[idPOI][3]; break;
			case 11: igY = 1*locPOIs[idPOI][3]; break;
			case 12: igY = -1*locPOIs[idPOI][3]; break;
			case 13: igY = -1*locPOIs[idPOI][3]; break;
			case 14: igY = 1*locPOIs[idPOI][3]; break;
			case 15: igY = 1*locPOIs[idPOI][3]; break;

			case 16: igY = 1*locPOIs[idPOI][3]; break;
			case 18: igY = 1*locPOIs[idPOI][3]; break;
			case 19: igY = 1*locPOIs[idPOI][3]; break;
			case 20: igY = 1*locPOIs[idPOI][3]; break;
			case 21: igY = 1*locPOIs[idPOI][3]; break;
			case 22: igY = 1*locPOIs[idPOI][3]; break;
			case 23: igY = 1*locPOIs[idPOI][3]; break;
			case 24: igY = 1*locPOIs[idPOI][3]; break;
			case 25: igY = 1*locPOIs[idPOI][3]; break;
			case 26: igY = 1*locPOIs[idPOI][3]; break;
			case 27: igY = 1*locPOIs[idPOI][3]; break;
			case 28: igY = 1*locPOIs[idPOI][3]; break;
			case 29: igY = 1*locPOIs[idPOI][3]; break;
			case 30: igY = 1*locPOIs[idPOI][3]; break;
			case 31: igY = 1*locPOIs[idPOI][3]; break;
			case 32: igY = 1*locPOIs[idPOI][3]; break;

		}

        if (igY > 0)
			displayCoords = Math.abs(igY) + "N ";
        else
			displayCoords = Math.abs(igY) + "S ";

        if (locPOIs[idPOI][2] > 0)
			displayCoords += Math.abs(locPOIs[idPOI][2]) + "E";
        else
			displayCoords += Math.abs(locPOIs[idPOI][2]) + "W";

		if ($("locDetails") != null){
			$("locDetails").setStyle("display","none");
			//$("locDetails").setStyles({width: '0px'});
			$$("#locDetails #locDetailsTitle").set("html",locPOIs[idPOI][0]);
			$$("#locDetails #locDetailsType").set("html","&nbsp;"+locPOIs[idPOI][1]);
			$$("#locDetails #locDetailsCoord").set("html","&nbsp;"+displayCoords);
			if ($("locDetailsImg") != null){$("locDetailsImg").destroy()};
		}
		else {
			$("map").adopt(
				locDetails = new Element("div", {id: "locDetails"}).adopt(
					locDetailsTitle = new Element("div",{id: "locDetailsTitle"}).set("html",locPOIs[idPOI][0]),
					locDetailsContent = new Element("div",{id: "locDetailsContent"}).adopt(
						new Element("div").adopt(new Element("span").set("html","Тип: "),
						new Element("span",{id: "locDetailsType"}).set("html","&nbsp;"+locPOIs[idPOI][1])),
						new Element("div").adopt(new Element("span").set("html","Координаты: "),
						new Element("span",{id: "locDetailsCoord"}).set("html","&nbsp;"+displayCoords))
					)
				).addEvent("click",function(){$("locDetails").fade("out");})
			);
		}

        if (locPOIs[idPOI][5] != 0) {
			locDetailsContent.adopt(
				new Element("div",{id: "locDetailsImg"}).adopt(
					new Element("a",{href: "base/picture/mobs/other/"+locPOIs[idPOI][8]+".jpg", target: "blank"}).adopt(
						new Element("img",{src: "base/picture/mobs/other/thumb/"+locPOIs[idPOI][8]+"_thumb.jpg"})
					)
				)
			);
        }

        var popupX = parseInt($(id).getStyle("left")) + 20;
        var popupY = parseInt($(id).getStyle("top")) - 16;

        // Корректируем Х
        if (popupX + 200 > 1024) {
			popupX = parseInt($(id).getStyle("left")) - 210;
        }
        // Корректируем У
        if (popupY < 0) popupY = 3;

		$("locDetails").style.top = -1000;
		$("locDetails").setStyle("display","");
        if (popupY + $("locDetails").offsetHeight > 768) {
			popupY = 763 - $("locDetails").offsetHeight;
        }

		$("locDetails").style.top = popupY;
		$("locDetails").style.left = popupX;

		$("locDetails").fade("hide");
		$("locDetails").fade("in");
	}

	function selLocsChanged() {
		var poiId = $("map_loc").value;
        var poi = "loc_"+poiId;
        if (poiId != "none") {
			offY = $(poi).offsetTop - 15;
			offX = $(poi).offsetLeft - 15;
			if ($("highlight") != null){
				$$("#map #highlight").setStyle("display","");
				$("highlight").setStyles({top: offY, left: offX});
				$$("#map #highlight").fade("in");
			}
			else{
				$("map").adopt(highlight = new Element("div",{id: "highlight"}).setStyles({top: offY, left: offX}).adopt(new Element("img",{src: "template/db/images/highlight.gif"})));
			}
            showLocationDetails(poi);

		}
		return true;
	}

	var mapLoaded = 0;
	function drawPOIs(map_id){
		//alert(map_id);
		map_v = map_id * 1;
		IgToMap = 0;
		ally = 1;
		switch (map_v){
			case 0: IgToMap=3.504; MapToIg=0.285; mapStartX=-42.749;mapStartY=14.662; ally = -1; break;
			case 1: IgToMap=18.4; MapToIg=0.054; mapStartX=-50.7;mapStartY=-24.2; ally = -1; break;
			case 2: IgToMap=15; MapToIg=0.066; mapStartX=-54.6;mapStartY=-28; ally = -1; break;
			case 3: IgToMap=7.852; MapToIg=0.127; mapStartX=-65.275;mapStartY=-29.159; ally = 1; break;
			case 4: IgToMap=12.55; MapToIg=0.08; mapStartX=-106.9;mapStartY=-11.1; ally = -1; break;
			case 5: IgToMap=3.6; MapToIg=0.277; mapStartX=-65.6;mapStartY=-17.6; ally = -1; break;
			case 6: IgToMap=4.119; MapToIg=0.243; mapStartX=-11.876;mapStartY=-14.576; ally = -1; break;
			case 7: IgToMap=4.368; MapToIg=0.229; mapStartX=-44.3;mapStartY=-26.2; ally = -1; break;
			case 8: IgToMap=10.52; MapToIg=0.095; mapStartX=-9.4;mapStartY=-26.2; ally = -1; break;
			case 9: IgToMap=3.6; MapToIg=0.277; mapStartX=-60.5;mapStartY=-1; ally = -1; break;
			case 10: IgToMap=3.745; MapToIg=0.267; mapStartX=-26.4;mapStartY=-20.8; ally = -1; break;
			case 11: IgToMap=2.497; MapToIg=0.4; mapStartX=-92.8;mapStartY=24.98; ally = 1; break;
			case 12: IgToMap=5.381; MapToIg=0.186; mapStartX=-78.734;mapStartY=-23.537; ally = -1; break;
			case 13: IgToMap=3.376; MapToIg=0.296; mapStartX=-82.8;mapStartY=-1.7; ally = -1; break;
			case 14: IgToMap=3.875; MapToIg=0.258; mapStartX=-112.9;mapStartY=-12.6; ally = 1; break;
			case 15: IgToMap=6.352; MapToIg=0.157; mapStartX=-24.3;mapStartY=-9.9; ally = 1; break;

			case 16: MapToIg=0.09375; mapStartX=-109.2;mapStartY=-9.3; break;
			case 18: MapToIg=0.3330078125; mapStartX=-121.8;mapStartY=2.8; break;
			case 19: MapToIg=0.130859375; mapStartX=-114.0;mapStartY=-3.9; break;
			case 20: MapToIg=0.109375; mapStartX=-105.2;mapStartY=-4.0; break;
			case 21: MapToIg=0.0703125; mapStartX=-117.2;mapStartY=-4.9; break;
			case 22: MapToIg=0.0703125; mapStartX=-116.1;mapStartY=-8.6; break;
			case 23: MapToIg=0.1357421875; mapStartX=-120.5;mapStartY=-12.4; break;
			case 24: MapToIg=0.0732421875; mapStartX=-112.1;mapStartY=-12.4; break;
			case 25: MapToIg=0.0751953125; mapStartX=-102.8;mapStartY=-10.6; break;
			case 26: MapToIg=0.07421875; mapStartX=-113.0;mapStartY=17.3; break;
			case 27: MapToIg=0.205078125; mapStartX=-82.0;mapStartY=-4.6; break;
			case 28: MapToIg=0.0556640625; mapStartX=-70.0;mapStartY=-12.9; break;
			case 29: MapToIg=0.2421875; mapStartX=-63.6;mapStartY=-4.9; break;
			case 30: MapToIg=0.072265625; mapStartX=-9.0;mapStartY=-48.5; break;
			case 31: MapToIg=0.15625; mapStartX=-114.0;mapStartY=2.0; break;
			case 32: MapToIg=0.216796875; mapStartX=-23.8;mapStartY=-35.3; break;

			default: IgToMap=0; MapToIg=0; mapStartX=0;mapStartY=0;
		}
		if(MapToIg != 0 && IgToMap==0)///16-32
		{			IgToMap = 1/MapToIg;
		}
		//alert(map_id);
		for( var i=0; i<locPOIs.length; i++){
			if (locPOIs[i] != null && locPOIs[i][6] == 1) {
				igX = locPOIs[i][2];
                igY = ally*locPOIs[i][3];
                dispX = ((mapStartX - igX) * IgToMap * 10) * (-1) - 5;
                dispY = ((mapStartY - igY) * IgToMap * 10) - 5;
				if (dispX > '1024'){alert(locPOIs[i][0]);}
                switch(locPOIs[i][7]) {
                     case '12':
                     case '15':
                     case '17':
                     case '16':
                     case '23':
                     case '24':
                     case '32':
                     case '34':
                     case '43':
                     case '44':
                        var marker = 'vendor.gif'; locPOIs[i][9] = "vendor.gif"; break;
                     case '4':
                     case '5':
                     case '6':
                     case '7':
                     case '8':
                     case '9':
                     case '10':
                     case '11':
                     case '26':
                     case '29':
                     case '30':
                     case '36':
                     case '37':
                     case '38':
                     case '39':
                     case '64':
                     case '65':
                     case '66':
                     case '67':
                        var marker = 'mark_craft.gif'; locPOIs[i][9] = "mark_craft.gif"; break;
                     case '18':
                     case '19':
                     case '20':
                     case '21':
                     case '22':
                     case '25':
                     case '31':
                     case '62':
                     case '63':
                        var marker = 'trainer.gif'; locPOIs[i][9] = "trainer.gif"; break;
                     case '14':
						var marker = 'auction.gif'; locPOIs[i][9] = "auction.gif"; break;
                     case '13':
						var marker = 'stable.gif'; locPOIs[i][9] = "stable.gif"; break;
                     case '27':
						var marker = 'bard.gif'; locPOIs[i][9] = "bard.gif"; break;
                     case '33':
                     case '35':
                        var marker = 'mark_misc.gif'; locPOIs[i][9] = "mark_misc.gif"; break;
                     case '40':
                        var marker = 'milestone.gif'; locPOIs[i][9] = "milestone.gif"; break;
                     case '41':
                        var marker = 'poi.gif'; locPOIs[i][9] = "poi.gif"; break;
                     case '42':
                        var marker = 'mark_item.gif'; locPOIs[i][9] = "mark_item.gif"; break;
                     case '46':
                        var marker = 'mark_mob.gif'; locPOIs[i][9] = "mark_mob.gif"; break;
                     case '47':
                        var marker = 'rep_vendor.gif'; locPOIs[i][9] = "rep_vendor.gif"; break;
                     case '48':
                        var marker = 'settlement.gif'; locPOIs[i][9] = "settlement.gif"; break;
                     case '49':
                        var marker = 'pool.gif'; locPOIs[i][9] = "pool.gif"; break;
                     case '50':
                        var marker = 'mailbox.gif'; locPOIs[i][9] = "mailbox.gif"; break;
                     case '51':
                        var marker = 'oven.gif'; locPOIs[i][9] = "oven.gif"; break;
                     case '52':
                        var marker = 'workbench.gif'; locPOIs[i][9] = "workbench.gif"; break;
                     case '53':
                        var marker = 'forge.gif'; locPOIs[i][9] = "forge.gif"; break;
                     case '54':
                        var marker = 'campfire.gif'; locPOIs[i][9] = "campfire.gif"; break;
                     case '55':
                        var marker = 'cook_campfire.gif'; locPOIs[i][9] = "cook_campfire.gif"; break;
                     case '56':
                        var marker = 'ring.gif'; locPOIs[i][9] = "ring.gif"; break;
                     case '57':
                        var marker = 'gemstone.gif'; locPOIs[i][9] = "gemstone.gif"; break;
                     case '58':
                        var marker = 'quest.gif'; locPOIs[i][9] = "quest.gif"; break;
                     case '59':
                        var marker = 'field.gif'; locPOIs[i][9] = "field.gif"; break;
                     case '60':
                        var marker = 'vault.gif'; locPOIs[i][9] = "vault.gif"; break;
                     case '61':
                        var marker = 'trader.gif'; locPOIs[i][9] = "trader.gif"; break;
                     default:
                        var marker = 'mark_npc.gif'; locPOIs[i][9] = "mark_npc.gif"; break;


				}
				$("map").adopt(imgMarker = new Element("img", {
						id: "loc_"+i, src: "template/db/images/"+marker}).setStyles({
						position: 'absolute', left: dispX, top: dispY}));
				imgMarker.addEvent("mouseover",function(){showLocationInfo(this.id);})
				imgMarker.addEvent("click",function(){showLocationDetails(this.id);});
			}
		}
		mapLoaded = 1;
	}

	function change_map(map_value){
		//mapid = map_value;
		$("map").innerHTML = "Загрузка...";
		JsHttpRequest.query(
			"map_online.php?do=loadmap",
			{
				'map_id': map_value
			},
			function(result, errors) {
				//alert($('map_id').selectedIndex);
				map_value = map_value*1;
				$$(".tip").fade("hide");
				$("map").innerHTML = "";
				locPOIs.length = 0;
				loc_index = 0;
				$("map_loc").length = 0;
				$("map_loc").adopt(new Element ("option",{value: "none"}).set("html","Выберите объект"));
				eval(result["locPOIs"]);
				$("map").setStyle('background','url('+result["map"]+') no-repeat');
				currentMap = map_value;
				mapLoaded = 0;
				//$("li").innerHTML = document.write('<a href="http://www.liveinternet.ru/click;mmoclub" '+'target="_blank"><img src="http://counter.yadro.ru/hit;mmoclub?t24.6;r'+escape(document.referrer)+((typeof(screen)=='undefined')?'':';s'+screen.width+'*'+screen.height+'*'+(screen.colorDepth?screen.colorDepth:screen.pixelDepth))+';u'+escape(document.URL)+';'+Math.random()+' title=LiveInternet: показано число посетителей за'+'сегодня '+'border=0 width=88 height=15><\/a>');
				drawPOIs(map_value);
			}
		);
	}

	function changeSelLoc(obj_id){
		var currentIndex = 0;
		if (mapLoaded == 1){
			for (var i=0; i<locPOIs.length; i++){
				if (locPOIs[i][8] == obj_id){currentIndex = i; break;}
			}
			$('map_loc').selectedIndex = currentIndex + 1;
			selLocsChanged();
		}
	}

	function loadObject(obj_id, obj_map){
		//alert(obj_map);
		if (currentMap == obj_map){
			var currentIndex = 0;
			for (var i=0; i<locPOIs.length; i++){
				if (locPOIs[i][8] == obj_id){currentIndex = i; break;}
			}
			$('map_loc').selectedIndex = currentIndex + 1;
			selLocsChanged();
		}
		else {
			change_map(obj_map);
			setTimeout('changeSelLoc('+obj_id+')',1000);
		}
	}

	function objSearch(str){
		//alert(str);
		if ($("divSearch") != null){
			$("divSearch").set("html","Идет поиск&hellip;");
			divSearch.setStyle("display","");
		}
		else {
			$('content_map').adopt(divSearch = new Element("div", {id: "divSearch"}).set("html","Идет поиск&hellip;").addEvent("click",function(){divSearch.setStyle("display","none")}));
		}

		var tmp = $('strSearch').getCoordinates();
        var popupX = tmp.left - divSearch.offsetWidth + $('strSearch').offsetWidth;
        var popupY = tmp.top + $('strSearch').offsetHeight + 2;

		divSearch.style.top = popupY;
		divSearch.style.left = popupX;

		JsHttpRequest.query(
			"map_online.php?do=search",
			{
				'str': str
			},
			function(result, errors) {
				//alert($('map_id').selectedIndex);
				divSearch.set("html",result["res"]);
				var popupX = tmp.left - divSearch.offsetWidth + $('strSearch').offsetWidth;
				divSearch.style.left = popupX;
			}
		);

	}

	function toggleLocType(type, show){
		if ($("locInfo") != null){ $("locInfo").fade("hide");	}
		if ($("locDetails") != null){ $("locDetails").fade("hide");}
		if ($("highlight") != null){ $$("#map #highlight").fade("hide");}

		for( var i=0; i<locPOIs.length; i++){
               if (locPOIs[i] != null && locPOIs[i][7] == type)
               {
                  if (show == true)
                  {
                     $('loc_'+i).fade('in');
                  }else{
                     $('loc_'+i).fade('out');
                  }
               }
		}

		$('cbx_'+type).checked = show;
		fillLocs();
		$('cbx_'+type).checked = !show;
		return true;
	}

	var filter_status = 0;
	function toggleFilterMenu(){
		if (filter_status == 0){
			$('divFilter').fade('hide');
			$('divFilter').fade('in');
			filter_status=1;
		}
		else {
			$('divFilter').fade('out');
			filter_status=0;
		}
        $('divFilter').setStyles({top: -1000});

		var tmp = $('btnFilter').getCoordinates();
        var popupX = tmp.left - $('divFilter').offsetWidth + $('btnFilter').offsetWidth + 2
        var popupY = tmp.top + $('btnFilter').offsetHeight +3 ;

		$("divFilter").style.top = popupY;
		$("divFilter").style.left = popupX;
	}

	function fillLocs() {
		if ($("locInfo") != null){ $("locInfo").fade("hide");	}
		if ($("locDetails") != null){ $("locDetails").fade("hide");}
		if ($("highlight") != null){ $$("#map #highlight").fade("hide");}

		while($('map_loc').options.length > 1){
			$('map_loc').options[1] = null;
        }

		//locPOIs.sort();
		for(var i=0; i<locPOIs.length; i++) {
			if (locPOIs[i] != null){
				if ($('cbx_'+locPOIs[i][7]) != null && $('cbx_'+locPOIs[i][7]).checked){
					$('map_loc').options[$('map_loc').length] = new Option(locPOIs[i][0], i);
					$('map_loc').selectedIndex = 0;
				}
			}
		}

		return true;
	}

	function enforceFilter(){
		for(var i=0; i<locPOIs.length; i++){
			if (locPOIs[i] != null && $('cbx_' + locPOIs[i][7]) != null){
				if ($('cbx_' + locPOIs[i][7]).checked){
					$('loc_' + i).fade('in');
				}
                else{
					$('loc_' + i).fade('out');
				}
            }
		}
        fillLocs();
	}

	function toggleGroup(grpId, checked){
		if (grpId=='merchant'){
			$('cbx_12').checked = checked;
            $('cbx_34').checked = checked;
            $('cbx_16').checked = checked;
            $('cbx_24').checked = checked;
            $('cbx_23').checked = checked;
            $('cbx_44').checked = checked;
            $('cbx_15').checked = checked;
            $('cbx_17').checked = checked;
            $('cbx_32').checked = checked;
            $('cbx_43').checked = checked;
		}
        else if(grpId=='craft'){
			$('cbx_4').checked = checked;
            $('cbx_6').checked = checked;
            $('cbx_9').checked = checked;
            $('cbx_38').checked = checked;
            $('cbx_36').checked = checked;
            $('cbx_29').checked = checked;
            $('cbx_10').checked = checked;
            $('cbx_5').checked = checked;
            $('cbx_7').checked = checked;
            $('cbx_8').checked = checked;
            $('cbx_39').checked = checked;
            $('cbx_37').checked = checked;
            $('cbx_30').checked = checked;
            $('cbx_11').checked = checked;
            $('cbx_26').checked = checked;
        }
        else if(grpId=='trainer'){
			$('cbx_25').checked = checked;
            $('cbx_31').checked = checked;
            $('cbx_21').checked = checked;
            $('cbx_18').checked = checked;
            $('cbx_19').checked = checked;
            $('cbx_22').checked = checked;
            $('cbx_20').checked = checked;
		}
        else if(grpId=='misc'){
			$('cbx_14').checked = checked;
            $('cbx_27').checked = checked;
            $('cbx_35').checked = checked;
            $('cbx_33').checked = checked;
            $('cbx_13').checked = checked;
			$('cbx_47').checked = checked;
			$('cbx_48').checked = checked;
			$('cbx_49').checked = checked;
			$('cbx_50').checked = checked;
			$('cbx_51').checked = checked;
			$('cbx_52').checked = checked;
			$('cbx_53').checked = checked;
			$('cbx_54').checked = checked;
			$('cbx_55').checked = checked;
			$('cbx_56').checked = checked;
			$('cbx_57').checked = checked;
			$('cbx_58').checked = checked;
			$('cbx_59').checked = checked;
			$('cbx_60').checked = checked;
			$('cbx_61').checked = checked;
		}
        enforceFilter();
	}

	function FilterCbxToggle(mode){
		for(var i=0; i<locTypes.length; i++){
			if (locTypes[i] != null && $('cbx_'+locTypes[i][0]) != null)
				$('cbx_'+locTypes[i][0]).checked = mode;
		}
		$('cbxGroupMerchant').checked = mode;
        $('cbxGroupCraft').checked = mode;
        $('cbxGroupTrainer').checked = mode;
        $('cbxGroupMisc').checked = mode;
        enforceFilter();
	}

	function feedBack(){
		window.open("kernel/feedback.php","","height=300, width=350, resizeable=no, status=no, location=no");
	}


function init_menu()
{	ul = $$(".popup_menu");	var li  = $$(".popup_menu").getParent();

	$$(".menu_cont_link a").addEvent('mousemove', function(){
		$$(".popup_menu").setStyles({'display':'none'});
	});

	li.addEvent('mousemove', function(){		this.getElement("ul").setStyles({'display':'block'});
	});

	ul = $$(".static_menu");
	var li  = $$(".static_menu").getParent();
	li.addClass("menu_li");
	var a = li.getElement("a:first-child");
	for(k = 0; k < a.length; k++)
	{		var t = a[k];
		var id = t.getParent().getElement('ul').id;//ul.static_menu
		var id1 = id.substr(0,id.indexOf("_"));

		if(document.URL.indexOf("do=article&mode=view&id=5")!=-1 && id1=="article")
			id1 = "1article";
		if(document.URL.indexOf("do=article&mode=view&id=4")!=-1 && id1=="article")
			id1 = "1article";
		if(document.URL.indexOf("do=article&mode=catalog&id=1")!=-1 && id1=="article")
			id1 = "1article";


		if(document.URL.indexOf("do=skills")!=-1 && id1=="class")
			id1 = "skills";
		if(document.URL.indexOf("do=stats")!=-1 && id1=="class")
			id1 = "stats";
		if(document.URL.indexOf("do=article&mode=view&id=5")!=-1 && id1=="class")
			id1 = "article";
		if(document.URL.indexOf("do=article&mode=view&id=4")!=-1 && id1=="class")
			id1 = "article";
		if(document.URL.indexOf("do=article&mode=catalog&id=1")!=-1 && id1=="class")
			id1 = "article";

		if(document.URL.indexOf("do="+id1) == -1)
			var fx = new Fx.Slide(id).hide();
		t.getParent().getElement("ul").setStyles({'display':'block'});
	}

	a.addEvent('click', function(e){
		var id = this.getParent().getElement('ul').id;
		var fx = new Fx.Slide(id);
		fx.toggle();
		$(this).getParent().toggleClass('menu_hover');
		new Event(e).stop();
	});


}

	window.addEvent("domready",function(){		$$("quest_images").setStyle("display","none");
		init_menu();
	})

	function toggleTab(tab){
		var qm = $('quest_maps');
		var qi = $('quest_images');
		switch (tab){
			case 'map': qm.setStyle("display",""); qi.setStyle("display","none"); break;
			case 'image': qi.setStyle("display",""); qm.setStyle("display","none");
		}
	}
