    var currentPlace;
    var currentSort;
    var currentRound;
    var currentLeague;

    function getID(id) {

        return document.getElementById(id);
    }

    function parseRecords(xml) {
        d = getID("dataTable");
        for (i = d.rows.length-1; i >= 0; i--)
          d.deleteRow(i);
        record = xml.getElementsByTagName("record");
        result = "";
        for (i = 0; i < record.length; i++) {
            tr = document.createElement("tr");

            td = document.createElement("td");
            td.innerHTML = record[i].childNodes[0].childNodes[0].nodeValue;
            tr.appendChild(td);

            td = document.createElement("td");
            td.innerHTML = '<a href=\"klub,'+record[i].childNodes[2].childNodes[0].nodeValue+'.html\" class=\"pogrubienie\" title=\"'+record[i].childNodes[1].childNodes[0].nodeValue + '\">'+record[i].childNodes[1].childNodes[0].nodeValue + '</a>';
            tr.appendChild(td);

            td = document.createElement("td");
            td.innerHTML = record[i].childNodes[3].childNodes[0].nodeValue;
            tr.appendChild(td);

            td = document.createElement("td");
            td.innerHTML = record[i].childNodes[4].childNodes[0].nodeValue;
            tr.appendChild(td);

            td = document.createElement("td");
            td.innerHTML = record[i].childNodes[5].childNodes[0].nodeValue;
            tr.appendChild(td);

            td = document.createElement("td");
            td.innerHTML = record[i].childNodes[6].childNodes[0].nodeValue;
            tr.appendChild(td);

            td = document.createElement("td");
            td.innerHTML = record[i].childNodes[7].childNodes[0].nodeValue;
            tr.appendChild(td);

            td = document.createElement("td");
            td.innerHTML = record[i].childNodes[8].childNodes[0].nodeValue;
            tr.appendChild(td);

            td = document.createElement("td");
            td.innerHTML = record[i].childNodes[9].childNodes[0].nodeValue;
            tr.appendChild(td);

            td = document.createElement("td");
            td.innerHTML = record[i].childNodes[10].childNodes[0].nodeValue;
            tr.appendChild(td);

            td = document.createElement("td");
            td.innerHTML = record[i].childNodes[11].childNodes[0].nodeValue;
            tr.appendChild(td);

            td = document.createElement("td");
            td.innerHTML = record[i].childNodes[12].childNodes[0].nodeValue;
            tr.appendChild(td);

            td = document.createElement("td");
            td.innerHTML = record[i].childNodes[13].childNodes[0].nodeValue;
            tr.appendChild(td);

            td = document.createElement("td");
            td.innerHTML = record[i].childNodes[14].childNodes[0].nodeValue;
            tr.appendChild(td);

            tr.className = record[i].childNodes[15].childNodes[0].nodeValue;

            d.appendChild(tr);
        }
        return result;
    }

    function getRecords() {
        advAJAX.get({
            url : "xml_tabela.php?id="+currentLeague+"&place="+currentPlace+"&tb="+currentSort+"&round="+currentRound,
            onInitialization : function() {
            },
            onSuccess : function(obj) {

                parseRecords(obj.responseXML);
            }
        });
    }

    function changePlace(p) {
      	document.getElementById(p).className = "zakladkaminion";
      	if (p == "away")
      	{
      	   document.getElementById('razem').className = "zakladkaminioff";
      	   document.getElementById('home').className = "zakladkaminioff";
        } else if (p == "home") {
      	   document.getElementById('razem').className = "zakladkaminioff";
      	   document.getElementById('away').className = "zakladkaminioff";
        } else {
      	   document.getElementById('home').className = "zakladkaminioff";
      	   document.getElementById('away').className = "zakladkaminioff";
        }        
        currentPlace = p;
        getRecords();
    }
    function changeSort(p) {
        currentSort = p;
        getRecords();
    }

    function changeRound(p) {
        currentRound = p;
        getRecords();
    }

    function initDynamicTable(id,tb) {
        currentLeague = id;
        currentSort = tb;
        getRecords();
    }
    

