<? include $DOCUMENT_ROOT."/zzzfilelist.inc"; ?>
<? include Inc("metootop.inc.php"); ?>
<? $where="displayres"; include Inc("checkgameaccess.inc.php"); ?>
<?
	$fn=Inc("mapdata.csv");
	$fp = fopen ($fn, "r");
	$mapcontent = fread($fp, filesize($fn));
	fclose($fp);
	Decrunch($mapcontent);
	$mapcontentcell=$cell;
	
	$fn=Inc("mapriver.csv");
	$fp = fopen ($fn, "r");
	$mapriver = fread($fp, filesize($fn));
	fclose($fp);
	Decrunch($mapriver);
	$mapriver=$cell;
	
	$fn=Inc("maproad.csv");
	$fp = fopen ($fn, "r");
	$maproad = fread($fp, filesize($fn));
	fclose($fp);
	Decrunch($maproad);
	$maproad=$cell;
	
	$fn=Inc("fileroad.csv");
	$fp = fopen ($fn, "r");
	$fileroad = fread($fp, filesize($fn));
	fclose($fp);
	Decrunch($fileroad);
	$fileroad=$cell;
	
	$fn=Inc("fileriver.csv");
	$fp = fopen ($fn, "r");
	$fileriver = fread($fp, filesize($fn));
	fclose($fp);
	Decrunch($fileriver);
	$fileriver=$cell;

	$fn=Inc("map_names.csv");
	$fp = fopen ($fn, "r");
	$content = fread($fp, filesize($fn));
	fclose($fp);
	Decrunch($content);
	$cellnames=$cell;
	$cellnames_lin=$lin;
?>
<style type="text/css">
  .a { position:absolute;top:0px;right:0px;z-index:1 }
  .b { z-index:2 }
  .r { position:relative; }
  .c { position:absolute;top:10px;right:18px;z-index:10 }
</style>
<SCRIPT LANGUAGE="JavaScript">
var moveHorse=false, moveUnfed=false, showTurn=false, showWoMarch=false;
var pathFinding=false, displayRange=false;
var idMem, errorMem=0, color_errorMem;
var waynb=0;
var way_id=new Array(50);
var way_color=new Array(50);
var way_count=new Array(50), way_countUnfed=new Array(50);
var way_countHorse=new Array(50), way_countHorseUnfed=new Array(50);
var way_road=new Array(50);
var Move=new Array (<?
	for ($i=1; $i<=count($MoveCost)-1; $i++) {
		if ($i!=1) echo ", ";
		echo $MoveCost[$i];
	}
?>
);
var roadName=new Array (<?
	for ($i=0; $i<=6; $i++) {
		if ($i!=0) echo ", ";
		echo "'".$loc[$loctag[4]+15+$i][$lang]."'";
	}
?>
);
var MoveRoad=new Array (<?
	for ($i=1; $i<=count($MoveCostRoad)-1; $i++) {
		if ($i!=1) echo ", ";
		echo $MoveCostRoad[$i];
	}
?>
);
var MoveHorse=new Array (<?
	for ($i=1; $i<=count($MoveCostHorse)-1; $i++) {
		if ($i!=1) echo ", ";
		echo $MoveCostHorse[$i];
	}
?>
);
var MoveHorseRoad=new Array (<?
	for ($i=1; $i<=count($MoveCostHorseRoad)-1; $i++) {
		if ($i!=1) echo ", ";
		echo $MoveCostHorseRoad[$i];
	}
?>
);
var Ground=new Array(
<?
	for ($i=1; $i<=$maplin; $i++) {
		if ($i!=1) echo ",\n";
		echo "\t new Array(";
		for ($j=1; $j<=$mapcol; $j++) {
			if ($j!=1) echo ",";
			echo $mapcontentcell[$i][$j];
		}
		echo ")";
	}
?>
);
var GroundColor=new Array(
<?
	for ($i=1; $i<=count($mapcolor); $i++) {
		if ($i!=1) echo ", ";
		echo "'".$mapcolor[$i]."'";
	}
?>
);
var VisionStart=new Array(
<?
	for ($i=0; $i<=count($visionstart); $i++) {
		if ($i!=0) echo ", ";
		echo "'".$visionstart[$i]."'";
	}
?>
);
var River=new Array(
<?
	for ($i=1; $i<=$maplin; $i++) {
		if ($i!=1) echo ",\n";
		echo "\t new Array(";
		for ($j=1; $j<=$mapcol; $j++) {
			if ($j!=1) echo ",";
			if ($mapriver[$i][$j]=="") { $mapriver[$i][$j]="000000"; }
			if ($mapriver[$i][$j]==" ") { $mapriver[$i][$j]="000000"; }
			echo "'".$mapriver[$i][$j]."'";
		}
		echo ")";
	}
?>
);
var Road=new Array(
<?
	for ($i=1; $i<=$maplin; $i++) {
		if ($i!=1) echo ",\n";
		echo "\t new Array(";
		for ($j=1; $j<=$mapcol; $j++) {
			if ($j!=1) echo ",";
			if ($maproad[$i][$j]=="") { $maproad[$i][$j]="000000"; }
			echo "'".$maproad[$i][$j]."'";
		}
		echo ")";
	}
?>
);

