var numberOfLines = 10;
var gridInterval;

function grid(){
    var l1 = new Array(numberOfLines);
    var l2 = new Array(numberOfLines);
    for(var i = 0; i < numberOfLines; i++){
        l1[i] = new Array(new Array(i*50-250, 0, 475), new Array(i*50-250, 0, 925));
        l2[i] = new Array(new Array(-250, 0, i*50+475), new Array(200, 0, i*50+475));
    }
    for(var i = 0; i < numberOfLines; i++){
        createNewLine(l1[i], "white", "kaikki");
        createNewLine(l2[i], "white", "kaikki");
    }
    gridInterval = setInterval(rotateGrid, 70, l1, l2);
}

var gridAngle = 0;
//var kaikki = document.getElementById("kaikki");  
var temp1 = new Array(numberOfLines);
var temp2 = new Array(numberOfLines);
var ax1 = new Array(0, 20, 600);
var ax2 = new Array(20, 0, 600);
var angle;

function rotateGrid(l1, l2){
    gridAngle++;
    var kaikki = document.getElementById("kaikki");
    if(gridAngle > 200) gridAngle = 1;
    for(var i = 0; i < l1.length; i++){
        temp1[i] = clonePath(l1[i]);
        temp2[i] = clonePath(l2[i]);
    }
    for(var i = 0; i < l1.length; i++){
        angle = gridAngle*Math.PI/100;
        rotatePathArbit(temp1[i], ax1, ax2, angle);
        drawSimpleLine(kaikki.getElementsByTagName("path")[i], temp1[i]);
        rotatePathArbit(temp2[i], ax1, ax2, angle);
        drawSimpleLine(kaikki.getElementsByTagName("path")[10+i], temp2[i]);
    }
}

function stopGrid(){
    clearInterval(gridInterval);
}

