// version 1.1.061117


function createMap(objList)
	{
		// assign map attributes

document.getElementById("lo").setAttribute("centerx","235");
document.getElementById("lo").setAttribute("centery","285");
document.getElementById("lo").setAttribute("coords","242,287,244,277,234,269,221,274,222,283");
document.getElementById("lomt").setAttribute("coords","231,283,238,282,237,276,229,276,230,282,229,286,225,283,225,283,222,282,223,274,236,269,244,276,241,286,230,286");
document.getElementById("locl").setAttribute("coords","229,277,230,281,237,282,237,277");
	

document.getElementById("ea").setAttribute("centerx","245");
document.getElementById("ea").setAttribute("centery","260");
document.getElementById("ea").setAttribute("coords","254,229,278,240,278,259,270,271,253,281,233,277,227,254,233,243");	
document.getElementById("eabe").setAttribute("coords","231,261,219,271,219,252");
document.getElementById("eacm").setAttribute("coords","224,240,235,237,246,255,230,262");
document.getElementById("eaes").setAttribute("coords","240,262,236,271,246,282,263,267");
document.getElementById("eahr").setAttribute("coords","236,260,219,272,224,275,238,266");
document.getElementById("eanf").setAttribute("coords","236,243,269,243,269,237,245,228");
document.getElementById("easf").setAttribute("coords","262,265,269,245,242,246,240,261");



document.getElementById("se").setAttribute("centerx","228");
document.getElementById("se").setAttribute("centery","300");
document.getElementById("se").setAttribute("coords","211,263,230,258,235,284,252,281,276,286,253,311,228,309,204,313,201,300");		
document.getElementById("seha").setAttribute("coords","218,291,214,317,194,311,192,298,203,287");	
document.getElementById("sekt").setAttribute("coords","245,280,239,294,257,302,270,286");	
document.getElementById("sesy").setAttribute("coords","224,283,215,290,238,293,241,286");	
document.getElementById("sesx").setAttribute("coords","219,294,216,311,243,309,254,302,240,295");	
document.getElementById("setv").setAttribute("coords","202,263,219,256,224,282,216,289,200,285");		




document.getElementById("sw").setAttribute("centerx","170");
document.getElementById("sw").setAttribute("centery","300");
document.getElementById("sw").setAttribute("coords","210,264,209,298,202,318,122,340,114,326,156,290,178,287,189,274,184,263");		
document.getElementById("swas").setAttribute("coords","152,292,185,276,181,292,166,302");		
document.getElementById("swdv").setAttribute("coords","168,312,162,303,153,300,148,291,110,331,128,340,155,328");		
document.getElementById("swdo").setAttribute("coords","193,316,192,301,183,294,166,305,169,312");		
document.getElementById("swgl").setAttribute("coords","182,274,178,265,185,261,201,262,202,275");			
document.getElementById("swwi").setAttribute("coords","200,300,193,300,181,292,186,274,200,275");			
	
document.getElementById("em").setAttribute("centerx","210");
document.getElementById("em").setAttribute("centery","240");
document.getElementById("em").setAttribute("coords","210,265,223,265,252,225,235,206,219,209,194,210,214,252");		
document.getElementById("emde").setAttribute("coords","189,210,206,220,206,233,201,239,194,235");	
document.getElementById("emle").setAttribute("coords","202,241,208,233,213,238,218,234,226,242,210,251");	
document.getElementById("emli").setAttribute("coords","237,235,222,240,215,231,218,213,230,211,240,221");	
document.getElementById("emnh").setAttribute("coords","226,249,214,263,200,263,206,250,225,242");	
document.getElementById("emnt").setAttribute("coords","211,210,207,214,207,232,212,234,215,231,219,222,216,214");	


document.getElementById("wm").setAttribute("centerx","188");
document.getElementById("wm").setAttribute("centery","256");
document.getElementById("wm").setAttribute("coords","211,267,177,266,175,235,202,225,218,252");		
document.getElementById("wmst").setAttribute("coords","181,229,193,220,200,237,195,243,185,240");		
document.getElementById("wmwa").setAttribute("coords","190,257,194,253,203,250,194,244,200,236,204,242,208,252,199,266");		
document.getElementById("wmmc").setAttribute("coords","177,228,165,231,165,267,194,264,187,255,194,255,191,249,179,249,186,241");		
document.getElementById("wmwm").setAttribute("coords","186,240,193,243,195,245,202,246,203,251,194,251,181,248");		


document.getElementById("ne").setAttribute("centerx","200");
document.getElementById("ne").setAttribute("centery","190");
document.getElementById("ne").setAttribute("coords","202,137,186,153,189,192,212,223,246,210");		
document.getElementById("necl").setAttribute("coords","213,184,216,171,202,170,196,178");		
document.getElementById("nedr").setAttribute("coords","198,180,186,183,183,172,206,167");		
document.getElementById("nehm").setAttribute("coords","218,215,210,203,220,189,231,189,237,211");		
document.getElementById("neny").setAttribute("coords","218,179,182,183,179,191,186,197,204,197,204,207,212,207,212,196,229,187");		
document.getElementById("nenu").setAttribute("coords","205,165,181,171,174,155,193,138");		
document.getElementById("nesy").setAttribute("coords","196,212,215,207,208,220,200,219");		
document.getElementById("newy").setAttribute("coords","203,198,186,197,186,208,202,211");		


document.getElementById("nw").setAttribute("centerx","135");
document.getElementById("nw").setAttribute("centery","195");
document.getElementById("nw").setAttribute("coords","76,176,99,156,117,153,133,183,184,159,203,223,182,232,160,175,115,196,83,189");	
document.getElementById("nwch").setAttribute("coords","193,221,171,232,169,225,178,212,183,218");		
document.getElementById("nwcu").setAttribute("coords","157,178,176,157,187,183,166,195");	
document.getElementById("nwgm").setAttribute("coords","175,212,186,206,191,212,188,218");		
document.getElementById("nwms").setAttribute("coords","166,212,178,212,172,224,166,221");	
document.getElementById("nwln").setAttribute("coords","188,206,168,212,171,193,180,191");		
document.getElementById("nwni").setAttribute("coords","104,194,124,180,107,147,89,154,67,180,84,192");	

document.getElementById("wa").setAttribute("centerx","153");
document.getElementById("wa").setAttribute("centery","263");
document.getElementById("wa").setAttribute("coords","151,261,152,238,140,236,142,214,170,219,182,238,176,265,191,268,192,284,172,290,132,280,131,263");		
document.getElementById("wadf").setAttribute("coords","128,281,170,266,166,233,148,243,142,257,124,265");		
document.getElementById("wagw").setAttribute("coords","170,285,165,271,177,263,186,278");		
document.getElementById("wanw").setAttribute("coords","147,242,174,231,164,216,138,214,132,238");		
document.getElementById("wasw").setAttribute("coords","144,276,164,272,168,289");		


document.getElementById("sc").setAttribute("centerx","150");
document.getElementById("sc").setAttribute("centery","110");
document.getElementById("sc").setAttribute("coords","196,13,97,42,86,99,140,174,174,171,200,133,205,74");		
document.getElementById("sccs").setAttribute("coords","147,108,161,129,141,126,135,113");
document.getElementById("scdg").setAttribute("coords","156,149,168,152,169,165,131,175,123,162");
document.getElementById("scfi").setAttribute("coords","183,109,186,119,161,128,152,117");
document.getElementById("scgr").setAttribute("coords","197,68,190,97,160,95,171,67");
document.getElementById("sclb").setAttribute("coords","189,120,153,132,156,146,188,173");
document.getElementById("scno").setAttribute("coords","138,103,134,110,79,98,87,42,185,8,161,74,165,78,164,85,157,89,157,96");
document.getElementById("scst").setAttribute("coords","122,162,156,148,154,132,141,127,134,120,136,111,64,96");
document.getElementById("scty").setAttribute("coords","154,120,168,109,182,109,184,98,140,99,145,106");

	


		isClicked="false";
		// create image holder node
		
		nodeHolder = document.createElement("div");
		nodeHolder.setAttribute("id", "mapholder");
		nodeHolder.style.width="300px";
		nodeHolder.style.height="350px";
		nodeHolder.style.position="relative";
		nodeHolder.style.background="url('/images/map/bg.png')";
		
		// create image node
				
		nodeImg = document.createElement("img");
		nodeImg.setAttribute("src", "/images/map/top.png");
		nodeImg.setAttribute("id", "mapimg");		
		nodeImg.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11=M11,M22=M22)";
		nodeImg.style.position="absolute";
		nodeImg.useMap = "#ukforces";

		// create image overlay node
				
		nodeOverlay = document.createElement("img");
		nodeOverlay.setAttribute("src", "/images/map/top.png");
		nodeOverlay.setAttribute("id", "mapoverlay");
		nodeOverlay.style.position="absolute";
		nodeOverlay.style.display="none";
		nodeOverlay.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11=M11,M22=M22)";	

		// create imgmap nodes
		
		nodeMap = document.createElement("map");
		nodeMap.setAttribute("id", "ukforces");
		nodeMap.setAttribute("name", "ukforces");
		
	
		
		for (i=0; i < (objList.childNodes.length); i++)
			{
				if(objList.childNodes[i].tagName == "LI")
					{
						it = objList.childNodes[i];			
						nodeRegion = document.createElement("area");
						nodeRegion.setAttribute("shape", "poly");
						nodeRegion.setAttribute("title", it.title);
						nodeRegion.setAttribute("coords", it.getAttribute("coords"));
						nodeRegion.setAttribute("centerx", it.getAttribute("centerx"));
						nodeRegion.setAttribute("centery", it.getAttribute("centery"));
						nodeRegion.setAttribute("regionid", it.id);
						nodeRegion.setAttribute("id", "area"+it.id);
						nodeRegion.onmouseover = regionMouseOver;
						nodeRegion.onmouseout = regionMouseOut;
						nodeRegion.onclick = regionClick;
						nodeMap.appendChild(nodeRegion);		
				
					
						// add map nodes for sub regions
						nodeRegionMap = document.createElement("map");
						nodeRegionMap.setAttribute("id", "map"+it.id);
						nodeRegionMap.setAttribute("name", "map"+it.id);
					
						for (ii=0; ii < it.childNodes[2].childNodes.length; ii++)
							{
											
								if (it.childNodes[2].childNodes[ii].tagName == "LI")
									{
										iit = it.childNodes[2].childNodes[ii];
										nodeForce = document.createElement("area");
										nodeForce.setAttribute("shape", "poly");
										nodeForce.setAttribute("id", iit.id);
										nodeForce.setAttribute("title", iit.firstChild.title);
										nodeForce.setAttribute("href", iit.firstChild.href);
										nodeForce.setAttribute("coords", iit.getAttribute("coords"));
										nodeForce.onmouseover = forceMouseOver;
										nodeForce.onmouseout = forceMouseOut;
										nodeRegionMap.appendChild(nodeForce);
									}

							}
						nodeHolder.appendChild(nodeRegionMap);
					}			
			}

		
		// add image and map nodes to holder
		
		nodeHolder.appendChild(nodeImg);
		nodeHolder.appendChild(nodeOverlay);	
		nodeHolder.appendChild(nodeMap);
		
		
		
		nodeInfo = document.createElement("div");
		nodeInfo.id="mapinfo";
		nodeInfo.innerText="";
		nodeInfo.style.width="300px";
		nodeInfo.style.height="30px";
		
		nodeInfo.style.letterSpacing="0px";
		nodeInfo.style.paddingRight="4px";
		nodeInfo.style.fontFamily="Verdana";
		// nodeInfo.style.textTransform="lowercase";
		
		nodeInfoSmall = document.createElement("span");
		nodeInfoSmall.style.fontSize="13px";
		nodeInfoSmall.style.height="10px";
		nodeInfoSmall.style.width="100%";
		nodeInfoSmall.style.textAlign="right";
		nodeInfoSmall.style.fontWeight="bold";
		nodeInfoSmall.style.display="block";
		
		
		nodeInfoLarge = document.createElement("span");
		nodeInfoLarge.style.marginTop="2px";
		nodeInfoLarge.style.fontSize="100%";
		nodeInfoLarge.style.width="110%";
		nodeInfoLarge.style.height="24px";
		nodeInfoLarge.style.display="block";
		
		nodeInfoLarge.style.textAlign="right";
		
		nodeInfo.appendChild(nodeInfoSmall);
		nodeInfo.appendChild(nodeInfoLarge);
		
		// add image nodes to page and hide the old list
		
		objList.parentNode.insertBefore(nodeHolder, objList.nextSibling);
		objList.parentNode.insertBefore(nodeInfo, objList.nextSibling);
		
		objList.style.display="none";

}



