	if (document.layers) {navigator.family = "nn4"}
	if (document.all) {navigator.family = "ie4"}
	if (window.navigator.userAgent.toLowerCase().match("gecko")) {navigator.family = "gecko"}
	overdiv="0";

function Go2(URL)
{
  if (URL == "nothing")
  {
    document.forms[0].reset();
    document.forms[0].elements[0].blur();
    return;
  }
  else
  {
    parent.frames[1].location.href = URL;
    document.forms[0].reset();
    document.forms[0].elements[0].blur();
  }
}

function FrameGo2(F, URL)
{
  FrameVar = eval("top."+F);
  FrameVar.location.href = URL;
}

function setArmy(NAME, ID)
{
	document.map_form.armee_name.value = NAME;
	document.map_form.armee_id.value = ID;
}

function Angreifen(ID)
{
	document.map_form.kolonie_id.value = ID;
	document.map_form.action.value = "Angreifen";
	document.map_form.submit();
}

function Bewegen(ID)
{
	document.map_form.kolonie_id.value = ID;
	document.map_form.action.value = "Bewegen";
	document.map_form.submit();
}

function ChangeLevel(what, level, base, max)
{
	temp = "document.FH_optionen."+level;
	document.write(temp+"->"+temp.value);
	if(what == "inc")
	{
		if (parseInt(document.FH_optionen.xp.value) > 0 && parseInt(temp.value) < max)
		{
			temp.value = parseInt(temp.value) + 1;
		}
	}
	else if (what == "dec")
	{
		help = "document.FH_optionen.old_"+level;
		if (parseInt(temp.value) > parseInt(help.value))
		{
			temp.value = parseInt(temp.value) - 1;
		}
	}
	calculate(base);
}

function zweierpotenz(potenz)
{
	if (potenz > 0)
	{
		ergebnis = 1;
		for (i = 1; i <= potenz; i++)
		{
			ergebnis = ergebnis * 2;
		}
	}
	else ergebnis = 1;
	return ergebnis;
}

function calculate(base)
{
  kosten = 0;
  for (z = 1; z <= 2; z++)
  {
    if (old_level = eval("document.FH_optionen.old_level_"+z))
	{
      if (new_level = eval("document.FH_optionen.level_"+z))
	  {
        old_anzahl = parseInt(old_level.value);
	    new_anzahl = parseInt(new_level.value);
		old_anzahl--;
		new_anzahl--;
		kosten = kosten + zweierpotenz(new_anzahl) * base - zweierpotenz(old_anzahl) * base;
	  }
	}
  }
  document.FH_optionen.xp_kosten.value = kosten;
}

// Login
function Encode()
{
  str = document.loginform.passwort_dummy.value;
  document.loginform.passwort_dummy.value = "";
  document.loginform.passwort.value = MD5(str);
  document.loginform.submit();
}

// PW ändern
function EncodeX()
{
  if ((document.settings_form.pw_old != "") && (document.settings_form.pw1 != "") && (document.settings_form.pw2 != ""))
  {
    pw_old = document.settings_form.pw_old_dummy.value;
    pw1 = document.settings_form.pw1_dummy.value;
    pw2 = document.settings_form.pw2_dummy.value;
	document.settings_form.pw1_old_dummy.value = "";
	document.settings_form.pw1_dummy.value = "";
	document.settings_form.pw2_dummy.value = "";
	
    if (pw1 == pw2)
    {
      document.settings_form.pw_old.value = MD5(pw_old);
      document.settings_form.pw1.value = MD5(pw1);
      document.settings_form.pw2.value = MD5(pw2);
      document.settings_form.submit();
    }
  }
}

// Nachschubrouten
function RouteSelect(from, to)
{
  document.forms[0].kol_from.selectedIndex = from;
  document.forms[0].kol_to.selectedIndex = to;
}

