$(document).ready(function () {

$('.overlayLayer').click(function(e) {
  $('.overlayLayer').removeClass('active');
  var $this = $(this);
  if (!$this.hasClass('active')) {
    $this.addClass('active');
  }
  e.preventDefault();
});

$(".overlayLayer").click(function () {   
	//var inputs = dojo.query(".overlayLayer");
	var inputs = dojo.query(".overlayLayer");
	var visible = [-1]; //street and city labels
	for (var i = 0, il = inputs.length; i < il; i++) {
		var layerLabel = $(inputs[i]).text();  //To select labels to check, we must nest <label tag> in htm. and somehow select that nested label
		//console.log('layerLabel: ',layerLabel);
		var layerCheckState = $(inputs[i]);
		//console.log('layerCheckState: ',layerCheckState);
		var layerObject = objectFindByKey(globalMapLayers, 'name', layerLabel);
		console.log('layerObject: ',layerObject);
		if ($(layerCheckState).hasClass("active")) {
			visible.push(layerObject.id);			
			//console.log(layerObject.id);
		}
		else {
			$(layerCheckState).removeClass("active");
			overlayLayer.setVisibleLayers([-1])
			//var elem = $('li.current_sub').prevAll("checked:first");
			//elem.removeClass("checked");
		}
	}

	overlayLayer.setVisibleLayers(visible);
	//legend.refresh();
	//$('.scrollable').nanoScroller();

});

 function objectFindByKey(array, key, value) {
        //alert(value);
        for (var i = 0; i < array.length; i++) {
		    //alert(array[i].name);
            if (array[i][key] === value) {
                return array[i];
            }
        }
        return null;
    }	


	

});

@@ -383,33 +383,9 @@
 1%5D; 
-//street and city labels
 %0A
+
 %09for
@@ -477,106 +477,8 @@
 );  
-//To select labels to check, we must nest %3Clabel tag%3E in htm. and somehow select that nested label
 %0A%09%09/
@@ -946,112 +946,15 @@
 1%5D)%0A
-%09%09%09//var elem = $('li.current_sub').prevAll(%22checked:first%22);%0A%09%09%09//elem.removeClass(%22checked%22);%0A
 %09%09%7D%0A%09%7D%0A
-%0A
 %09ove
@@ -994,66 +994,8 @@
 e);%0A
-%09//legend.refresh();%0A%09//$('.scrollable').nanoScroller();%0A%0A
 %7D);%0A
@@ -1046,32 +1046,8 @@
 ) %7B%0A
-        //alert(value);%0A
     
@@ -1095,38 +1095,8 @@
 ) %7B%0A
-%09%09    //alert(array%5Bi%5D.name);%0A
     
@@ -1216,20 +1216,15 @@
 ll;%0A
+
     %7D%09%0A
-%0A%0A%09%0A%0A
 %7D);%0A

Clean app.js