function regionMouseOver()
{
	if (isClicked != "true")
		{	
	strRegionID = (this.id.substring(4,6));
	strImageID = "/images/map/hover_" + strRegionID + ".png";
	document.getElementById('mapimg').src=strImageID;
	document.getElementById('mapinfo').childNodes[1].innerHTML = this.title;
		}

}

function regionMouseOut()
{
	if ((isClicked != "true")||(!document.all))
		{
			renderDefault();
		}
}

function regionClick()
{
	isClicked = "true";	
	document.getElementById('mapholder').style.background="";
	newImg = "/images/map/full_" + this.getAttribute("regionid") + ".png";
	
	
	document.getElementById('mapimg').src=newImg;
	document.getElementById('mapinfo').childNodes[0].innerHTML = this.title;
	document.getElementById('mapinfo').childNodes[1].innerHTML = "";
	
	if (document.all)
		{
			insertNodeZoomOut();
		}
	zoomIn(this);

}

function insertNodeZoomOut()
{
	nodeZoomOut = document.createElement("a");
	nodeZoomOut.style.fontSize="100%";
	nodeZoomOut.style.cursor="hand";
	nodeZoomOut.onclick = zoomOut;
	nodeZoomOut.innerHTML = "zoom out";
	
	document.getElementById('mapinfo').childNodes[1].appendChild(nodeZoomOut);
}



