// Following structures support the grouping of Layers.  This should be located
// in the ArcIMSparams.js, but becuase the header loads earlier, it is all located 
// in the script that supports only the group layering.

//group layers (for one set only) list the layers to group together, each being
//a list in the array. groupName is the name to give the group the TOC.

// A reworking of the standard grouplayers implementation to support multiple
// groups of layers (as opposed to a single group).  Simple an array of arrays.
// A little more difficult to work with, but gives greater flexibility.  CAT.
// Structure - there is a top level array, groupManager that has as many entries
//    as there are groups.
//    Then there is a groupLayerInfo array for each of the Groups, including the name, whether it is visible, and what its layers are
//    Finally there is a groupLayers array for each of the layers in a Group.

  // The first 'group' in the array is simply 'default' which lists all the standard layers
  // as outlined in the site AXL file.
  
  var groupManager = new Array(5);    // let's give the system a clue and dimension an array with an exact number of layers.
  var activeGroup = "";

  // The default group - has no real information in it.
  var groupVisible = true;
  var groupName = "Select...";
  var groupLayers = new Array();
  var groupLayerInfo = new Array();
  groupLayers[0] = "Roads";
  groupLayers[1] = "Townline";
  groupLayers[2] = "Water Bodies";
  groupLayers[3] = "Road Centerline";
  groupLayers[4] = "Trails";
  groupLayers[5] = "Rivers and Streams";    
  groupLayers[6] = "Selected Parcel";
  groupLayerInfo[0] = groupVisible;
  groupLayerInfo[1] = groupName;
  groupLayerInfo[2] = groupLayers;
  groupManager[0] = groupLayerInfo;

  // Now set up each of the 3 group arrays
  //   Group 1 - ???  
  groupVisible = false;
  groupName = "Parcel Mapping";
  groupLayers = new Array();
  groupLayerInfo = new Array();
  groupLayers[0] = "Neighboring Towns";
  groupLayers[1] = "Major Water Bodies";
  groupLayers[2] = "Townline";
  groupLayers[3] = "Parcels - Clear";
  groupLayers[4] = "Parcel IDs";
  groupLayers[5] = "Buildings";
  groupLayers[6] = "Road Names";  
  groupLayers[7] = "Roads";
  groupLayers[8] = "Parcels";
  groupLayers[9] = "Water Bodies";
  groupLayers[10] = "Rivers and Streams";
  groupLayers[11] = "Property Dimensions";
  groupLayers[12] = "Road Centerline";
  groupLayers[13] = "Parcel IDs";
  groupLayers[14] = "Selected Parcel";
  groupLayers[15] = "Ocean";
  groupLayerInfo[0] = groupVisible;
  groupLayerInfo[1] = groupName;
  groupLayerInfo[2] = groupLayers;
  groupManager[1] = groupLayerInfo;
  

  groupVisible = false;
  groupName = "Base Mapping";
  groupLayers = new Array();
  groupLayerInfo = new Array();
  groupLayers[0] = "Townline";
  groupLayers[1] = "Parcels - Clear";
  groupLayers[2] = "Driveways";
  groupLayers[3] = "Buildings";
  groupLayers[4] = "Road Names";  
  groupLayers[5] = "Railroads";
  groupLayers[6] = "Parcels";
  groupLayers[7] = "Driveways";
  groupLayers[8] = "Water Bodies";
  groupLayers[9] = "Roads";
  groupLayers[10] = "Rivers and Streams";
  groupLayers[11] = "Vegetation";
  groupLayers[12] = "Parcels";
  groupLayers[13] = "Road Centerline";
  groupLayers[14] = "Selected Parcel";
  groupLayers[15] = "Ocean";
  groupLayers[16] = "Neighboring Towns";
  groupLayers[17] = "Major Water Bodies";
  groupLayerInfo[0] = groupVisible;
  groupLayerInfo[1] = groupName;
  groupLayerInfo[2] = groupLayers;
  groupManager[2] = groupLayerInfo;
  
  //   Group 2 - Street Map - All street information
  // nb - after the first group, do not use VAR to declare variables, they are only declared once.
 groupVisible = true;
 groupName = "Shoreland Zoning";
 groupLayers = new Array();
 groupLayerInfo = new Array();
 groupLayers[0] = "Townline";
 groupLayers[1] = "Parcels - Clear";
 groupLayers[2] = "Areas with Known Archeological Sites";
 groupLayers[3] = "Steep Slopes in Shoreland";
 groupLayers[4] = "Unstable Coastal Bluffs";
 groupLayers[5] = "Shoreland Zoning";
 groupLayers[6] = "Buildings";
 groupLayers[7] = "Road Names";  
 groupLayers[8] = "Railroads";
 groupLayers[9] = "Rivers and Streams";
 groupLayers[10] = "Water Bodies";
 groupLayers[11] = "Water Bodies";
 groupLayers[12] = "Roads";
 groupLayers[13] = "Road Centerline";
 groupLayers[14] = "Parcels";
 groupLayers[15] = "Selected Parcel";
 groupLayers[16] = "Ocean";
 groupLayers[17] = "Neighboring Towns";
 groupLayers[18] = "Major Water Bodies";
 groupLayerInfo[0] = groupVisible;
 groupLayerInfo[1] = groupName;
 groupLayerInfo[2] = groupLayers;
 groupManager[3] = groupLayerInfo;
  
  //   Group 3 - Street Map - All street information
  // nb - after the first group, do not use VAR to declare variables, they are only declared once.