function isEven(x) {
	return (x%2)?false:true;
}

function M(id) {
	var r;
	if (id==0) {
		document.getElementById('mask').src="gfx/nothing.gif";
	} else {
		if (id<=<? echo $userlin; ?>) {
			document.getElementById('mask').src="turn/moves/move-"+id+"-1.gif";
		} else {
			if (id<=<? echo ($userlin+25); ?>) {
				r=id-<? echo $userlin; ?>;
				document.getElementById('mask').src="turn/moves/move-sugg"+r+"-1.gif";
			} else {
				if (id==<? echo ($userlin+25+1); ?>) {
					document.getElementById('mask').src="turn/moves/move-allplanned-1.gif";
				} else {
					if (id==<? echo ($userlin+25+2); ?>) {
						document.getElementById('mask').src="turn/moves/move-allenemy-1.gif";
					}
				}
			}
		}
	}
}

function showRange() {
	var r, startx, starty, x, y, cx, cy, c, vs, add=0, dis=0;
	if (displayRange) {
		displayRange=false;
		pathFinding=false;
		notThisTime=true;
		for(i=1; i<=waynb; i++) {
			document.getElementById(way_id[i]).style.backgroundColor = way_color[i];
			document.getElementById(way_id[i]+".c").innerHTML="";
		}
		waynb=0;
	} else {
		if (pathFinding) {
			displayRange=true;
			dis=9;
		}
	}
			vs=idMem.split('.');
			startx=vs[0]*1;
			starty=vs[1]*1;
			if ((starty/2)!=parseInt(starty/2)) { add=-1; }
			
			y=starty-13;
			for (x=startx-6; x<=startx+7; x++) {
				if ((x>=1) && (y>=1) && (x<=44) && (y<=39)) {
					cx=x+add;
					cy=y;
					c=cx+"."+cy;
					document.getElementById(c).style.backgroundColor = GroundColor[Ground[cy-1][cx-1]-1+dis];
				}
			}
			y=starty+13;
			for (x=startx-6; x<=startx+7; x++) {
				if ((x>=1) && (y>=1) && (x<=44) && (y<=39)) {
					cx=x+add;
					cy=y;
					c=cx+"."+cy;
					document.getElementById(c).style.backgroundColor = GroundColor[Ground[cy-1][cx-1]-1+dis];
				}
			}
			x=startx-13;
			y=starty+1;
			do {
				y--;
				if ((y/2)!=parseInt(y/2)) { x++; }
				if ((x>=1) && (y>=1) && (x<=44) && (y<=39)) {
					cx=x+add;
					cy=y;
					c=cx+"."+cy;
					document.getElementById(c).style.backgroundColor = GroundColor[Ground[cy-1][cx-1]-1+dis];
				}
			} while (y>starty-13)
			x=startx-13;
			y=starty-1;
			do {
				y++;
				if ((y/2)!=parseInt(y/2)) { x++; }
				if ((x>=1) && (y>=1) && (x<=44) && (y<=39)) {
					cx=x+add;
					cy=y;
					c=cx+"."+cy;
					document.getElementById(c).style.backgroundColor = GroundColor[Ground[cy-1][cx-1]-1+dis];
				}
			} while (y<starty+13)
			x=startx+14;
			y=starty+1;
			do {
				y--;
				if ((y/2)==parseInt(y/2)) { x--; }
				if ((x>=1) && (y>=1) && (x<=44) && (y<=39)) {
					cx=x+add;
					cy=y;
					c=cx+"."+cy;
					document.getElementById(c).style.backgroundColor = GroundColor[Ground[cy-1][cx-1]-1+dis];
				}
			} while (y>starty-13)
			x=startx+14;
			y=starty-1;
			do {
				y++;
				if ((y/2)==parseInt(y/2)) { x--; }
				if ((x>=1) && (y>=1) && (x<=44) && (y<=39)) {
					cx=x+add;
					cy=y;
					c=cx+"."+cy;
					document.getElementById(c).style.backgroundColor = GroundColor[Ground[cy-1][cx-1]-1+dis];
				}
			} while (y<starty+13)
}

