//Variables
var draw_precision_variables = function() {
    getFullPanel(0, 0, 4, 9, "tab-page-precision_planting", "sec-precision_planting", "PRECISION", "CONTROL", "VER 1.0");
    var panel = document.getElementById("sec-precision_planting");
    panel.innerHTML += draw_precision_variables_1();
    panel.innerHTML += draw_precision_variables_2();
    panel.innerHTML += draw_precision_variables_3();
    panel.innerHTML += draw_precision_variables_4();
    panel.innerHTML += draw_precision_variables_5();
    panel.innerHTML += draw_precision_variables_6();
}

var draw_precision_variables_1 = function() {
    var html = getSectionTitle('GPS INPUT');
    var rows = '';
    var row = '';
    row = getInfoCell('', 'INT RECEIVE');
    row += getInfoCell('gps-control-int-receive', '1');
    row += getInfoCell('', 'EXT RECEIVE');
    row += getInfoCell('gps-control-ext-receive', '2');
    rows += getInfoRow(row);
    row = getInfoCell('', 'X');
    row += getInfoCell('gps-control-x', '1245d963');
    row += getInfoCell('', 'Y');
    row += getInfoCell('gps-control-y', '1245d963');
    rows += getInfoRow(row);
    row = getInfoCell('', 'ACC COUNT');
    row += getInfoCell('gps-control-acc-count', '1');
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_precision_variables_2 = function() {
    var html = getSectionTitle('CURRENT BLOCK');
    var rows = '';
    var row = '';
    row = getInfoCell('', 'LAND');
    row += getInfoCell('prec-plant-land', '1');
    row += getInfoCell('', 'FLOW');
    row += getInfoCell('prec-plant-flow', '250');
    rows += getInfoRow(row);
    row = getInfoCell('', 'X0');
    row += getInfoCell('prec-plant-x0', '1245d963');
    row += getInfoCell('', 'X1');
    row += getInfoCell('prec-plant-x1', '1245d963');
    rows += getInfoRow(row);
    row = getInfoCell('', 'Y0');
    row += getInfoCell('prec-plant-y0', '1245d963');
    row += getInfoCell('', 'Y1');
    row += getInfoCell('prec-plant-y1', '1245d963');
    rows += getInfoRow(row);
    row = getInfoCell('', 'BLOCKS');
    row += getInfoCell('prec-plant-blocks', '200');
    row += getInfoCell('', 'INDEX');
    row += getInfoCell('prec-plant-index', '120');
    rows += getInfoRow(row);
    row = getInfoCell('', 'INBOUNDS');
    row += getInfoCell('prec-plant-inbounds', 'NO');
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_precision_variables_3 = function() {
    var html = getSectionTitle('PRECISION SEARCH');
    var rows = '';
    var row = '';
    row = getInfoCell('', 'IDX');
    row += getInfoCell('', 'X0');
    row += getInfoCell('', 'X1');
    row += getInfoCell('', 'Y0');
    row += getInfoCell('', 'Y1');
    rows += getInfoRow(row);
    for (var i = 0; i < 12; i++) {
        row = getInfoCell('prec-search-idx-' + (i + 1), (i + 1));
        row += getInfoCell('prec-search-x0-' + (i + 1), '1245d963');
        row += getInfoCell('prec-search-x1-' + (i + 1), '1245d963');
        row += getInfoCell('prec-search-y0-' + (i + 1), '1245d963');
        row += getInfoCell('prec-search-y1-' + (i + 1), '1245d963');
        rows += getInfoRow(row);
    }

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_precision_variables_4 = function() {
    var html = getSectionTitle('SIMULATION OUTPUT');
    var rows = '';
    var row = '';
    row = getInfoCell('', 'OUT X');
    row += getInfoCell('', '1');
    row += getInfoCell('', 'OUT Y');
    row += getInfoCell('', '2');
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_precision_variables_5 = function() {
    var html = getSectionTitle('SIMULATION CONTROL');
    var rows = '';
    var row = '';
    row += '<td><div class="ai-cell ai-cell-warning" id="prec-sel-off" onclick="PrecisionMode(\'off\');">OFF</div></td>';
    row += '<td><div class="ai-cell ai-cell-secondary-1" id="prec-sel-row" onclick="PrecisionMode(\'row\');">ROW PLANTING</div></td>';
    row += '<td><div class="ai-cell ai-cell-secondary-1" id="prec-sel-big-rad" onclick="PrecisionMode(\'big-rad\');">BIG RADIUS</div></td>';
    row += '<td><div class="ai-cell ai-cell-secondary-1" id="prec-sel-small-rad" onclick="PrecisionMode(\'small-rad\');">SMALL RADIUS</div></td>';
    rows += getInfoRow(row);
    html += getTabel(rows);
    
    rows = '';
    row = '';
    row += '<td><div class="ai-cell ai-cell-warning" id="prec-sel-exact" onclick="PrecisionSpeed(\'exact\');">EXACT SPEED</div></td>';
    row += '<td><div class="ai-cell ai-cell-secondary-1" id="prec-sel-variable" onclick="PrecisionSpeed(\'variable\');">VARIABLE SPEED</div></td>';
    rows += getInfoRow(row);
    html += getTabel(rows);
    
    rows = '';
    row = '';
    row += '<td><div class="ai-cell ai-cell-warning" id="prec-out-off" onclick="PrecisionOutput(\'off\');">OFF</div></td>';
    row += '<td><div class="ai-cell ai-cell-secondary-1" id="prec-out-output" onclick="PrecisionOutput(\'output\');">EXPORT DATA</div></td>';
    rows += getInfoRow(row);
    html += getTabel(rows);

    html = getPanel(html);
    return html;
}

var draw_precision_variables_6 = function() {
    var html = getSectionTitle('LOGS');
    html += '<textarea id="prec-logs" class="form-control" style="width:100%; height:100px"></textarea>';

    html = getPanel(html);
    return html;
}

draw_precision_variables();

var PrecisionMode = function(mode)
{
    if (mode == "off") {
        document.getElementById("prec-sel-off").className = "ai-cell ai-cell-warning";
    } else {
        document.getElementById("prec-sel-off").className = "ai-cell ai-cell-secondary-1";
    }
    if (mode == "row") {
        document.getElementById("prec-sel-row").className = "ai-cell ai-cell-warning";
    } else {
        document.getElementById("prec-sel-row").className = "ai-cell ai-cell-secondary-1";
    }
    if (mode == "big-rad") {
        document.getElementById("prec-sel-big-rad").className = "ai-cell ai-cell-warning";
    } else {
        document.getElementById("prec-sel-big-rad").className = "ai-cell ai-cell-secondary-1";
    }
    if (mode == "small-rad") {
        document.getElementById("prec-sel-small-rad").className = "ai-cell ai-cell-warning";
    } else {
        document.getElementById("prec-sel-small-rad").className = "ai-cell ai-cell-secondary-1";
    }
}
var PrecisionSpeed = function(mode)
{
    if (mode == "exact") {
        document.getElementById("prec-sel-exact").className = "ai-cell ai-cell-warning";
    } else {
        document.getElementById("prec-sel-exact").className = "ai-cell ai-cell-secondary-1";
    }
    if (mode == "variable") {
        document.getElementById("prec-sel-variable").className = "ai-cell ai-cell-warning";
    } else {
        document.getElementById("prec-sel-variable").className = "ai-cell ai-cell-secondary-1";
    }
}
var PrecisionOutput = function(mode)
{
    if (mode == "off") {
        document.getElementById("prec-out-off").className = "ai-cell ai-cell-warning";
        document.getElementById("prec-out-output").className = "ai-cell ai-cell-secondary-1";
    } else {
        document.getElementById("prec-out-output").className = "ai-cell ai-cell-warning";
        document.getElementById("prec-out-off").className = "ai-cell ai-cell-secondary-1";
    }
}

//Variables
var draw_precision_map = function() {
    getFullPanel(4, 0, 5, 9, "tab-page-precision_planting", "sec-precision_map", "PRECISION", "MAP", "VER 1.0");
    var panel = document.getElementById("sec-precision_map");
    panel.innerHTML += draw_precision_map_1();
}

var draw_precision_map_1 = function() {
    var html = getSectionTitle('POTCH FARM R210');
    html += '<div class="ai-map-block" id="map-img-block">';
    html += '<img class= "ai-img-map" src="./img/satelite.jpg">';
    html += '</div>';
    html += '<svg class="ai-map-svg" id="map-grid-svg"></svg>';
    html = getPanel(html);
    return html;
}

draw_precision_map();