groupVisible = true;
groupName = "Base Zone Mapping";
groupLayers = new Array();
groupLayerInfo = new Array();
groupLayers[0] = "Buildings";
groupLayers[1] = "Road Names";
groupLayers[2] = "Parcels - Clear";
groupLayers[3] = "Zoning";
groupLayers[4] = "Roads";
groupLayers[5] = "Townline";
groupLayers[6] = "Road Centerline";
groupLayers[7] = "Water Bodies";
groupLayers[8] = "Parcels";
groupLayers[9] = "Selected Parcel";
groupLayers[10] = "Ocean";
groupLayers[11] = "Neighboring Towns";
groupLayers[12] = "Major Water Bodies";
groupLayerInfo[0] = groupVisible;
groupLayerInfo[1] = groupName;
groupLayerInfo[2] = groupLayers;
groupManager[4] = groupLayerInfo;
  
  
  
    //   Group 4 - Street Map - All street information
  // nb - after the first group, do not use VAR to declare variables, they are only declared once.
  groupVisible = true;
  groupName = "Watershed Protection Zoning";
  groupLayers = new Array();
  groupLayerInfo = new Array();
  groupLayers[0] = "Buildings";
  groupLayers[1] = "Road Names";
  groupLayers[2] = "Parcels - Clear";
  groupLayers[3] = "Watershed Protection Zone";
  groupLayers[4] = "Roads";
  groupLayers[5] = "Townline";
  groupLayers[6] = "Road Centerline";
  groupLayers[7] = "Water Bodies";
  groupLayers[8] = "Parcels";
  groupLayers[9] = "Selected Parcel";
  groupLayers[10] = "Ocean";
  groupLayers[11] = "Neighboring Towns";
  groupLayers[12] = "Major Water Bodies";
  groupLayerInfo[0] = groupVisible;
  groupLayerInfo[1] = groupName;
  groupLayerInfo[2] = groupLayers;
  groupManager[5] = groupLayerInfo;
  
      //   Group 5 - Historic Landmarks and Districts
  // nb - after the first group, do not use VAR to declare variables, they are only declared once.
  groupVisible = true;
  groupName = "Local Historic Districts";
  groupLayers = new Array();
  groupLayerInfo = new Array();
  groupLayers[0] = "Parcels - Clear";
  groupLayers[1] = "Historic Landmarks";
  groupLayers[2] = "Local Historic Districts";
  groupLayers[3] = "Buildings";
  groupLayers[4] = "Road Names";  
  groupLayers[5] = "Rivers and Streams";
  groupLayers[6] = "Water Bodies";
  groupLayers[7] = "Road Centerline";
  groupLayers[8] = "Parcels";
  groupLayers[9] = "Selected Parcel";
  groupLayers[10] = "Ocean";
  groupLayers[11] = "Neighboring Towns";
  groupLayers[12] = "Major Water Bodies";                       
  groupLayerInfo[0] = groupVisible;
  groupLayerInfo[1] = groupName;
  groupLayerInfo[2] = groupLayers;
  groupManager[6] = groupLayerInfo;
                              
                              
                              
      //   Group 6 - Street Map - All street information
  // nb - after the first group, do not use VAR to declare variables, they are only declared once.
  groupVisible = true;
  groupName = "Elderly Congregate Zoning";
  groupLayers = new Array();
  groupLayerInfo = new Array();
  groupLayers[0] = "Elderly Congregate Zone";
  groupLayers[1] = "Road Names";
  groupLayers[2] = "Parcels - Clear";
  groupLayers[3] = "Buildings";
  groupLayers[4] = "Roads";
  groupLayers[5] = "Townline";
  groupLayers[6] = "Road Centerline";
  groupLayers[7] = "Water Bodies";
  groupLayers[8] = "Parcels";
  groupLayers[9] = "Selected Parcel";
  groupLayers[10] = "Ocean";
  groupLayers[11] = "Neighboring Towns";
  groupLayers[12] = "Major Water Bodies";  
  groupLayerInfo[0] = groupVisible;
  groupLayerInfo[1] = groupName;
  groupLayerInfo[2] = groupLayers;
  groupManager[7] = groupLayerInfo;
  
      //   Group 7 - Street Map - All street information
  // nb - after the first group, do not use VAR to declare variables, they are only declared once.
  groupVisible = true;
  groupName = "Elderly Affordable Housing Zoning";
  groupLayers = new Array();
  groupLayerInfo = new Array();
  groupLayers[0] = "Buildings";
  groupLayers[1] = "Road Names";
  groupLayers[2] = "Parcels - Clear";
  groupLayers[3] = "York Village Affordable Elderly Housing District";
  groupLayers[4] = "Roads";
  groupLayers[5] = "Townline";
  groupLayers[6] = "Road Centerline";
  groupLayers[7] = "Water Bodies";
  groupLayers[8] = "Parcels";
  groupLayers[9] = "Selected Parcel";
  groupLayers[10] = "Ocean";
  groupLayers[11] = "Neighboring Towns";
  groupLayers[12] = "Major Water Bodies";  
  groupLayerInfo[0] = groupVisible;
  groupLayerInfo[1] = groupName;
  groupLayerInfo[2] = groupLayers;
  groupManager[8] = groupLayerInfo;
  
    //   Group 8 - Street Map - All street information
  // nb - after the first group, do not use VAR to declare variables, they are only declared once.
  groupVisible = true;
  groupName = "Hospital Overlay District";
  groupLayers = new Array();
  groupLayerInfo = new Array();
  groupLayers[0] = "Buildings";
  groupLayers[1] = "Road Names";
  groupLayers[2] = "Parcels - Clear";
  groupLayers[3] = "York Village Hospital Overlay District";
  groupLayers[4] = "Roads";
  groupLayers[5] = "Townline";
  groupLayers[6] = "Road Centerline";
  groupLayers[7] = "Water Bodies";
  groupLayers[8] = "Parcels";
  groupLayers[9] = "Selected Parcel";
  groupLayers[10] = "Ocean";
  groupLayers[11] = "Neighboring Towns";
  groupLayers[12] = "Major Water Bodies";  
  groupLayerInfo[0] = groupVisible;
  groupLayerInfo[1] = groupName;
  groupLayerInfo[2] = groupLayers;
  groupManager[9] = groupLayerInfo;
  
    //   Group 9 - Street Map - All street information
  // nb - after the first group, do not use VAR to declare variables, they are only declared once.
  groupVisible = true;
  groupName = "Wireless Communication Facilities Overlay";
  groupLayers = new Array();
  groupLayerInfo = new Array();
  groupLayers[0] = "Buildings";
  groupLayers[1] = "Road Names";
  groupLayers[2] = "Parcels - Clear";
  groupLayers[3] = "Roads";
  groupLayers[4] = "Wireless Communication Facilities Overlay District";
  groupLayers[5] = "Townline";
  groupLayers[6] = "Road Centerline";
  groupLayers[7] = "Water Bodies";
  groupLayers[8] = "Parcels";
  groupLayers[9] = "Selected Parcel";
  groupLayers[10] = "Ocean";
  groupLayers[11] = "Neighboring Towns";
  groupLayers[12] = "Major Water Bodies";  
  groupLayerInfo[0] = groupVisible;
  groupLayerInfo[1] = groupName;
  groupLayerInfo[2] = groupLayers;
  groupManager[10] = groupLayerInfo;
  
  //   Group 10 - Street Map - All street information
  // nb - after the first group, do not use VAR to declare variables, they are only declared once.
  groupVisible = true;
  groupName = "Flood Plain Mapping";
  groupLayers = new Array();
  groupLayerInfo = new Array();
  groupLayers[0] = "Buildings";
  groupLayers[1] = "Road Names";
  groupLayers[2] = "Parcels-Flood Maps";
  groupLayers[3] = "Coastal Barrier Resources System";
  groupLayers[4] = "Flood Zones";
  groupLayers[5] = "Roads";
  groupLayers[6] = "Town Border";
  groupLayers[7] = "Road Centerline";
  groupLayers[8] = "Water Bodies";
  groupLayers[9] = "Townline";
  groupLayers[10] = "Rivers and Streams";
  groupLayers[11] = "Selected Parcel";
  groupLayers[12] = "Ocean";
  //groupLayers[12] = "Major Water Bodies";
  //groupLayers[13] = "Flood Panel Index";
  groupLayerInfo[0] = groupVisible;
  groupLayerInfo[1] = groupName;
  groupLayerInfo[2] = groupLayers;
  groupManager[11] = groupLayerInfo;
  
    //   Group 11 - Street Map - All street information
  // nb - after the first group, do not use VAR to declare variables, they are only declared once.
  groupVisible = true;
  groupName = "Aerial Photography";
  groupLayers = new Array();
  groupLayerInfo = new Array();
  groupLayers[0] = "Road Names";
  groupLayers[1] = "Parcels Clear";
  groupLayers[2] = "Roads";
  groupLayers[3] = "Town Border";
  groupLayers[4] = "Road Centerline";
  groupLayers[5] = "Townline";
  groupLayers[6] = "New Ortho";
  groupLayers[7] = "Neighboring Towns";
  groupLayers[8] = "Air Photo";
  groupLayers[9] = "Selected Parcel";
  groupLayerInfo[0] = groupVisible;
  groupLayerInfo[1] = groupName;
  groupLayerInfo[2] = groupLayers;
  groupManager[12] = groupLayerInfo;
  
    //   Group 12 - Street Map - All street information
  // nb - after the first group, do not use VAR to declare variables, they are only declared once.
  groupVisible = true;
  groupName = "Trash Day Mapping";
  groupLayers = new Array();
  groupLayerInfo = new Array();
  groupLayers[0] = "Townline";
  groupLayers[1] = "Parcels - Clear";
  groupLayers[2] = "Buildings";
  groupLayers[3] = "Road Names";  
  groupLayers[4] = "Roads with Trash Day";
  groupLayers[5] = "Parcels";
  groupLayers[6] = "Water Bodies";
  groupLayers[7] = "Rivers and Streams";
  groupLayers[8] = "Property Dimensions";
  groupLayers[9] = "Road Centerline";
  groupLayers[10] = "Selected Parcel";
  groupLayers[11] = "Ocean";
  groupLayers[12] = "Neighboring Towns";
  groupLayers[13] = "Major Water Bodies";  
  groupLayerInfo[0] = groupVisible;
  groupLayerInfo[1] = groupName;
  groupLayerInfo[2] = groupLayers;
  groupManager[13] = groupLayerInfo;
  
      //   Group 13 - Street Map - All street information
  // nb - after the first group, do not use VAR to declare variables, they are only declared once.
    groupVisible = true;
  groupName = "Street Ownership";
  groupLayers = new Array();
  groupLayerInfo = new Array();
  groupLayers[0] = "Townline";
  groupLayers[1] = "Parcels - Clear";
  groupLayers[2] = "Buildings";
  groupLayers[3] = "Road Names";  
  groupLayers[4] = "Street Ownership";
  groupLayers[5] = "Parcels";
  groupLayers[6] = "Water Bodies";
  groupLayers[7] = "Rivers and Streams";
  groupLayers[8] = "Property Dimensions";
  groupLayers[9] = "Road Centerline";
  groupLayers[10] = "Selected Parcel";
  groupLayers[11] = "Ocean";
  groupLayers[12] = "Neighboring Towns";
  groupLayers[13] = "Major Water Bodies";  
  groupLayerInfo[0] = groupVisible;
  groupLayerInfo[1] = groupName;
  groupLayerInfo[2] = groupLayers;
  groupManager[14] = groupLayerInfo;
  
        //   Group 14 - Firearms Map - All street information
  // nb - after the first group, do not use VAR to declare variables, they are only declared once.
    groupVisible = true;
  groupName = "Firearms Safety Ordinance";
  groupLayers = new Array();
  groupLayerInfo = new Array();
  groupLayers[0] = "Townline";
  groupLayers[1] = "Parcels - Clear";
  groupLayers[2] = "Buildings";
  groupLayers[3] = "Road Names";
  groupLayers[4] = "State Game Preserve";  
  groupLayers[5] = "Firearms Safety Zones";
  groupLayers[6] = "Parcels";
  groupLayers[7] = "Water Bodies";
  groupLayers[8] = "Rivers and Streams";
  groupLayers[9] = "Property Dimensions";
  groupLayers[10] = "Road Centerline";
  groupLayers[11] = "Selected Parcel";
  groupLayers[12] = "Ocean";
  groupLayers[13] = "Neighboring Towns";
  groupLayers[14] = "Major Water Bodies";  
  groupLayerInfo[0] = groupVisible;
  groupLayerInfo[1] = groupName;
  groupLayerInfo[2] = groupLayers;
  groupManager[15] = groupLayerInfo;

	
	        //   Group 17 - Home Occupation Zones - All street information
	// nb - after the first group, do not use VAR to declare variables, they are only declared once.
	  groupVisible = true;
	groupName = "Home Occupation Zones";
	groupLayers = new Array();
	groupLayerInfo = new Array();
	groupLayers[0] = "Townline";
	groupLayers[1] = "Parcels - Clear";
	groupLayers[2] = "Buildings";
	groupLayers[3] = "Road Names";
	groupLayers[4] = "Home Occupation Zones";  
	groupLayers[5] = "Parcels";
	groupLayers[6] = "Water Bodies";
	groupLayers[7] = "Rivers and Streams";
	groupLayers[8] = "Property Dimensions";
	groupLayers[9] = "Road Centerline";
	groupLayers[10] = "Selected Parcel";
	groupLayers[11] = "Ocean";
	groupLayers[12] = "Neighboring Towns";
	groupLayers[13] = "Major Water Bodies";  
	groupLayerInfo[0] = groupVisible;
	groupLayerInfo[1] = groupName;
	groupLayerInfo[2] = groupLayers;
	groupManager[16] = groupLayerInfo;
	
	  	        //   Group 18 - Rough Draft Shoreland Zones - All street information
	// nb - after the first group, do not use VAR to declare variables, they are only declared once.
	groupVisible = true;
	groupName = "Conceptual Toll Booth Locations";
	groupLayers = new Array();
	groupLayerInfo = new Array();
	groupLayers[0] = "Townline";
	groupLayers[1] = "Parcels - Clear";
	groupLayers[2] = "Buildings";
	groupLayers[3] = "Road Names";
	groupLayers[4] = "Parcels";
	groupLayers[5] = "Water Bodies";
	groupLayers[6] = "Rivers and Streams";
	groupLayers[7] = "Conceptual Toll Booth Locations";
	groupLayers[8] = "Conceptual Toll Booth Location 8.7";
	groupLayers[9] = "Conceptual Toll Booth Location 9.9";
	groupLayers[10] = "Conceptual Toll Booth Location 11.3";
	groupLayers[11] = "Conceptual Toll Booth Location 13.2";
	groupLayers[12] = "Centerlines";
	groupLayers[13] = "Selected Parcel";
	groupLayers[14] = "Ocean";
	groupLayers[15] = "Neighboring Towns";
	groupLayers[16] = "Major Water Bodies";  
	groupLayerInfo[0] = groupVisible;
	groupLayerInfo[1] = groupName;
	groupLayerInfo[2] = groupLayers;
	groupManager[17] = groupLayerInfo; 
	
	  	        //   Group 18 - Rough Draft Shoreland Zones - All street information
	// nb - after the first group, do not use VAR to declare variables, they are only declared once.
