// globale Instanz von XMLHttpRequest
var xmlHttp = false;// char boxtop
var xmlHttpGet = false;//load map
var xmlHttpSend = false;//save click
// XMLHttpRequest-Instanz erstellen
// ... fr Internet Explorer
try 
{
	xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
	xmlHttpGet  = new ActiveXObject("Msxml2.XMLHTTP");
	xmlHttpSend  = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
    try
	{
        xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
        xmlHttpGet  = new ActiveXObject("Microsoft.XMLHTTP");
        xmlHttpSend  = new ActiveXObject("Microsoft.XMLHTTP");
    }
	catch(e)
	{
        xmlHttp  = false;
        xmlHttpGet  = false;
        xmlHttpSend  = false;
    }
}
// ... fr Mozilla, Opera und Safari
if (!xmlHttp  && typeof XMLHttpRequest != 'undefined')
{
    xmlHttp = new XMLHttpRequest();
}
if (!xmlHttpGet  && typeof XMLHttpRequest != 'undefined')
{
    xmlHttpGet = new XMLHttpRequest();
}
if (!xmlHttpSend  && typeof XMLHttpRequest != 'undefined')
{
    xmlHttpSend = new XMLHttpRequest();
}
// get data every min
setInterval("loadBoxtop()",60*1000);
//loadMap();

function loadMap()
{
	try 
	{
		if (xmlHttpGet)
		{
			xmlHttpGet.open('GET', 'map.php?t=map', true);
			xmlHttpGet.onreadystatechange = function ()
			{
				if (xmlHttpGet.readyState == 4 && xmlHttpGet.status == 200)
				{
					document.getElementById("map_window").innerHTML = xmlHttpGet.responseText;
					loadSystemMsg();
				}
			};
			xmlHttpGet.send(null);
		}
	}
	catch(e){}
}

function loadSystemMsg()
{
	try 
	{
		if (xmlHttpGet)
		{
			xmlHttpGet.open('GET', 'map.php?t=ajaxsystemmsg', true);
			xmlHttpGet.onreadystatechange = function ()
			{
				if (xmlHttpGet.readyState == 4 && xmlHttpGet.status == 200)
				{
					document.getElementById("systemmsg_window").innerHTML = xmlHttpGet.responseText;
					loadBoxtop();
				}
			};
			xmlHttpGet.send(null);
		}
	}
	catch(e){}
}
function saveClick(x,y)
{
	if(document.getElementById('map_loading').style.visibility=='visible')return;
	document.getElementById('map_loading').style.visibility='visible';
	try 
	{
		if (xmlHttpSend) 
		{
			xmlHttpSend.open('POST', 'map.php?t=click');
			xmlHttpSend.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlHttpSend.send('x='+x+'&y='+y);
			xmlHttpSend.onreadystatechange = function ()
			{
				if (xmlHttpSend.readyState == 4)
				{
					document.getElementById("saveClick").innerHTML = xmlHttpSend.responseText;
					loadMap();
				}
			};
		}
	}
	catch(e){}
}

function loadBoxtop()
{
	try 
	{
		if (xmlHttp)
		{
			xmlHttp.open('GET', 'map.php?t=ajaxboxtop', true);
			xmlHttp.onreadystatechange = function ()
			{
				if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
				{
					document.getElementById("char_window").innerHTML = xmlHttp.responseText;
					if(document.getElementById('map_loading')!=null)
						document.getElementById('map_loading').style.visibility='hidden';
				}
			};
			xmlHttp.send(null);
		}
	}
	catch(e){}
}


