
DrawMiniMap()


function DrawMiniMap() {

	if(miniMapZoom<1) miniMapZoom = 1;
	
	var intPlus = 3;

	if(mapSize<2500) intPlus = 3;

	var innerInnerMiniMapTop = (mapSize-2500*Math.floor(mapSize/2500+1))/miniMapZoom;
	var innerInnerMiniMapLeft = (mapSize-2500*Math.floor(mapSize/2500+1))/miniMapZoom;

	var strMmp = '<div style="width: ' + (Math.floor(mapSize * 2 / 2500 + intPlus) * Math.round(2500 / miniMapZoom) + 10) + 'px; height: ' + (Math.floor(mapSize * 2 / 2500 + intPlus) * Math.round(2500 / miniMapZoom)) + 'px; top: ' + innerInnerMiniMapTop + '; left: ' + innerInnerMiniMapLeft + '; background-color: green; border: 1px solid darkgreen; position: absolute; text-align: left;">';

	for(i=1;i<(mapSize * 2 / 2500 + intPlus);i++) {
		for(j=1;j<(mapSize * 2 / 2500 + intPlus);j++) {
			strMmp+='<img src="' + strGameMap + '" width="' + Math.round(2500 / miniMapZoom) + '" height="' + Math.round(2500 / miniMapZoom) + '"">';
		}
		strMmp+='<br>';
	}
	strMmp+='</div>'

	//Cities

	for(i=0;i<cities.length-1;i++) {
		if(cities[i][13] == userID || cities[i][9] == intUserKingdomID) {
			strMmp+='<div title="' + cities[i][1] + '" style="border-radius: ' + (cities[i][2] / miniMapZoom * 5) + 'px; width: ' + Math.max(cities[i][2] / miniMapZoom * 10, 1) + 'px; height: ' + Math.max(cities[i][2] / miniMapZoom * 10, 1) + 'px; background-color: lightgreen; font-size: 0px; position: absolute; top:' + ((cities[i][5] - -mapSize - cities[i][2] / 2) / miniMapZoom) + '; left: ' + ((cities[i][4] - -mapSize - cities[i][2] / 2) / miniMapZoom) + '"></div>';
		}
		else {
			strMmp+='<div title="' + cities[i][1] + '" style="border-radius: ' + (cities[i][2] / miniMapZoom * 5) + 'px; width: ' + Math.max(cities[i][2] / miniMapZoom * 10, 1) + 'px; height: ' + Math.max(cities[i][2] / miniMapZoom * 10, 1) + 'px; background-color: red; font-size: 0px; position: absolute; top:' + ((cities[i][5] - -mapSize - cities[i][2] / 2) / miniMapZoom) + '; left: ' + ((cities[i][4] - -mapSize - cities[i][2] / 2) / miniMapZoom) + '"></div>';
		}
	}
	//citys.ID, name, lev, city_type, X, Y, CONCAT(accounts.title, ' ', accounts.owner), race, tag, kingdomID, gates, kingdomanme, los, owneriD

	if(parent.menu && strMmp != null) parent.menu.document.getElementById('innerkarta').innerHTML = strMmp;
}

function miniMap() {
	
	try {
		parent.menu.document.getElementById('minimapInnerBox').style.width = (bodyHolder.clientWidth / miniMapZoom) + 'px';
		parent.menu.document.getElementById('minimapInnerBox').style.height = (bodyHolder.clientHeight / miniMapZoom) + 'px';

		parent.menu.document.getElementById('minimapInnerBox').style.top = 100 - (bodyHolder.clientHeight / miniMapZoom / 2) + 'px';
		parent.menu.document.getElementById('minimapInnerBox').style.left = 101 - (bodyHolder.clientWidth / miniMapZoom / 2) + 'px';

		parent.menu.document.getElementById('innerkarta').style.top = 100 - (bodyHolder.scrollTop / miniMapZoom) - (bodyHolder.clientHeight / miniMapZoom / 2) + 'px';
		parent.menu.document.getElementById('innerkarta').style.left = 100 - (bodyHolder.scrollLeft / miniMapZoom) - (bodyHolder.clientWidth / miniMapZoom / 2) + 'px';
	}
	
	catch(err) {}
}

function minimapClickGo(x, y) {

	if(x && y) {

		// Where on the map did we click? 0,0 is center, minimap is 200x200
		var clickX = x - 100; 
		var clickY = y - 100; 

		//window.status = 'clickX=' + clickX + ' clickY=' + clickY;

		parent.map.scroll(bodyHolder.scrollLeft + clickX * miniMapZoom, bodyHolder.scrollTop + clickY * miniMapZoom);

		//alert(clickX + ', ' + clickY);

	}
}