//	groupVisible = true;
//	groupName = "FY 2009 DPW Crack/Seal/Patch Streets";
//	groupLayers = new Array();
//	groupLayerInfo = new Array();
//	groupLayers[0] = "Townline";
//	groupLayers[1] = "Parcels - Clear";
//	groupLayers[2] = "Buildings";
//	groupLayers[3] = "Road Names";
//	groupLayers[4] = "Parcels";
//	groupLayers[5] = "Water Bodies";
//	groupLayers[6] = "Rivers and Streams";
//	groupLayers[7] = "FY2009 streets to get patched";
//	groupLayers[8] = "FY2009 streets to get cracksealing";
//	groupLayers[9] = "Centerlines";
//	groupLayers[10] = "Selected Parcel";
//	groupLayers[11] = "Ocean";
//	groupLayers[12] = "Neighboring Towns";
//	groupLayers[13] = "Major Water Bodies";   
//	groupLayerInfo[0] = groupVisible;
//	groupLayerInfo[1] = groupName;
//	groupLayerInfo[2] = groupLayers;
//	groupManager[18] = groupLayerInfo;
	
	  	        //   Group 18 - Rough Draft Shoreland Zones - All street information
	// nb - after the first group, do not use VAR to declare variables, they are only declared once.
//	  groupVisible = true;
//	groupName = "Rough Draft Shoreland Zones";
//	groupLayers = new Array();
//	groupLayerInfo = new Array();
//	groupLayers[0] = "Townline";
//	groupLayers[1] = "Parcels - Clear";
//	groupLayers[2] = "Buildings";
//	groupLayers[3] = "Road Names";
//	groupLayers[4] = "Parcels";
//	groupLayers[5] = "Water Bodies";
//	groupLayers[6] = "Rivers and Streams";
//	groupLayers[7] = "Rough Draft Shoreland Changes";
//	groupLayers[8] = "Unstable Bluffs";
//	groupLayers[9] = "Slopes in Shoreland";
//	groupLayers[10] = "Inland Wading Habitat";
//	groupLayers[11] = "Road Centerlines";
//	groupLayers[12] = "Selected Parcel";
//	groupLayers[13] = "Ocean";
//groupLayers[14] = "Neighboring Towns";
//	groupLayers[15] = "Major Water Bodies";  
//	groupLayerInfo[0] = groupVisible;
//	groupLayerInfo[1] = groupName;
//	groupLayerInfo[2] = groupLayers;
//	groupManager[17] = groupLayerInfo; 
   
      //   Group 3 - Street Map - All street information
  // nb - after the first group, do not use VAR to declare variables, they are only declared once.
  //groupVisible = false;
  //groupName = "*Quick Map Test*";
  //groupLayers = new Array();
 //groupLayerInfo = new Array();
  //groupLayers[0] = "1";
  //groupLayers[1] = "2";
  //groupLayers[2] = "3";
  //groupLayers[3] = "4";
  //groupLayers[4] = "Structure";
 // groupLayers[5] = "Parcels - Ortho";
  //groupLayers[6] = "Aerial Photography - 2002";
  //groupLayers[7] = "Selected Parcel";
  //groupLayerInfo[0] = groupVisible;
  //groupLayerInfo[1] = groupName;
  //groupLayerInfo[2] = groupLayers;
  //groupManager[10] = groupLayerInfo;
