var topka;
topka=1;

function ukaz_top(i){
    $$("itop"+topka).className="off";
    $$("itop"+i).className="on";
    $$("itop"+topka+"k").className="no_topky";
    $$("itop"+i+"k").className="sel_topky";
    topka=i;
}

function rotuj(){
    nova=topka+1;
    if(nova>5)nova=1;
    ukaz_top(nova);
    topka=nova;
    myTimer = setTimeout("rotuj()",20000);
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}

function den_minus(){
    i_glob=i_glob-1;
    Date_matches.setDate(Date_matches.getDate()-1);
    den=Date_matches.getDate();
    mes=Date_matches.getMonth()+1;
    if(den < 10){den = "0" + den;}
    if(mes < 10){mes = "0" + mes;}
    $$("date_matches").innerHTML=den+"."+mes+"."+Date_matches.getFullYear();
    load_matches(i_glob);
}

function den_plus(){
    i_glob=i_glob+1;
    Date_matches.setDate(Date_matches.getDate()+1);
    den=Date_matches.getDate();
    mes=Date_matches.getMonth()+1;
    if(den < 10){den = "0" + den;}
    if(mes < 10){mes = "0" + mes;}
    $$("date_matches").innerHTML=den+"."+mes+"."+Date_matches.getFullYear();
    load_matches(i_glob);
}

function load_matches(i){
    var tms = new Date().getTime();
    $$("matches").innerHTML = "<img src='Images/loading.gif'>";
    var xhr = createXMLHttpRequest( );
    xhr.onreadystatechange = function( ) {
        if (xhr.readyState==4) {
            if (xhr.status==200) {
                $$("matches").innerHTML = xhr.responseText;
            } else alert("Message returned, but with error status.");
        }
    }
    xhr.open("GET", "Includes/futbal/feed_match.php?i="+i+"&time="+tms, true);
    xhr.send(null);
}

function load_stats_all(co, sezona){
    var tms = new Date().getTime();
    //alert(co+"_out");
    $$(co+"_out").innerHTML = "<img src='Images/loading.gif'>";
    var xhr = createXMLHttpRequest( );
    xhr.onreadystatechange = function( ) {
        if (xhr.readyState==4) {
            if (xhr.status==200) {
                $$(co+"_out").innerHTML = xhr.responseText;
            } // else alert("Message returned, but with error status.");
        }
    }
    xhr.open("GET", "Includes/futbal/feed_stat_all.php?co="+co+"&sezona="+sezona+"&time="+tms, true);
    xhr.send(null);
}

function hrac(id_hrac, sezona, e){
	var poz = findPos(e);
	var tms = new Date().getTime();

	$$("vypln").className = "list1";
	$$("vypln").style.left = (poz[0] - 50) + "px";
	$$("vypln").style.top = (poz[1] + 16) + "px";	
	$$("vypln").innerHTML = "<img src='Images/loading.gif'>";
	
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {
		if (xhr.readyState==4) {
			if (xhr.status==200) {
				$$("vypln").innerHTML = xhr.responseText;
				//vyska=$$("vypln").style.height;
				//$$("vypln").style.height = vyska + "px";
			} else alert("Message returned, but with error status.");
		}
	}
	xhr.open("GET", "Includes/futbal/feed_hrac.php?id_hrac="+id_hrac+"&time="+tms, true);
	xhr.send(null);
//	$("vypln").innerHTML = "Kliknute na " + id_zap + "Poz x: " + poz[0] + "Poz y: " + poz[1];
}

function stats(id_klub, sezona, ako, e){
	var poz = findPos(e);

	$$("stat_obsah").innerHTML = "<img src='Images/loading.gif'>";
	
	var xhr = createXMLHttpRequest( );
	xhr.onreadystatechange = function( ) {
		if (xhr.readyState==4) {
			if (xhr.status==200) {
				$$("stat_obsah").innerHTML = xhr.responseText;
			} else alert("Message returned, but with error status.");
		}
	}
	xhr.open("GET", "Includes/futbal/feed_stat.php?id="+id_klub+"&sezona="+sezona+"&ako="+ako, true);
	xhr.send(null);
//	$("vypln").innerHTML = "Kliknute na " + id_zap + "Poz x: " + poz[0] + "Poz y: " + poz[1];
}