function forceMouseOver()
{
	//strForceID = (event.srcElement.id);
	//strImageID = "/images/map/hover_" + strForceID + ".png";
	//document.getElementById('mapoverlay').style.display="block";
	//document.getElementById('mapoverlay').src=strImageID;
	document.getElementById('mapinfo').childNodes[1].innerHTML = this.title;
}


function forceMouseOut()
{
	//document.getElementById('mapoverlay').style.display="none";
	document.getElementById('mapinfo').childNodes[1].innerHTML = "";	
			insertNodeZoomOut();
}


function zoomIn(obj)
{

	objImage = document.getElementById('mapimg');
	objOverlay = document.getElementById('mapoverlay');
	
	positionX = obj.getAttribute("centerx");
	positionY = obj.getAttribute("centery");		

	if (document.all)
		{
	
	objectZoom(objImage, 1.2, positionX, positionY);
	setTimeout("objectZoom(objImage, 1.4, positionX, positionY)", 50);
	setTimeout("objectZoom(objImage, 1.6, positionX, positionY)", 100);
	setTimeout("objectZoom(objImage, 1.8, positionX, positionY)", 150);
	setTimeout("objectZoom(objImage, 2, positionX, positionY)", 200);
	
	objectZoom(objOverlay, 1.2, positionX, positionY);
	setTimeout("objectZoom(objOverlay, 1.4, positionX, positionY)", 50);
	setTimeout("objectZoom(objOverlay, 1.6, positionX, positionY)", 100);
	setTimeout("objectZoom(objOverlay, 1.8, positionX, positionY)", 150);
	setTimeout("objectZoom(objOverlay, 2, positionX, positionY)", 200);	
		}
		
		
	mapToUse = "#map" + (obj.getAttribute("regionid"));
		
	if (document.all)
		{	
			setTimeout("objImage.useMap=mapToUse", 100);
		}
	else
		{
		objImage.useMap=mapToUse;
			//objImage.setAttribute("useMap",mapToUse);
		}
	
	

}