/*
  Function uses the services of the getGroup to determine if the
  named layer belongs to a group.
  Modified from original sample version to support multiple layers.
  
  @param glayerName The name of a layer in the layer list.
  @return True if the layer in question is a group layer.
  @see #getGroup
  @author Cord Thomas
  */
function checkLayer(glayerName) {
   var gName=getGroup(glayerName);
   if (gName.length==0)
      return false;
   else
      return true;
}

/*
  Function returns the group a specified layer belongs to.
  
  @param glayerName The name of a layer in question.
  @return The name of the group the layer belongs to.
  @author Cord Thomas
  */
function getGroup(glayerName) {
  var glInfo=null;
  var gLayers=null;
  var gName="";
  for (var gm=0;gm<groupManager.length;gm++) {
     glInfo = groupManager[gm];
     gLayers = glInfo[2];
     gName = glInfo[1];
     for (var gl=0;gl<gLayers.length;gl++) {
        if (glayerName == gLayers[gl]) {
           return gName;
           break
	}
     }
   }
   return "";   // This should be blank.
}

/* Returns whether a named layer is in a group. 
   @param layerName The name of hte layer in question.
   @param groupName The name of the group to search in.
*/ 
function layerInGroup(layerName, groupName) {
   var glInfo=null;
   var gLayers=null;
   var gName="";
   for (var gm=0;gm<groupManager.length;gm++) {
      glInfo = groupManager[gm];
      gName = glInfo[1];
      // If the group name is the same as the groupName then we are in the right group.
      if (gName == groupName) {
         gLayers = glInfo[2];
         for (var gl=0;gl<gLayers.length;gl++) {
            if (layerName == gLayers[gl]) {
               return true;
               break
            }
         }
      }
   }
  return false;   // This should be blank.
}

function setGroup(theVal) {
 var theName;
  if (theVal == 1) { 
    groupVisible = true
  } else { 
    groupVisible = false 
  }
  for(var ii=0;ii<layerCount;ii++) {
    theName = LayerName[ii];
    if (checkLayer(theName) == true) {
      LayerVisible[ii] = theVal;     
    }
  }
}

/* Loop through all the layers in the map, if the layer is in the
   currently active group, then it is set to visible, otherwise it is not. */
function updateGroupLayers() {
  var j = 0;
  var groupFromLayer="";
  
  for (var i=0;i<t.layerCount;i++) {
    if (layerInGroup(t.LayerName[i], activeGroup)) {
      // alert (t.LayerName[i] + '  is visible');
      t.LayerVisible[i] = 1;
    } else {
      t.LayerVisible[i] = 0;
    }
  }
  t.sendMapXML();
}

 function setLayers (formListName) {
     activeGroup = eval("document." + formListName + ".value");
     if (activeGroup!="Default") {
        updateGroupLayers();
     }
 }