function Col(id) {
	var r, startx, starty, x, y, cx, cy, c, xm, vs, t, ts, te;
	if (pathFinding) {
		pathFinding=false;
		notThisTime=true;
		for(i=1; i<=waynb; i++) {
			document.getElementById(way_id[i]).style.backgroundColor = way_color[i];
			document.getElementById(way_id[i]+".c").innerHTML="";
		}
		waynb=0;
	}
	if (id==0) {
		for (y=1; y<=39; y++) {
			for (x=1; x<=44; x++) {
				c=GroundColor[Ground[y-1][x-1]-1];
				document.getElementById(x+"."+y).style.backgroundColor = c;
			}
		}
	} else {
		if (id<=25) {
			xm=9;
			vs=VisionStart[id].split('.');
			startx=vs[0]*1;
			starty=vs[1]*1;
			for (y=1; y<=13; y++) {
				for (x=1; x<=xm; x++) {
					cx=x+startx-1;
					cy=y+starty-1;
					c=cx+"."+cy;
					document.getElementById(c).style.backgroundColor = GroundColor[Ground[cy-1][cx-1]-1+9];
				}
				if (xm==9) { xm=8; } else { xm=9; }
			}
		} else {
			if (id==26) { ts=1; te=10; }
			if (id==27) { ts=11; te=20; }
			if (id==28) { ts=21; te=25; }
			if (id==29) { ts=1; te=25; }
			
			for (t=ts; t<=te; t++) {
				xm=9;
				vs=VisionStart[t].split('.');
				startx=vs[0]*1;
				starty=vs[1]*1;
				for (y=1; y<=13; y++) {
					for (x=1; x<=xm; x++) {
						cx=x+startx-1;
						cy=y+starty-1;
						c=cx+"."+cy;
						document.getElementById(c).style.backgroundColor = GroundColor[Ground[cy-1][cx-1]-1+9];
					}
					if (xm==9) { xm=8; } else { xm=9; }
				}
			}
		}
	}
}

function HL(id) {
	waynb++;
	way_id[waynb]=id;
	way_color[waynb]=document.getElementById(id).style.backgroundColor;
	document.getElementById(id).style.backgroundColor = '#FFFF80';
}

function C(id) {
	var i, t, sum, show, add, limit;
	if (id=='move1') {
		moveHorse=false;
		document.getElementById(id).style.backgroundColor = '#FFFF80';
		document.getElementById('move2').style.backgroundColor = '#372710';
	}
	if (id=='move2') {
		moveHorse=true;
		document.getElementById(id).style.backgroundColor = '#FFFF80';
		document.getElementById('move1').style.backgroundColor = '#372710';
	}
	if (id=='move3') {
		moveUnfed=!moveUnfed;
		if (moveUnfed) {
			document.getElementById(id).style.backgroundColor = '#FFFF80';
		} else {
			document.getElementById(id).style.backgroundColor = '#372710';
		}
	}
	if (id=='move4') {
		showTurn=false;
		showWoMarch=false;
		document.getElementById(id).style.backgroundColor = '#FFFF80';
		document.getElementById('move5').style.backgroundColor = '#372710';
		document.getElementById('move6').style.backgroundColor = '#372710';
	}
	if (id=='move5') {
		showTurn=true;
		showWoMarch=false;
		document.getElementById(id).style.backgroundColor = '#FFFF80';
		document.getElementById('move4').style.backgroundColor = '#372710';
		document.getElementById('move6').style.backgroundColor = '#372710';
	}
	if (id=='move6') {
		showTurn=true;
		showWoMarch=true;
		document.getElementById(id).style.backgroundColor = '#FFFF80';
		document.getElementById('move4').style.backgroundColor = '#372710';
		document.getElementById('move5').style.backgroundColor = '#372710';
	}
	t=1;
	sum=0;
	for (i=2; i<=waynb; i++) {
		id=way_id[i]+".c";
		if (showWoMarch) { limit=12; } else { limit=14; }
		if (!moveUnfed) {
			if (!moveHorse) {
				show=way_count[i];
				add=way_count[i]-way_count[i-1];
			} else {
				show=way_countHorse[i];
				add=way_countHorse[i]-way_countHorse[i-1];
			}
		} else {
			if (!moveHorse) {
				show=way_countUnfed[i];
				add=way_countUnfed[i]-way_countUnfed[i-1];
			} else {
				show=way_countHorseUnfed[i];
				add=way_countHorseUnfed[i]-way_countHorseUnfed[i-1];
			}
		}
		if (sum+add>limit) {
			t=t+1;
			sum=add;
		} else {
			sum=sum+add;
		}
		if (!showTurn) {
			document.getElementById(id).innerHTML="<font size=2 color=red><b>"+show;
		} else {
			document.getElementById(id).innerHTML="<font size=2 color=green><b>"+t;
		}
	}
}

