var DispMap=null
function mapdisplay(LocationNo,MapSize)
	{
//	---WINDOW-------------------------------------------------------------------------------------------------------------
	scrbars="no"
	mapwidth=MapSize*200
	mapheight=MapSize*132
	if (MapSize>=10){MapRows=10; mapheight=1320} else {MapRows=MapSize}
	if (mapwidth >= screen.width){
		scrbars="yes";
		windowwidth=screen.width-30;
		windowheight=screen.height-90
		}
	else{
		windowwidth=mapwidth;
		windowheight=mapheight
		}
	WindowProperties='height='+windowheight+',width='+windowwidth+',top=20,left=10,scrollbars='+scrbars+',status=no'
//	---MAP-------------------------------------------------------------------------------------------------------------
	Row=new Array
	Column=new Array
	MapIDCenter=Location[LocationNo][1];
	ColumnNr=+MapIDCenter.substring(5,7).valueOf()
	MapLeft=ColumnNr-Math.ceil(MapSize/2-0.5)
	MapRight=ColumnNr+Math.ceil(MapSize/2-0.5)
	if (MapLeft<1)MapLeft=1
	if (MapRight>18)MapLeft=19-MapSize
	MapLetterASCII=MapIDCenter.charCodeAt(4)
	MapTop=MapLetterASCII-Math.ceil(MapSize/2+0,5)
	if (MapSize==2)MapTop=MapTop-1 
	MapBottom=MapLetterASCII+Math.ceil(MapSize/2+0,5)
	if (MapTop<65)MapTop=64
	if (MapBottom>74)MapTop=74-MapRows
	for (i=0; i<(MapSize); i++){
		Column[i]=MapLeft+i;
		Row[i]=String.fromCharCode(MapTop+i+1);
		}
//	---PIN(S)-----------------------------------------------------------------------------------------------------------
	PinX=new Array;
	PinY=new Array;
	Pin=new Array;
	PageRedirect=new Array;
	StructureSurvives=new Array;
	PinType=new Array;
	CorrPinX=new Array;
	CorrPinY=new Array;
	if (LocationNo==0){imax=Location.length} else {imax=2}
	for (i=0; i<imax; i++){
		if (LocationNo>0){j=LocationNo} else {j=i};
		StationName=Location[i][0];
		StationFirstLetter=StationName.charCodeAt(0);
		StateRedirect=State;
		if (State=="Minnesota"){
			if (StationFirstLetter<67){
				StateRedirect="Minnesota1"
				}
			if (StationFirstLetter>=67 && StationFirstLetter<72){
				StateRedirect="Minnesota2"
				}
			if (StationFirstLetter>=72 && StationFirstLetter<78){
				StateRedirect="Minnesota3"
				}
			if (StationFirstLetter>=78){
				StateRedirect="Minnesota4"
				}
			};
		if (State=="Montana"){
			if (StationFirstLetter<72){
				StateRedirect="Montana1"
				}
			else{
				StateRedirect="Montana2"
				}
			};
		if (State=="NorthDakota"){
			if (StationFirstLetter<69){
				StateRedirect="NorthDakota1"
				}
			if (StationFirstLetter>=69 && StationFirstLetter<76){
				StateRedirect="NorthDakota2"
				}
			if (StationFirstLetter>=76 && StationFirstLetter<80){
				StateRedirect="NorthDakota3"
				}
			if (StationFirstLetter>=80){
				StateRedirect="NorthDakota4"
				}
			};
		PageRedirect[i]="GNEDepots"+StateRedirect+".htm#"+Location[j][0];
		MapID=Location[j][1];
		PinX[i]=Location[j][2];
		PinY[i]=Location[j][3];
		StructureSurvives[i]=Location[j][4];
		Pin=Location[j][5];
		ColumnNr=+MapID.substring(5,7).valueOf();
		MapLetterASCII=MapID.charCodeAt(4)
		CorrPinX[i]=(ColumnNr-MapLeft)*200;
		CorrPinY[i]=(MapLetterASCII-MapTop-1)*132;
		if (LocationNo>0 && Pin==2){Pin=0};
		if (Pin==0){
			PinType[i]="images/MapPinRight.GIF"
			};
		if (Pin==1){
			PinType[i]="images/MapPinLeft.GIF";
			CorrPinX[i]=CorrPinX[i]-22;
			};
		if (Pin==2){
			PinType[i]="images/MapPinRightBelow.GIF";
			CorrPinY[i]=CorrPinY[i]+25;
			};
		PinX[i]=PinX[i]+CorrPinX[i]-1;
		PinY[i]=PinY[i]+CorrPinY[i]-26
		}
//	---MAP WRITE---------------------------------------------------------------------------------------------------------
	{
	if(DispMap!=null&&DispMap.closed==false)
		DispMap.close();
		DispMap=window.open("", "mapwindow", WindowProperties);
		DispMap.document.open();
		DispMap.document.write("<html>");
		DispMap.document.write("<head>");
		DispMap.document.write("<title>GN 19"+MapIDCenter.substring(2,4)+" System Map - "+Location[LocationNo][0]+" - Great Northern Empire</title>");
		DispMap.document.write("<style type='text/css'> body {margin:0pt} </style>");
		DispMap.document.write("<script language='JavaScript'>");
		DispMap.document.write("function MapRedirect(){");
		DispMap.document.write("timer = setTimeout('window.close();', 10);}");
		DispMap.document.write("</script>");
		DispMap.document.write("</head>");
		DispMap.document.write("<body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 bgcolor='#FFFFFF'>");
		DispMap.document.write("<table border='0' cellspacing='0' cellpadding='0'>");
		for (y=0; y<MapRows; y++){
			DispMap.document.write("<tr>");
				for (x=0; x<MapSize; x++){
					MapSrc="maps/GN49"+Row[y]+Column[x]+".JPG";
					DispMap.document.write("<td width=200><a href='javascript: window.close()'><img border='0' src='"+MapSrc+"' width='200' height='132' title='Click to close map'></a></td>");
	 			}
				DispMap.document.write("</tr>");
		}
		DispMap.document.write("</table>");
		for (i=1; i<imax; i++){
			if (LocationNo==0){
				AltMessage="Click to go to the "+Location[i][0]+" listing"
				}
			else{
				PageRedirect[i]="javascript: window.close()";
				AltMessage="Click to close map"
				}
			if (LocationNo==0&&StructureSurvives[i]==0){}
				else{
				DispMap.document.write("<a href='"+PageRedirect[i]+"' target='gnepage' onClick='MapRedirect()'><img border='0' src='"+PinType[i]+"' style='left: "+PinX[i]+"; top: "+PinY[i]+"; position: absolute' title='"+AltMessage+"'></a>");
				}
			}
		DispMap.document.write("</html>");
		DispMap.document.close();
		DispMap.focus();
		if (mapwidth >= screen.width){DispMap.scroll(PinX[LocationNo]-(screen.width/2),PinY[LocationNo]-(screen.height/2))}
	}
}