function zoomOut()
{

	objImage = document.getElementById('mapimg');
	objOverlay = document.getElementById('mapoverlay');

	if (document.all)
		{
	
	positionX = 150;
	positionY = 175;		
	
	objectZoom(objImage, 1.8, positionX, positionY);
	setTimeout("objectZoom(objImage, 1.6, positionX, positionY)", 50);
	setTimeout("objectZoom(objImage, 1.4, positionX, positionY)", 100);
	setTimeout("objectZoom(objImage, 1.2, positionX, positionY)", 150);
	setTimeout("objectZoom(objImage, 1, positionX, positionY)", 200);
	
	objectZoom(objOverlay, 1.8, positionX, positionY);
	setTimeout("objectZoom(objOverlay, 1.6, positionX, positionY)", 50);
	setTimeout("objectZoom(objOverlay, 1.4, positionX, positionY)", 100);
	setTimeout("objectZoom(objOverlay, 1.2, positionX, positionY)", 150);
	setTimeout("objectZoom(objOverlay, 1, positionX, positionY)", 200);		
		}	
	objOverlay.style.display="none";
	setTimeout("renderDefault()", 300);

}


function renderDefault()
{
	isClicked = "false";
	document.getElementById('mapimg').src="/images/map/top.png";
	
	if (document.getElementById('mapholder').style.background!="url(/images/map/bg.png)")
		{
			document.getElementById('mapholder').style.background="url('/images/map/bg.png')";
		}

	mapToUse = "#ukforces";
	document.getElementById('mapimg').useMap=mapToUse;
			
	document.getElementById('mapinfo').childNodes[0].innerHTML = "";
	document.getElementById('mapinfo').childNodes[1].innerHTML = "";			
}

function objectZoom(obj, factor, posX, posY)
{

	newX = 150-(posX*factor);
	newY = 175-(posY*factor);	
	

	obj.filters.item(0).M11 = factor;  // object width
	obj.filters.item(0).M22 = factor; // object height

	obj.filters.item(0).Dx = newX; // left position
	obj.filters.item(0).Dy = newY; // top position	
}


function objectShift(obj, posX, posY)
{
	// shifts object to centre based on coords
	
	obj.filters.item(0).Dx = posX; // left position
	obj.filters.item(0).Dy = posY; // top position	

}