var showSettings = false;

function toggleSettings() {
	// Shows and hides settings.
	
    console.log("toggle settings");
    if (showSettings) {
        document.getElementsByClassName("start-settings-checkboxes")[0].style.display = "none";
        document.getElementsByClassName("start-settings-show-hide")[0].innerHTML = "show";
        showSettings = false;
    } else {
        document.getElementsByClassName("start-settings-checkboxes")[0].style.display = "inline";
        document.getElementsByClassName("start-settings-show-hide")[0].innerHTML = "hide";
        showSettings = true;
    }
}

function followLink(destination) {
	// Build query string and load new page.
	
    var checkboxes = document.getElementsByClassName("start-checkbox");
    var query = "";
    // Loop through settings-checkboxes.
    for (var i = 0; i < checkboxes.length; i++) {
      if (checkboxes[i].checked != checkboxes[i].defaultChecked) {
        if (query === "") {
            query = "?";
        } else {
            query += "&";
        }
        query += checkboxes[i].name + "=";
        if (checkboxes[i].checked) {
            query += "1";
        } else {
            query += "0";
        }
      }
    }
    destination += query;
    console.log(destination);
    window.location = destination;
}