function S(id) {
	var i, text;
	var ids=id.split('.'), ids2, difx, dify;
	var m, mmem, mHorse, sdir=0, riv, roa;
	var notThisTime=false, newCell=true;
	var canGo=true, moreWay=0;
	if (errorMem!=0) {
		document.getElementById(errorMem).style.backgroundColor = color_errorMem;
		document.getElementById(errorMem+".c").innerHTML="";
		errorMem=0;
	}
	if (pathFinding) {
		if (id==idMem) {
			pathFinding=false;
			notThisTime=true;
			for(i=1; i<=waynb; i++) {
				document.getElementById(way_id[i]).style.backgroundColor = way_color[i];
				document.getElementById(way_id[i]+".c").innerHTML="";
			}
			waynb=0;
		} else {
			for (i=1; i<=waynb; i++) {
				if (id==way_id[i]) { k=i; newCell=false; }
			}
			if (newCell) {
				ids2=way_id[waynb].split('.');
				dify=ids[1]-ids2[1]; difx=ids[0]-ids2[0];
				if (dify==0) {
					if (difx==-1) { sdir=4; }
					if (difx==1) { sdir=1; }
				} else {
					if (dify==-1) {
						if (isEven(ids2[1])) {
							if (difx==0) { sdir=5; }
							if (difx==1) { sdir=6; }
						} else {
							if (difx==-1) { sdir=5; }
							if (difx==0) { sdir=6; }
						}
					}
					if (dify==1) {
						if (isEven(ids2[1])) {
							if (difx==0) { sdir=3; }
							if (difx==1) { sdir=2; }
						} else {
							if (difx==-1) { sdir=3; }
							if (difx==0) { sdir=2; }
						}
					}
				}
				if (sdir==0) {
					canGo=false;
				} else {
					riv=River[ids[1]-1][ids[0]-1].charAt(sdir-1);
					roa=Road[ids[1]-1][ids[0]-1].charAt(sdir-1);
					if (riv==1) {
						if (roa>1) {
							moreWay=1;
						} else {
							canGo=false;
						}
					}
					if (riv==2) {
						if (roa>1) {
							moreWay=1;
						} else {
							moreWay=2;
						}
					}
					m=Ground[ids[1]-1][ids[0]-1];
					mHorse=m;
					if ((roa==1) || (roa>3)) {
						m=MoveRoad[m-1];
						mHorse=MoveHorseRoad[mHorse-1];
					} else {
						m=Move[m-1];
						mHorse=MoveHorse[mHorse-1];
					}
					mmem=m;
					m=m+moreWay;
					mHorse=mHorse+moreWay;
					if (canGo) {
						HL(id);
						way_count[waynb]=way_count[waynb-1]+m;
						way_countHorse[waynb]=way_countHorse[waynb-1]+mHorse;
						way_countUnfed[waynb]=way_countUnfed[waynb-1]+Math.ceil(m*4/3);
						way_countHorseUnfed[waynb]=way_countHorseUnfed[waynb-1]+Math.ceil(mHorse*4/3);
						way_road[waynb]=roadName[sdir];
						C(0);
					}
//					document.getElementById(id+".c").innerHTML="<font size=1 color=red><b>"+sdir+"("+riv+","+roa+","+mmem+","+moreWay+")="+m;
				}
				if (!canGo) {
					color_errorMem=document.getElementById(id).style.backgroundColor;
					document.getElementById(id).style.backgroundColor = '#FF0000';
					errorMem=id;
				}
			} else {
				for (i=k; i<=waynb; i++) {
					document.getElementById(way_id[i]).style.backgroundColor = way_color[i];
					document.getElementById(way_id[i]+".c").innerHTML="";
				}
				waynb=k-1;
			}
		}
		text="";
		for (i=2; i<=waynb; i++) {
			if (i!=2) { text=text+", "; }
			text=text+way_road[i];
		}
		document.getElementById("displayRoad").innerHTML=text;
	}
	if ((!pathFinding) && (!notThisTime)) {
		pathFinding=true;
		idMem=id;
		waynb=0;
		HL(id);
		way_count[waynb]=0;
		way_countHorse[waynb]=0;
		way_countUnfed[waynb]=0;
		way_countHorseUnfed[waynb]=0;
	}
}

