var btnSave;
var btnHand;
var btnPolygon;
var btnEdit;
var btnZoomIn;
var btnZoomOut;
var btnBrightnessHigh;
var btnBrightnessLow;


function initNavMenu() {
    getElements();
    setElementsOnClick();
    initBrightness();
}

function setElementsOnClick() {
    setOnClick(btnSave);
    setOnClick(btnHand);
    setOnClick(btnPolygon);
    setOnClick(btnEdit);
    setOnClick(btnZoomIn);
    setOnClick(btnZoomOut);
    setOnClick(btnBrightnessHigh);
    setOnClick(btnBrightnessLow);
}

function getElements() {
    btnSave = document.getElementsByClassName('btnsave')[0];
    btnHand = document.getElementsByClassName('btn-hand')[0];
    btnPolygon = document.getElementsByClassName('btn-polygon')[0];
    btnEdit = document.getElementsByClassName('btn-edit')[0];
    btnZoomIn = document.getElementsByClassName('btn-zoom-in')[0];
    btnZoomOut = document.getElementsByClassName('btn-zoom-out')[0];
    btnBrightnessHigh = document.getElementsByClassName('btn-brightness-high')[0];
    btnBrightnessLow = document.getElementsByClassName('btn-brightness-low')[0];
}

function clearOnClick(element) {
    element.onclick = '';
}

function btnSaveFunc(btnIsSelected) {
    /*global onSave*/
    /*eslint no-undef: "error"*/
    onSave();
}

function btnHandFunc(btnIsSelected) {
    alert("Implement hand tool");
}

function btnPolygonFunc(btnIsSelected) {
    if (btnIsSelected) {
        svgImg.onclick = function () {
            svgImgOnClick(event);
        };
    } else {
        clearOnClick(svgImg.onclick);
    }
}

function btnEditFunc(btnIsSelected) {

}

function btnZoomInFunc(btnIsSelected) {

}

function btnZoomOutFunc(btnIsSelected) {

}

function btnBrightnessHighFunc(btnIsSelected) {
    plusBrightness();
}

function btnBrightnessLowFunc(btnIsSelected) {
    minusBrightness();
}

function setOnClick(btn) {
    btn.onclick = function () {
        var btnIsSelected = false;
        if (isButtonSelected(btn)) {
            btnIsSelected = true;
        }

        switch (btn.id) {
            case 'btn_save':
                btnSaveFunc(btnIsSelected);
                break;
            case 'btn_hand':
                btnHandFunc(btnIsSelected);
                break;
            case 'btn_polygon':
                btnPolygonFunc(btnIsSelected);
                break;
            case 'btn_edit':
                btnEditFunc(btnIsSelected);
                break;
            case 'btn_zoom_in':
                btnZoomInFunc(btnIsSelected);
                break;
            case 'btn_zoom_out':
                btnZoomOutFunc(btnIsSelected);
                break;
            case 'btn_brightness_high':
                btnBrightnessHighFunc(btnIsSelected);
                break;
            case 'btn_brightness_low':
                btnBrightnessLowFunc(btnIsSelected);
                break;
        }
    }
}

function isButtonSelected(btn) {
    if (btn.style.background === 'rgb(27, 109, 133)') {
        btn.style.background = '#ffffff';
        return false;
    } else {
        btn.style.background = '#1b6d85';
        return true;
    }
}
@@ -210,32 +210,125 @@
 itBrightness();%0A
+    setIsButtonSelected(btnPolygon, isButtonSelected(btnPolygon));%0A    btnPolygonFunc(true);%0A
 %7D%0A%0Afunction setE
@@ -1501,32 +1501,87 @@
 = function () %7B%0A
+            if (!isButtonSelected(btnPolygon)) return;%0A
             svgI
@@ -2052,16 +2052,41 @@
     if (
+setIsButtonSelected(btn, 
 isButton
@@ -2099,16 +2099,17 @@
 ed(btn))
+)
  %7B%0A     
@@ -3120,74 +3120,130 @@
     
-btn.style.background = '#ffffff';%0A        return false;%0A    %7D else
+return true;%0A    %7D else %7B%0A        return false;%0A    %7D%0A%7D%0A%0Afunction setIsButtonSelected(btn, isEnabled) %7B%0A    if (isEnabled)
  %7B%0A 
@@ -3278,36 +3278,70 @@
 = '#
-1b6d85
+ffffff
 ';%0A    
-    return true
+%7D else %7B%0A        btn.style.background = '#1b6d85'
 ;%0A  

Make the polygon button to be initially activated.