
//This is where everything is done
function onLoad(){

    var listeners = Listeners();
    TDEMO.TEXTURES.loadAll(listeners.texturesReady);
    
    //Setting up sync device
    var syncDevice = TDEMO.SYNC.initSyncDevice();
    syncDevice.on('ready', listeners.syncReady);
    
    //Setting up audio
    var audio = document.createElement('audio');
    audio.id = "audio";
    audio.setAttribute('src', 'bin/hermot_v1.ogg');
    audio.load();
    audio.addEventListener("canplaythrough", listeners.audioReady);
    document.body.appendChild(audio);
    
    //Setting up video resources
    var video = document.createElement('video');
    video.id = "koivut";
    video.style.display = "none";
    video.loop = true;
    video.muted = true;
    video.setAttribute('src', 'bin/videot/koivut.mp4');
    video.load();
    video.addEventListener("canplaythrough", listeners.koivutReady);
    document.body.appendChild(video);
    
    var video2 = document.createElement('video');
    video2.id = "maa";
    video2.style.display = "none";
    video2.loop = true;
    video2.muted = true;
    video2.setAttribute('src', 'bin/videot/maa.mp4');
    video2.load();
    video2.addEventListener("canplaythrough", listeners.maaReady);
    document.body.appendChild(video2);
    
    var video3 = document.createElement('video');
    video3.id = "havut";
    video3.style.display = "none";
    video3.loop = true;
    video3.muted = true;
    video3.setAttribute('src', 'bin/videot/havupuu.mp4');
    video3.load();
    video3.addEventListener("canplaythrough", listeners.havutReady);
    document.body.appendChild(video3);


    //Setting up start button
    var startbtn = document.createElement("button");
    var t = document.createTextNode("START");
    startbtn.appendChild(t);
    startbtn.addEventListener("click", listeners.userReady);
    document.getElementById("start").appendChild(startbtn);
    
};