function DC(id) {
	openWindow('inc/input_data.inc.php?game_checked=<? echo $game_checked; ?>&id='+id,'400','600');
}

overdiv="0";
//  #########  CREATES POP UP BOXES 
function pL(text){
if (navigator.family == "gecko") {pad="0"; bord="1 bordercolor=black";}
else {pad="1"; bord="0";}
	desc="<table cellspacing=0 cellpadding="+pad+" border="+bord+"  bgcolor=000000><tr><td>\n"
	+"<table cellspacing=0 cellpadding=3 border=0 width=100%><tr><td bgcolor=ffffdd><center><font size=-1>\n"
	+text
	+"\n</td></tr></table>\n"
	+"</td></tr></table>";
if(navigator.family =="nn4") {
	document.object1.document.write(desc);
	document.object1.document.close();
	document.object1.left=x-40;
	document.object1.top=y+20;
	}
else if(navigator.family =="ie4"){
	object1.innerHTML=desc;
	object1.style.pixelLeft=x-40;
	object1.style.pixelTop=y+20;
	}
else if(navigator.family =="gecko"){
	document.getElementById("object1").innerHTML=desc;
	document.getElementById("object1").style.left=x-40;
	document.getElementById("object1").style.top=y+20;
	}
}
function hL(){
if (overdiv == "0") {
	if(navigator.family =="nn4") {eval(document.object1.top="-500");}
	else if(navigator.family =="ie4"){object1.innerHTML="";}
	else if(navigator.family =="gecko") {document.getElementById("object1").style.top="-500";}
	}
}

//  ########  TRACKS MOUSE POSITION FOR POPUP PLACEMENT
var isNav = (navigator.appName.indexOf("Netscape") !=-1);
function handlerMM(e){
x = (isNav) ? e.pageX : event.clientX + document.body.scrollLeft;
y = (isNav) ? e.pageY : event.clientY + document.body.scrollTop;
}
if (isNav){document.captureEvents(Event.MOUSEMOVE);}
document.onmousemove = handlerMM;

// This array is used for hotkeys
var keyActions = new Array ();
keyActions [0] = {character:  "q", 
                  actionType: "code", 
                  param:      "C('move1');"};
keyActions [1] = {character:  "z", 
                  actionType: "code", 
                  param:      "C('move2');"};
keyActions [2] = {character:  "e", 
                  actionType: "code", 
                  param:      "C('move3');"};
keyActions [3] = {character:  "x", 
                  actionType: "code", 
                  param:      "showRange('');"};
// End of user defined array