function changeColor(id, typ)
{
	var newCell = document.getElementById(id);
	var oldCell = document.getElementById(document.forms[0].elements[0].value);
	oldTyp = document.forms[0].elements[1].value;
	switch(oldTyp)
	{
		case '1': oldCell.bgColor="#999900";
		break;
		case '2': oldCell.bgColor="#009999";
		break;
		case '3': oldCell.bgColor="#0000FF";
		break;
		case '4': oldCell.bgColor="#009900";
		break;
		case '5': oldCell.bgColor="#990099";
		break;
		case '6': oldCell.bgColor="#999999";
		break;
		case '7': oldCell.bgColor="#BB4444";
		break;
	}
	newCell.bgColor = "red";
	document.forms[0].elements[0].value=id;
	document.forms[0].elements[1].value=typ;
}

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;

function popLayer(armeename, einheitenzahl, einheit1, einheit2, einheit3, einheit4, einheit5, einheit6)
{
	if (navigator.family == "gecko") {pad="0"; bord="1 bordercolor=black";}
	else {pad="1"; bord="0";} 
	desc = "&nbsp;Armee:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+armeename+"&nbsp;<br>"
		  +"&nbsp;Schützen:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+einheit1+"&nbsp;<br>"
		  +"&nbsp;Sölner:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+einheit2+"&nbsp;<br>"
		  +"&nbsp;Wolfsjäger:&nbsp;&nbsp;&nbsp;&nbsp;"+einheit3+"&nbsp;<br>"
		  +"&nbsp;Schlächter:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+einheit4+"&nbsp;<br>"
		  +"&nbsp;Wächter:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+einheit5+"&nbsp;<br>"
		  +"&nbsp;Drachen:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+einheit6+"&nbsp;<br>"
		  +"&nbsp;Gesammt:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+einheitenzahl+"&nbsp;<br>";
	
	desc_for_ie = ""
        +"<table cellspacing=0 cellpadding=0 border=0>"
		+"<tr><th class=\"normal\" bgcolor=#111111>"
        +"Armee:</th><th class=\"normal\" bgcolor=#111111>"
		+armeename
		+"</th></tr><tr><th class=\"normal\" bgcolor=#111111>"
		+"Schützen:</th><th class=\"normal\" bgcolor=#111111>"
		+einheit1
		+"</th></tr><tr><th class=\"normal\" bgcolor=#111111>"
		+"Söldner:</th><th class=\"normal\" bgcolor=#111111>"
		+einheit2
		+"</th></tr><tr><th class=\"normal\" bgcolor=#111111>"
		+"Wolfsjäger:</th><th class=\"normal\" bgcolor=#111111>"
		+einheit3
		+"</th></tr><tr><th class=\"normal\" bgcolor=#111111>"
		+"Schlächter:</th><th class=\"normal\" bgcolor=#111111>"
		+einheit4
		+"</th></tr><tr><th class=\"normal\" bgcolor=#111111>"
		+"Wächter:</th><th class=\"normal\" bgcolor=#111111>"
		+einheit5
		+"</th></tr><tr><th class=\"normal\" bgcolor=#111111>"
		+"Drachen:</th><th class=\"normal\" bgcolor=#111111>"
		+einheit6
		+"</th></tr><tr><th class=\"normal\" bgcolor=#111111>"
		+"Gesammt:</th><th class=\"normal\" bgcolor=#111111>"
		+einheitenzahl
        +"</th></tr></table>"
        +"";
		if(navigator.family =="nn4") {
        document.object1.document.write(desc);
        document.object1.document.close();
        document.object1.left=x+15;
        document.object1.top=y-5;
        }
		else if(navigator.family =="ie4"){
        object1.innerHTML=desc_for_ie;
        object1.style.pixelLeft=x+15;
        object1.style.pixelTop=y-5;
        }
		else if(navigator.family =="gecko"){
        document.getElementById("object1").innerHTML=desc;
        document.getElementById("object1").style.left=x+15;
        document.getElementById("object1").style.top=y-5;
        }
}

function hideLayer()
{
	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";}
    }
}


function changeImage( imgName, imgFile )
{
    if( document.images )
    document.images[imgName].src = imgFile;
}
