// JavaScript Document
var AntzTest = {
    init : function(config){
        config.init;
        this.config = config;
        this.numAns = 0;
        this.numWrong = 0;
        this.numRight = 0;
        var img = document.createElement('img');
        img.src=AntzBaseUrl+'/images/site/tutorials/cross.gif';
        this.cross = img;
        var img = document.createElement('img');
        img.src=AntzBaseUrl+'/images/site/tutorials/tick.gif';
        this.tick = img;
    },
    
    select : function(q, a){
        var ans = this.config.answers[q];
        var ansBox = document.getElementById('ans'+q);
        if(ans == a){
            this.numRight++;
            ansBox.innerHTML = this.config.comments[q][a]; 
            ansBox.className = 'rightAnswer';
        }else{
            this.numWrong++;
            ansBox.innerHTML = this.config.comments[q][a]; 
            ansBox.className = 'wrongAnswer';
        };
        this.writeScore();
    },
    
    writeScore : function(){
        var scoreBox = document.getElementById('score');
        perc = (100/this.config.numQs)*this.numRight;
        scoreBox.innerHTML = 'Score: '+Math.round(perc)+' %';  
    }
}
