// Script by Jakub "rEs0LuTe" Sedláček

var xmlHttp;
var srvr_status = 0;

function vytvorXMLHttp() {
	if(window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Mircrosoft.XMLHTTP");
	} else if(window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest;	
	}
}


function zobrazServre() {
	vytvorXMLHttp();
	
	xmlHttp.onreadystatechange = zobrazServre_zmena;
	xmlHttp.open("GET","servers_news.php",true);
	xmlHttp.send(null);

}

function zobrazServre_zmena() {
	if(xmlHttp.readyState == 4) {
		if(xmlHttp.status == 200) {
			document.getElementById("servre_detail").innerHTML = xmlHttp.responseText;
		}
	} else {
		zobrazLoad();	
	}
}

function zobrazLoad() {
		document.getElementById("servre_detail").innerHTML = "<table><tr><td><img src='/images/loader.gif' alt='Loading'></td><td>Loading...</td></tr></table>";
}

function load_top5() {
	vytvorXMLHttp();
	xmlHttp.onreadystatechange = load_top5_zmena;
	xmlHttp.open("GET","/doplnky/top5.php",true);
	xmlHttp.send(null);
}

function load_top5_zmena() {
	if(xmlHttp.readyState==4) {
		if(xmlHttp.status==200) {
			document.getElementById("top5_right").innerHTML = xmlHttp.responseText;
		}
	} else {
		document.getElementById("top5_right").innerHTML = "<table><tr><td><img src='/images/loader.gif' alt='Loading'></td></tr><tr><td>Loading...</td></tr></table>";	
	}
}

function ukazbody(user_id) {
	vytvorXMLHttp();
	xmlHttp.onreadystatechange = ukazbody_zmena;
	xmlHttp.open("GET","/doplnky/ukazbody.php?user_id=" + user_id, true);
	xmlHttp.send(null);
}

function ukazbody_zmena() {
	if(xmlHttp.readyState==4) {
		if(xmlHttp.status==200) {
			document.getElementById("ukazbody_box").innerHTML = xmlHttp.responseText;
		}
	} else {
		document.getElementById("ukazbody_box").innerHTML = "<table><tr><td><img src='/images/loader.gif' alt='Loading'></td></tr><tr><td>Loading...</td></tr></table>";	
	}	
}

function refreshhracov(nick) {
	if(nick.length > 0) {
		vytvorXMLHttp();
		xmlHttp.onreadystatechange = refreshracov_zmena;
		xmlHttp.open("GET","/doplnky/hraci.php?hrac=" + escape(nick),true);
		xmlHttp.send(null);
	} else {
		zrusrefreshracov();
	}
}
function zrusrefreshracov() {
	document.getElementById("zobraznicky").style.padding = "0px";
	document.getElementById("zobraznicky").style.border = "none";
	document.getElementById("zobraznicky").innerHTML = '';	
}
function refreshracov_zmena() {
	if(xmlHttp.readyState==4) {
		if(xmlHttp.status==200) {
			document.getElementById("zobraznicky").style.padding = "3px";
			document.getElementById("zobraznicky").style.border = "1px #000000 solid";
			document.getElementById("zobraznicky").innerHTML = xmlHttp.responseText;
		}
	} else {
		document.getElementById("zobraznicky").innerHTML = "<table><tr><td><img src='/images/loader.gif' alt='Loading'></td></tr><tr><td>Loading...</td></tr></table>";	
	}	
}
function insertNick(nick) {
	document.getElementById("uzivate").value = nick;
	zrusrefreshracov();
}