//  End -->
</script>
<div id="object1" style="position:absolute; background-color:FFFFDD;color:black;border-color:black;border-width:20; visibility:show; left:25px; top:-100px; z-index:+100" onmouseover="overdiv=1;"  onmouseout="overdiv=0; setTimeout('hL()',1000)">
pop up description layer
</div>
<? include Inc("loaddata_res.inc.php"); ?>
<? include Inc("displaynames.inc.php"); ?>
<?
	for ($loc=1; $loc<=8; $loc++) {
		$globalminmax[$loc]=0;
		$globalmax[$loc]=0;
	}
	for ($j=1; $j<=$maplin; $j++) {
		for ($i=1; $i<=$mapcol+1; $i++) {
			$found=true;
			if (!(1&$j)) {
				if ($i==1) {
					$found=false;
				}
			}
			if (1&$j) {
				if ($i==$mapcol+1) {
					$found=false;
				}
			}
			if ($found) {
				$k=$i;
				if (!(1&$j)) {
					$k=$i-1;
				}
				if (strlen($towninhex_num[$k][$j])>0) {
					$pieces=explode(";",$towninhex_num[$k][$j]);
					for ($loc=1; $loc<=8; $loc++) {
						$localmin[$loc]=9999;
						$localmax[$loc]=0;
					}
					for ($ip=0; $ip<=count($pieces)-1; $ip++) {
						$l=$pieces[$ip]*1;
						
						if ($town[$l]->climate>0) {
							if ($town[$l]->localprod[8]>0) {
								#$total=(int)($town[$l]->localprod[8]/$ProdVSClimate[8-1][$town[$l]->climate-1]/100);
								$total=$town[$l]->localprod[8]/($ProdVSClimate[8-1][$town[$l]->climate-1]/100);
								
								$localmin[8]=min($localmin[8], $total);
								$localmax[8]=max($localmax[8], $total);
							}
						}
					}
					if ($localmin[8]!=9999) {
						$globalminmax[8]=max($localmin[8], $globalminmax[8]);
						$globalmax[8]=max($localmax[8], $globalmax[8]);
					}
				}
			}
		}
	}

	echo "<table width=".(($mapcol+0.5)*$mapcell)." cellpadding=0 cellspacing=0 border=0>";
	echo "<tr height=1>";
	for ($i=1; $i<=2*$mapcol+1; $i++) {
		echo "<td width=".(int)($mapcell/2).">";
		echo "</td>";
	}
	echo "</tr>";
	for ($j=1; $j<=$maplin; $j++) {
		echo "<tr height=$mapcell valign=top align=center>\n";
		for ($i=1; $i<=$mapcol+1; $i++) {
			if (($i==1) && ($j==1)) {
				echo "<div style='position:absolute;z-index:100'>";
				echo "<img id='mask' src='gfx/nothing.gif'>";
				echo "</div>";
			}
			
			$found=true;
			if (!(1&$j)) {
				if ($i==1) {
					echo "<td width=".(int)($mapcell/2).">";
					$found=false;
				}
			}
			if (1&$j) {
				if ($i==$mapcol+1) {
					echo "<td width=".(int)($mapcell/2).">";
					$found=false;
				}
			}
			if ($found) {
				echo "<td colspan=2";
				$k=$i;
				if (!(1&$j)) {
					$k=$i-1;
				}
				echo " id='$k.$j' onclick='S(this.id)' onDblclick='DC(this.id)'";
				echo " bgcolor=".$mapcolor[$mapcontentcell[$j][$k]]."><div class=r>";
				
				if ($fileriver[$j][$k]=="") { $fileriver[$j][$k]="e.gif"; }
				echo "<img src='gfx/".$fileriver[$j][$k]."' class=a>";
				if ($fileroad[$j][$k]!="") { echo "<img src='gfx/".$fileroad[$j][$k]."' class=a>"; }
				
				if (strlen($towninhex_num[$k][$j])>0) {
					$pieces=explode(";",$towninhex_num[$k][$j]);
					for ($loc=1; $loc<=8; $loc++) {
						$localmin[$loc]=9999;
						$localmax[$loc]=0;
					}
					for ($ip=0; $ip<=count($pieces)-1; $ip++) {
						$l=$pieces[$ip]*1;
						
						if ($town[$l]->climate>0) {
							if ($town[$l]->localprod[8]>0) {
								#$total=(int)($town[$l]->localprod[8]/$ProdVSClimate[8-1][$town[$l]->climate-1]/100);
								$total=$town[$l]->localprod[8]/($ProdVSClimate[8-1][$town[$l]->climate-1]/100);
								
								$localmin[8]=min($localmin[8], $total);
								$localmax[8]=max($localmax[8], $total);
							}
						}
					}
					if ($localmin[8]!=9999) {
						$total=(($localmin[8]*100/$globalminmax[8])+5)/10;
						$total=(int)($total)*10;
						echo "<img src='gfx/res_8_".$total."' class=a>";
					}
				}
				
				$hex="";
				if ($k<10) { $hex.="0"; } $hex.=$k;
				if ($j<10) { $hex.="0"; } $hex.=$j;
				echo "<font size=1px class=b>".$hex."<div id='$k.$j.c' class=c></div>";
				echo "<br>";

			}
			echo "</div>";
			echo "</td>\n";
		}
		echo "</tr>\n";
	}
	echo "</table>";
?>
<br><br><br><br>
</body>
</html>