//made by Vytautas Ziukas 
    function Init(mode)
    {
        var numb1 = rand(10);
        var numb2 = rand(10);

        var numb3 = 0;
        var numb4 = 0;      
        var numb5 = 0;
        
        switch(mode)
        {
            case 'sum':
                var numb3 = numb1 + rand(10);
                var numb4 = numb2 + rand(10);        
                var numb5 = numb2 + rand(10);        
                answer = numb1 + numb2;
                break;
            case 'sub':
                sub1 = numb1 + numb2;
                var numb3 = numb2 + rand(10) - numb2;
                var numb4 = numb1 + rand(10) - numb1;        
                var numb5 = numb2 + rand(10) - numb2;   
                numb1 = sub1;     
                answer = numb1 - numb2;
                break;
            case 'mul':
                var numb3 = numb1 * rand(10);
                var numb4 = numb2 * rand(10);        
                var numb5 = numb2 * rand(10);        
                answer = numb1 * numb2;
                break;
            case 'div':
                if (numb1 == 0)
                    numb1 = 1;
                if (numb2 == 0)
                    numb2 = 1;


                div1 = numb1 * numb2;
                var numb3 = Math.round((rand(10) * rand(10) +1) / (rand(10)+1));
                var numb4 = Math.round((rand(10) * rand(10) +1) / (rand(10)+1));        
                var numb5 = Math.round((rand(10) * rand(10) +1) / (rand(10)+1));        
                numb1 = div1;
                answer = numb1 / numb2;
                break;
        }
        
        var sum1 = document.getElementById("sum1");
        var sum2 = document.getElementById("sum2");
        var sum3 = document.getElementById("sum3");

        var place = rand(3);
        sum1.innerHTML = place == 0 ? answer : numb3;
        sum2.innerHTML = place == 1 ? answer : numb4;
        sum3.innerHTML = place == 2 ? answer : numb5;

        var nr1 = document.getElementById("Nr1");
        nr1.innerHTML = numb1;
        
        var nr2 = document.getElementById("Nr2");
        nr2.innerHTML = numb2;

        div1 = document.getElementById("rt_col");
        div1.style.display = "none";            
        div1 = document.getElementById("rt_col2");
        div1.style.display = "none";
    }
    
    function selected( name )
    {
        msg = document.getElementById("message");
        div1 = document.getElementById("rt_col");
        div2 = document.getElementById("rt_col2");

        selAnsw = document.getElementById(name).innerHTML;
        if (selAnsw == answer)
        {
            div1.style.display = "";  
            div2.style.display = "none";           
        }
        else
        {
            div1.style.display = "none"; 
            div2.style.display = "";            
        }
    }
    
    function rand ( n )
    {
      return ( Math.floor ( Math.random ( ) * n ) );
    }
