function init(){
      parseXml("Kalender.xml")
      GetNextGame()
}

// Returns the next game based on the current date
function GetNextGame()
{
      _volgendeWedstrijd = document.getElementById("VW")
    
    // Find all games
      var allGames = oDomDoc.getElementsByTagName("Wedstrijd")

    var _gameType = "";
    var _gameDate = "";
    var _gameHome = "";
    var _gameVisitors = "";
    var _tijdstip = "";
    
    var numberOfGames = 0;
    
    //Al deze items overlopen en...
      for(i=0; i < allGames.length; i++)
    {
        // Get game info
            _gameDate = allGames.item(i).getElementsByTagName("Datum").item(0).firstChild.nodeValue
        _gameHour = allGames.item(i).getElementsByTagName("Uur").item(0).firstChild.nodeValue    
        _gameMinutes = allGames.item(i).getElementsByTagName("Min").item(0).firstChild.nodeValue    
        _gameType = allGames.item(i).getElementsByTagName("Type").item(0).firstChild.nodeValue
        _gameHome = allGames.item(i).getElementsByTagName("Thuisploeg").item(0).firstChild.nodeValue
        _gameVisitors = allGames.item(i).getElementsByTagName("Bezoekers").item(0).firstChild.nodeValue
        
        var now = new Date().addHours(1);
        //var gameDate = new Date(_gameDate);

        var _year = _gameDate.slice(6,10);
        var _month = _gameDate.slice(3,5);
        var _day = _gameDate.slice(0,2);
                
        var gameDate = new Date(_year,_month, _day);

        var myDate=new Date().setFullYear(_year,_month-1,_day);

        if(myDate <= Date.parse(now))
        {
            // Continue processing all games
        }
        else if(numberOfGames == 0)
        {
            // if 1 game found in the future, display the first one
            numberOfGames = 1;

            var _newLine0 = document.createElement("br")
            var _newLine1 = document.createElement("br")
            var _newLine2 = document.createElement("br")
            var _newLine3 = document.createElement("br")
            var _newLine4 = document.createElement("br")

            // Display previous values
            var nextGame = document.createElement("div");
            // Set an Id?

            var divHome = document.createTextNode(_gameHome);
            var divDottedLine = document.createTextNode("-");
            var divVisitors = document.createTextNode(_gameVisitors);
            var month = gameDate.getMonth() + 1;
            if(month < 10)
            {
                month = "0" + month;
            }
            //var dateAndTime = gameDate.getDate() + "/" + month + "/" + gameDate.getFullYear() + ' - ' + _gameHour + ':' + _gameMinutes;
            var dateAndTime = _day + "/" + _month + "/" + _year + ' - ' + _gameHour + ':' + _gameMinutes;
            var divTijdstip = document.createTextNode(dateAndTime);
            
            nextGame.appendChild(_newLine0);
            nextGame.appendChild(divHome);
            nextGame.appendChild(_newLine1);
            nextGame.appendChild(divDottedLine);
            nextGame.appendChild(_newLine2);
            nextGame.appendChild(divVisitors);
            nextGame.appendChild(_newLine3);
            nextGame.appendChild(_newLine4);
            nextGame.appendChild(divTijdstip);

            _volgendeWedstrijd.appendChild(nextGame);
        }
      }
}

Date.prototype.addHours = function(h)
{
    var copiedDate = new Date(this.getTime());    
    copiedDate.setHours(copiedDate.getHours()+h);    
    return copiedDate;
}

Date.prototype.addMinutes = function(h)
{
    var copiedDate = new Date(this.getTime());    
    copiedDate.setHours(copiedDate.getMinutes()+h);    
    return copiedDate;
}
-->

