//*********************************************************************
//
// USGS Group Layers Code additions 
// Created By:  Chris Rusanowski
// Modified By: Jennifer Ming
// Installation:
//   -Copy USGS_Catalog_Group_Layers.js into the javascript directory of the HTML Viewer
//   -Include in MapFrame.htm with the javascript code below:
//      <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript" SRC="http://gisdata.usgs.net/wms_catalog/index_as_js.php?View=Seamless"></SCRIPT>
//      <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript" SRC="javascript/USGS_Catalog_Group_Layers.js"></SCRIPT>
//      <script type="text/javascript" language="JavaScript" src="/MODIS_Current_Layers.jsp"></script>
//	USGS_Catalog_Group_Layers.js must after USGS_OGC_Download_Layers.js
//	MODIS_Current_Layers.jsp must after http://gisdata.usgs.net/wms_catalog/index_as_js.php?View=Seamless
//
//   -Add the Following code to the BeforeMapRefresh function in MapFrame.htm
//      if (USGS_Group_Loaded) {
//        if (IVM_Initialized==false) IVM_Init_Selected_Layer();
//        IVM_Update_Layer();
//      }
//   -Add var USGS_Group_Loaded=false; to mapframe.htm before the load of this file
//
//   -Add the Following code to the DrawOGCLayers function in USGS_OGC.js (after   Downloading_Count = 0;)   
//          //If we are using  the Group Layers, we want to update the visibility
//          //of the layers based upon the group rendering.
//          if (USGS_Group_Loaded) { IVM_OGC_Update_Layer(); }
//
//   -Add the Following code to the getOGCLayerList function in USGS_Download_List.js (From beginning)
//          //If using group layers reset the display counter variables
//          if (USGS_Group_Loaded) { IVM_OGC_Reset_Display(); }

//	Note: If you do not have download button, add the following lines
//
//   -Add the Following code to the getOGCTOC function in USGS_OGC.js (From beginning)
//          //If using group layers reset the display counter variables
//          if (USGS_Group_Loaded) { IVM_OGC_Reset_Display(); }
//
//
//   -Add the Following code to the GetOGCTOC_Layer function in USGS_OGC.js(From the second line)
//    //*********************************************************************                   
//    //*			  START of Code to Add USGS Grouping Layers                   
//    //*********************************************************************
//  //If using the Group rendering then grouped layers only get 1 TOC entry, so
//  //we do a check to see if one TOC entry has already been displayed...
//  var Temp_Keyword = -1;
//
//  if (USGS_Group_Loaded) {
//    Temp_Keyword = IVM_Keyword_check(SRC_Layer_Name[LayerID]);
//  }
//
//  if (Temp_Keyword>-1){
//    if (!IVM_Selected_Layer_Displayed[Temp_Keyword]){
//    	IVM_Selected_Layer_Displayed[Temp_Keyword] = true;
//        LocalString += ('<tr><td>&nbsp;</td><td valign="top" align="left">');
//	if(parent.MapFrame.IVM_Selected_Layer_SubSelect[Temp_Keyword] == "[Not Selected]" || parent.MapFrame.IVM_Selected_Layer_SubSelect[Temp_Keyword] == undefined){
//    		LocalString += ('<input type="Button" style="font-size: 6pt; padding: 0px; border-style: inset;" name="GroupButton" + Temp_Index  value=" O " ');
//	}else{
//
//    		LocalString += ('<input type="Button" style="font-size: 6pt; padding: 0px;;" name="GroupButton" + Temp_Index  value=" X " ');
//	}
//
//	//Note: If you do not have LPDAAC just add one line: LocalString += (' onclick="parent.MapFrame.setMODIS(' + Temp_Keyword + ');"');										
//      if(Temp_Keyword == 0){						
//        LocalString += (' onclick="parent.MapFrame.setLPDAAC(' + Temp_Keyword + ');"');          
//      }else if (Temp_Keyword == 1){
//        LocalString += (' onclick="parent.MapFrame.setMODIS(' + Temp_Keyword + ');"');
//      }
//
//    if ((SRC_Layer_Max_Scale[LayerID]!=0 && SRC_Layer_Max_Scale[LayerID]<CurrentMapScale) || ((SRC_Layer_Min_Scale[LayerID]!=0 && SRC_Layer_Min_Scale[LayerID]>CurrentMapScale) ) ){
//      LocalString += (' disabled="disabled"');
//      DisableColor = '#CCCCCC';
//    } else {
//      LocalString += (' readonly="readonly"');
//      DisableColor = parent.USGSTextColor;
//    }
//    LocalString += (' />');
//
//    //If the Layer has a documentation URL then write our layer name hot-linked to that URL
//    if (SRC_Layer_Documentation_URL[LayerID].length>0) {
//
//       if(parent.MapFrame.IVM_Selected_Layer_SubSelect[Temp_Keyword] == "[Not Selected]" || parent.MapFrame.IVM_Selected_Layer_SubSelect[Temp_Keyword] == "undefined"){
//      		LocalString += ('</td><td valign="top" align="left"><a href="' + SRC_Layer_Documentation_URL[LayerID] + '" target="_blank" title="View Documentation about this layer."><span style="color: ' + DisableColor + ';">' + parent.MapFrame.IVM_Keyword_Array[Temp_Keyword] + '</span></a></td></tr>');	   
//	}else{		
//      		LocalString += ('</td><td valign="top" align="left"><a href="' + SRC_Layer_Documentation_URL[LayerID] + '" target="_blank" title="View Documentation about this layer."><span style="color: ' + DisableColor + ';">' + parent.MapFrame.IVM_Selected_Layer_SubSelect[Temp_Keyword] + '</span></a></td></tr>');
//        }
//
//    } else {
//      //No Documentation URL, so if there is a Metadata URL hot-link the layer name to that
//      if (SRC_Layer_Metadata_URL[LayerID].length>0) {
//
//	    if(parent.MapFrame.IVM_Selected_Layer_SubSelect[Temp_Keyword] == "[Not Selected]" || parent.MapFrame.IVM_Selected_Layer_SubSelect[Temp_Keyword] == "undefined"){
//     		LocalString += ('</td><td valign="top" align="left"><a href="' + SRC_Layer_Metadata_URL[LayerID] + '" target="_blank" title="View Documentation about this layer."><span style="color: ' + DisableColor + ';">' + parent.MapFrame.IVM_Keyword_Array[Temp_Keyword] + '</span></a></td></tr>');	   
//	     }else{		
//      		LocalString += ('</td><td valign="top" align="left"><a href="' + SRC_Layer_Metadata_URL[LayerID] + '" target="_blank" title="View Documentation about this layer."><span style="color: ' + DisableColor + ';">' + parent.MapFrame.IVM_Selected_Layer_SubSelect[Temp_Keyword] + '</span></a></td></tr>');
//	     }
//
//      } else {
//        //No Documentation URL or Metadata URL, so just print the Layer name.
//
//	    if(parent.MapFrame.IVM_Selected_Layer_SubSelect[Temp_Keyword] == "[Not Selected]" || parent.MapFrame.IVM_Selected_Layer_SubSelect[Temp_Keyword] == "undefined"){
//      		LocalString += ('</td><td valign="top" align="left"><span style="color: ' + DisableColor + ';">' + parent.MapFrame.IVM_Keyword_Array[Temp_Keyword] + '</span></a></td></tr>');	   
//	     }else{		
//      		LocalString += ('</td><td valign="top" align="left"><span style="color: ' + DisableColor + ';">' + parent.MapFrame.IVM_Selected_Layer_SubSelect[Temp_Keyword] + '</span></a></td></tr>');
//	     }
//      }
//    }
//    //If we are displaying layer classification and this layer has a legend image URL defined, then we display that
//    if (Display_Layer_Classification && SRC_Layer_Icon_URL[LayerID].length > 0) {
//      LocalString += ('<tr><td>&nbsp;</td><td>&nbsp;</td><td valign="top" align="left">');
//      LocalString += ('<img src="' + SRC_Layer_Icon_URL[LayerID] + '" style="background-color: #FFFFFF;" alt="Classification for ' + SRC_Layer_Name[LayerID] + '" /></td></tr>');
//    }
//
//    }//end if (!IVM_Selected_Layer_Displayed[Temp_Keyword])
//  }else{
//    //*********************************************************************
//    //*			  END of Code to Add USGS Grouping Layers                     
//    //*********************************************************************
//
//	here is original code 
//
//    //*********************************************************************                   
//    //*			  START of Code to Add USGS Grouping Layers                   
//    //*********************************************************************
//  } // end if (Temp_Keyword>-1)
//    //*********************************************************************
//    //*			  END of Code to Add USGS Grouping Layers                     
//    //*********************************************************************
//
//    The following lines are only for LPDAAC
//    -Copy lpdaac.asp into the main HTML viewer directory
//    -COpy daac.css into the includes directory
//    -Copy lpdaac.herder.jpg into the images directory
//    -Copy the menu directory into images directory
//    -The layer name of LPDAAC Modis look likes: "SRC_Layer_Name[610] = 'NASA_LPDAAC_MOD13A2 004 NDVI 2000 049';" in the Catalog
//*********************************************************************//Define all the variables used to include Group Layers in the map
//USGS_Group_Loaded is used to check if the extension is loaded and if
//it should be used.  Set this to false if you do not want any grouping
//of layers to show up at all.
//It comes from the mapframe.htm because it is needed there to avoid 
//any error messages, if there is a problem loading this file.
USGS_Group_Loaded=true;

//If the USGS_OGC_Loaded variable is not defined - USGS_OGC.js is not loaded
//then uncomment the line below to avoid error messages...
var USGS_OGC_Loaded = true;

//Display_Only_OGC is used by the TOC to show only OGC layers, and no
//layers from the overlying map service.
Display_Only_OGC=true;


//IVM_Keyword_Array is the grouping definition.  It may be a keyword included within a layer
//(IE: To include any layer that has GREENNESS as part of the ID, just specify "GREENNESS"), or
//it may be a comma-separated list of layer id's to be merged as a single grouping  (IE: To 
//include GREENNESS_20020602 and GREENNESS_20020702 as one grouping specify "GREENNESS_20020602,GREENNESS_20020702").
//When using the layerID's rather than a keyword, the match must be the complete Layer ID for each in the grouping.
//The default code saved in CVS includes grouping for the ZipnShip service and the IVM pages.
var IVM_Keyword_Array = new Array();
IVM_Keyword_Array[0] = "Landsat 1-3 MSS";
IVM_Keyword_Array[1] = "Landsat 4-5 MSS";
IVM_Keyword_Array[2] = "Landsat 4-5 TM 12/31/99";
IVM_Keyword_Array[3] = "LGSOWG Landsat 1-3 MSS";
IVM_Keyword_Array[4] = "LGSOWG Landsat 4-5 MSS";
IVM_Keyword_Array[5] = "USGS SPOT";
IVM_Keyword_Array[6] = "USGS Declassified";
IVM_Keyword_Array[7] = "Landsat ETM+ 12/31/03";
IVM_Keyword_Array[8] = "Declass II High Resolution";
IVM_Keyword_Array[9] = "Declass II Medium Resolution";
// IVM_Keyword_Array[10] = "Space Imaging IKONOS";
IVM_Keyword_Array[10] = "DigitalGlobe Quickbird";
IVM_Keyword_Array[11] = "NASA Ames Aerial Photographs";

//IVM_Keyword_URLS allows you to specify a documentation or related link for the whole grouping.  Leave blank string 
//if this does not exist.  The name in the TOC will be linked to this URL.
var IVM_Keyword_URLS = new Array();
IVM_Keyword_URLS[0] = "";
IVM_Keyword_URLS[1] = "";
IVM_Keyword_URLS[2] = "";
IVM_Keyword_URLS[3] = "";
IVM_Keyword_URLS[4] = "";
IVM_Keyword_URLS[5] = "";
IVM_Keyword_URLS[6] = "";
IVM_Keyword_URLS[7] = "";
IVM_Keyword_URLS[8] = "";
IVM_Keyword_URLS[9] = "";
// IVM_Keyword_URLS[10] = "";
IVM_Keyword_URLS[10] = "";
IVM_Keyword_URLS[11] = "";

//IVM_Keyword_Name allows you to specify a group name to display for this grouping. Used when no matching layers are found...
//Leave this blank if you want the layer name from the Map Service to be displayed instead of this name.
var IVM_Keyword_Name = new Array();
IVM_Keyword_Name[0] = "Landsat 1-3 MSS";//display it on the web page
IVM_Keyword_Name[1] = "Landsat 4-5 MSS";
IVM_Keyword_Name[2] = "Landsat 4-5 TM 12/31/99";
IVM_Keyword_Name[3] = "LGSOWG Landsat 1-3 MSS";
IVM_Keyword_Name[4] = "LGSOWG Landsat 4-5 MSS";
IVM_Keyword_Array[5] = "USGS SPOT";
IVM_Keyword_Array[6] = "USGS Declassified";
IVM_Keyword_Array[7] = "Landsat ETM+ 12/31/03";
IVM_Keyword_Array[8] = "Declass II High Resolution";
IVM_Keyword_Array[9] = "Declass II Medium Resolution";
// IVM_Keyword_Array[10] = "Space Imaging IKONOS";
IVM_Keyword_Array[10] = "DigitalGlobe Quickbird";
IVM_Keyword_Array[11] = "NASA Ames Aerial Photographs";



//IVM_Keyword_Type specifies the type of grouping display.  "Single" type groupings will only display 1 layer at a time and all other group layers
//will be hidden.  If the user turns it on or off, then they are prompted to choose the layer from among the grouped layers that gets displayed.
//"Multiple" type groupings will turn all the layers in a group on or off together.  All the matching layers are handled through one entry in the
//toc so the user does not get prompted to choose a layer from the group.
var IVM_Keyword_Type = new Array();
IVM_Keyword_Type[0] = "Multiple";
IVM_Keyword_Type[1] = "Multiple";
IVM_Keyword_Type[2] = "Multiple";
IVM_Keyword_Type[3] = "Multiple";
IVM_Keyword_Type[4] = "Multiple";
IVM_Keyword_Type[5] = "Multiple";
IVM_Keyword_Type[6] = "Multiple";
IVM_Keyword_Type[7] = "Multiple";
IVM_Keyword_Type[8] = "Multiple";
IVM_Keyword_Type[9] = "Multiple";
//IVM_Keyword_Type[10] = "Multiple";
IVM_Keyword_Type[10] = "Multiple";
IVM_Keyword_Type[11] = "Multiple";
//The following five variables are used by the code to determine the proper layer to display
//and make sure only one entry per grouping is displayed.
var IVM_Selected_Layer_Name = new Array();
var IVM_Selected_Layer_SubSelect = new Array();
var IVM_Selected_Layer_Transparency = new Array();
var IVM_Selected_Layer_Displayed = new Array();
var IVM_Initialized = false;

//IVM_Selected_Layer_ID will hold the Layer ID that is visible for the Single Type of groupings, or it will hold the current visibility
//for the Multiple type of groupings.
var IVM_Selected_Layer_ID = new Array();

//Alt_Display_Layername and Original_Display_Layername are used for dynamic display of a layer name, or renaming layers on the fly.
//Get_Display_LayerName will search Original_Display_Layername and replace return the corresponding Alt_Display_Layername
var Alt_Display_Layername = new Array();
var Original_Display_Layername = new Array();
var Alt_Display_Layername_Year = new Array();
var Alt_Display_Layername_Date = new Array();

//The following two variables are used by the code to determine the proper layer names for index
var IVM_IndexedWMSOriginalName = new Array();
var IVM_IndexedWMSDisplayNames = new Array();
var IVM_IndexedWMSLayers = new Array();
var IVM_IndexedWMSServices = new Array();

var LPDaac_Category_Order = new Array();
var LPDaac_Category_ID = new Array();
var LPDaac_Category_Year_Order = new Array();

//Default Categories in order are (for MSS2):

LPDaac_Category_Order[0] = "1983";
LPDaac_Category_Order[1] = "1981";
LPDaac_Category_Order[2] = "1980";
LPDaac_Category_Order[3] = "1979";
LPDaac_Category_Order[4] = "1978";
LPDaac_Category_Order[5] = "1977";
LPDaac_Category_Order[6] = "1976";
LPDaac_Category_Order[7] = "1975";
LPDaac_Category_Order[8] = "1974";
LPDaac_Category_Order[9] = "1973";
LPDaac_Category_Order[10] = "1972";

//
LPDaac_Category_ID[0] = "1983";
LPDaac_Category_ID[1] = "1981";
LPDaac_Category_ID[2] = "1980";
LPDaac_Category_ID[3] = "1979";
LPDaac_Category_ID[4] = "1978";
LPDaac_Category_ID[5] = "1977";
LPDaac_Category_ID[6] = "1976";
LPDaac_Category_ID[7] = "1975";
LPDaac_Category_ID[8] = "1974";
LPDaac_Category_ID[9] = "1973";
LPDaac_Category_ID[10] = "1972";

//Years available per band
LPDaac_Category_Year_Order[0]  = "Full Year,Spring";
LPDaac_Category_Year_Order[1]  = "Full Year,Winter,Spring,Fall";
LPDaac_Category_Year_Order[2]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order[3]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order[4]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order[5]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order[6]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order[7]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order[8]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order[9]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order[10] = "Full Year,Winter,Fall";


//for MSS1
var LPDaac_Category_Order1 = new Array();
var LPDaac_Category_ID1 = new Array();
var LPDaac_Category_Year_Order1 = new Array();

//Default Categories in order are:

LPDaac_Category_Order1[0] = "1992";
LPDaac_Category_Order1[1] = "1991";
LPDaac_Category_Order1[2] = "1990";
LPDaac_Category_Order1[3] = "1989";
LPDaac_Category_Order1[4] = "1988";
LPDaac_Category_Order1[5] = "1987";
LPDaac_Category_Order1[6] = "1986";
LPDaac_Category_Order1[7] = "1985";
LPDaac_Category_Order1[8] = "1984";
LPDaac_Category_Order1[9] = "1983";
LPDaac_Category_Order1[10] = "1982";

//
LPDaac_Category_ID1[0] = "1992";
LPDaac_Category_ID1[1] = "1991";
LPDaac_Category_ID1[2] = "1990";
LPDaac_Category_ID1[3] = "1989";
LPDaac_Category_ID1[4] = "1988";
LPDaac_Category_ID1[5] = "1987";
LPDaac_Category_ID1[6] = "1986";
LPDaac_Category_ID1[7] = "1985";
LPDaac_Category_ID1[8] = "1984";
LPDaac_Category_ID1[9] = "1983";
LPDaac_Category_ID1[10] = "1982";

//Years available per band
LPDaac_Category_Year_Order1[0]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order1[1]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order1[2]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order1[3]  = "Full Year,Spring,Summer,Fall";
LPDaac_Category_Year_Order1[4]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order1[5]  = "Full Year,Spring,Summer,Fall";
LPDaac_Category_Year_Order1[6]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order1[7]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order1[8]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order1[9]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order1[10] = "Full Year,Summer,Fall";

//for IGSLG MSS1
var LPDaac_Category_Order2 = new Array();
var LPDaac_Category_ID2 = new Array();
var LPDaac_Category_Year_Order2 = new Array();

//Default Categories in order are:
LPDaac_Category_Order2[0] = "1999";
LPDaac_Category_Order2[1] = "1998";
LPDaac_Category_Order2[2] = "1997";
LPDaac_Category_Order2[3] = "1996";
LPDaac_Category_Order2[4] = "1995";
LPDaac_Category_Order2[5] = "1994";
LPDaac_Category_Order2[6] = "1993";
LPDaac_Category_Order2[7] = "1992";
LPDaac_Category_Order2[8] = "1991";
LPDaac_Category_Order2[9] = "1990";
LPDaac_Category_Order2[10] = "1989";
LPDaac_Category_Order2[11] = "1988";
LPDaac_Category_Order2[12] = "1987";
LPDaac_Category_Order2[13] = "1986";
LPDaac_Category_Order2[14] = "1985";
LPDaac_Category_Order2[15] = "1984";
LPDaac_Category_Order2[16] = "1983";


//
LPDaac_Category_ID2[0] = "1999";
LPDaac_Category_ID2[1] = "1998";
LPDaac_Category_ID2[2] = "1997";
LPDaac_Category_ID2[3] = "1996";
LPDaac_Category_ID2[4] = "1995";
LPDaac_Category_ID2[5] = "1994";
LPDaac_Category_ID2[6] = "1993";
LPDaac_Category_ID2[7] = "1992";
LPDaac_Category_ID2[8] = "1991";
LPDaac_Category_ID2[9] = "1990";
LPDaac_Category_ID2[10] = "1989";
LPDaac_Category_ID2[11] = "1988";
LPDaac_Category_ID2[12] = "1987";
LPDaac_Category_ID2[13] = "1986";
LPDaac_Category_ID2[14] = "1985";
LPDaac_Category_ID2[15] = "1984";
LPDaac_Category_ID2[16] = "1983";




//Years available per band
LPDaac_Category_Year_Order2[0]  = "Full Year,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[1]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[2]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[3]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[4]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[5]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[6]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[7]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[8]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[9]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[10] = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[11]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[12]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[13]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[14]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[15]  = "Full Year,Spring,Summer,Fall";
LPDaac_Category_Year_Order2[16]  = "Winter,Summer";





//for TM
var LPDaac_Category_Order3 = new Array();
var LPDaac_Category_ID3 = new Array();
var LPDaac_Category_Year_Order3 = new Array();

//Default Categories in order are:
LPDaac_Category_Order3[0] = "1982";
LPDaac_Category_Order3[1] = "1981";
LPDaac_Category_Order3[2] = "1980";
LPDaac_Category_Order3[3] = "1979";
LPDaac_Category_Order3[4] = "1978";
LPDaac_Category_Order3[5] = "1977";
LPDaac_Category_Order3[6] = "1976";
LPDaac_Category_Order3[7] = "1975";

//
LPDaac_Category_ID3[0] = "1982";
LPDaac_Category_ID3[1] = "1981";
LPDaac_Category_ID3[2] = "1980";
LPDaac_Category_ID3[3] = "1979";
LPDaac_Category_ID3[4] = "1978";
LPDaac_Category_ID3[5] = "1977";
LPDaac_Category_ID3[6] = "1976";
LPDaac_Category_ID3[7] = "1975";


//Years available per band
LPDaac_Category_Year_Order3[0]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order3[1]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order3[2]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order3[3]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order3[4]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order3[5]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order3[6]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order3[7]  = "Full Year,Spring,Summer,Fall,Winter";




//for TM
var LPDaac_Category_Order4 = new Array();
var LPDaac_Category_ID4 = new Array();
var LPDaac_Category_Year_Order4 = new Array();

//Default Categories in order are:
LPDaac_Category_Order4[0] = "1999";
LPDaac_Category_Order4[1] = "1998";
LPDaac_Category_Order4[2] = "1997";
LPDaac_Category_Order4[3] = "1996";
LPDaac_Category_Order4[4] = "1995";
LPDaac_Category_Order4[5] = "1994";
LPDaac_Category_Order4[6] = "1993";
LPDaac_Category_Order4[7] = "1992";
LPDaac_Category_Order4[8] = "1991";
LPDaac_Category_Order4[9] = "1990";
LPDaac_Category_Order4[10] = "1989";
LPDaac_Category_Order4[11] = "1988";
LPDaac_Category_Order4[12] = "1987";
LPDaac_Category_Order4[13] = "1986";
LPDaac_Category_Order4[14] = "1985";
LPDaac_Category_Order4[15] = "1984";
LPDaac_Category_Order4[16] = "1983";
LPDaac_Category_Order4[17] = "1982";

//
LPDaac_Category_ID4[0] = "1999";
LPDaac_Category_ID4[1] = "1998";
LPDaac_Category_ID4[2] = "1997";
LPDaac_Category_ID4[3] = "1996";
LPDaac_Category_ID4[4] = "1995";
LPDaac_Category_ID4[5] = "1994";
LPDaac_Category_ID4[6] = "1993";
LPDaac_Category_ID4[7] = "1992";
LPDaac_Category_ID4[8] = "1991";
LPDaac_Category_ID4[9] = "1990";
LPDaac_Category_ID4[10] = "1989";
LPDaac_Category_ID4[11] = "1988";
LPDaac_Category_ID4[12] = "1987";
LPDaac_Category_ID4[13] = "1986";
LPDaac_Category_ID4[14] = "1985";
LPDaac_Category_ID4[15] = "1984";
LPDaac_Category_ID4[16] = "1983";
LPDaac_Category_ID4[17] = "1982";


//Years available per band
LPDaac_Category_Year_Order4[0]  = "";
LPDaac_Category_Year_Order4[1]  = "Full Year,Spring,Summer,Winter";
LPDaac_Category_Year_Order4[2]  = "Full Year,Spring,Summer,Winter";
LPDaac_Category_Year_Order4[3]  = "Full Year,Spring,Summer,Winter";
LPDaac_Category_Year_Order4[4]  = "Full Year,Spring,Summer,Winter";
LPDaac_Category_Year_Order4[5]  = "Full Year,Spring,Summer,Winter";
LPDaac_Category_Year_Order4[6]  = "Full Year,Spring,Summer,Winter";
LPDaac_Category_Year_Order4[7]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order4[8]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order4[9]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order4[10] = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order4[11]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order4[12]  = "Full Year";
LPDaac_Category_Year_Order4[13]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order4[14]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order4[15]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order4[16]  = "Full Year,winter";
LPDaac_Category_Year_Order4[17]  = "Full Year";


//for TM
var LPDaac_Category_Order5 = new Array();
var LPDaac_Category_ID5 = new Array();
var LPDaac_Category_Year_Order5 = new Array();

//Default Categories in order are:
LPDaac_Category_Order5[0] = "1999";
LPDaac_Category_Order5[1] = "1998";
LPDaac_Category_Order5[2] = "1997";
LPDaac_Category_Order5[3] = "1996";
LPDaac_Category_Order5[4] = "1995";
LPDaac_Category_Order5[5] = "1994";
LPDaac_Category_Order5[6] = "1993";
LPDaac_Category_Order5[7] = "1992";
LPDaac_Category_Order5[8] = "1991";
LPDaac_Category_Order5[9] = "1990";
LPDaac_Category_Order5[10] = "1989";
LPDaac_Category_Order5[11] = "1988";
LPDaac_Category_Order5[12] = "1987";
LPDaac_Category_Order5[13] = "1986";

//
LPDaac_Category_ID5[0] = "1999";
LPDaac_Category_ID5[1] = "1998";
LPDaac_Category_ID5[2] = "1997";
LPDaac_Category_ID5[3] = "1996";
LPDaac_Category_ID5[4] = "1995";
LPDaac_Category_ID5[5] = "1994";
LPDaac_Category_ID5[6] = "1993";
LPDaac_Category_ID5[7] = "1992";
LPDaac_Category_ID5[8] = "1991";
LPDaac_Category_ID5[9] = "1990";
LPDaac_Category_ID5[10] = "1989";
LPDaac_Category_ID5[11] = "1988";
LPDaac_Category_ID5[12] = "1987";
LPDaac_Category_ID5[13] = "1986";


//Years available per band
LPDaac_Category_Year_Order5[0]  = "Winter";
LPDaac_Category_Year_Order5[1]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order5[2]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order5[3]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order5[4]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order5[5]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order5[6]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order5[7]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order5[8]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order5[9] =  "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order5[10]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order5[11]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order5[12]  = "Full Year,Spring,Summer,Fall,Winter";
LPDaac_Category_Year_Order5[13]  = "Full Year,Summer,Fall";

var LPDaac_Category_Order6 = new Array();
var LPDaac_Category_ID6 = new Array();
var LPDaac_Category_Camera_Order6 = new Array();
var LPDaac_Category_Date_Order_0 = new Array();
var LPDaac_Category_Resolution_Order_0 = new Array();
var LPDaac_Category_Resolution_Order_1 = new Array();
var LPDaac_Category_Resolution_Order_2 = new Array();
var LPDaac_Category_Resolution_Order_3 = new Array();
var LPDaac_Category_Resolution_Order_4 = new Array();
var LPDaac_Category_Resolution_Order_5 = new Array();
var LPDaac_Category_Resolution_Order_6 = new Array();
var LPDaac_Category_Resolution_Order_7 = new Array();
var LPDaac_Category_Resolution_Order_8 = new Array();
var LPDaac_Category_Resolution_Order_9 = new Array();
var LPDaac_Category_Resolution_Order_10 = new Array();
var LPDaac_Category_Resolution_Order_11 = new Array();
var LPDaac_Category_Resolution_Order_12 = new Array();
var LPDaac_Category_Resolution_Order_13 = new Array();



var LPDaac_Category_Date_Order_1 = new Array();
var LPDaac_Category_Date_Order_2 = new Array();
//Default Categories in order are:

/*
LPDaac_Category_Order6[0] = "Aft";
LPDaac_Category_Order6[1] = "Forward";
LPDaac_Category_Order6[2] = "Carto";


LPDaac_Category_ID6[0] = "Aft";
LPDaac_Category_ID6[1] = "Forward";
LPDaac_Category_ID6[2] = "Carto";

LPDaac_Category_Camera_Order6[0] = "1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972";
LPDaac_Category_Camera_Order6[1] = "1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972";
LPDaac_Category_Camera_Order6[2] = "1962,1963,1964";


//Resolutions for Aft
LPDaac_Category_Resolution_Order_0[0] = "medium";
LPDaac_Category_Resolution_Order_0[1] = "medium";
LPDaac_Category_Resolution_Order_0[2] = "medium";
LPDaac_Category_Resolution_Order_0[3] = "medium";
LPDaac_Category_Resolution_Order_0[4] = "medium";
LPDaac_Category_Resolution_Order_0[5] = "medium,High";
LPDaac_Category_Resolution_Order_0[6] = "medium,High";
LPDaac_Category_Resolution_Order_0[7] = "medium,High";
LPDaac_Category_Resolution_Order_0[8] = "High";
LPDaac_Category_Resolution_Order_0[9] = "High";
LPDaac_Category_Resolution_Order_0[10] = "High";

//for Forward
LPDaac_Category_Resolution_Order_1[0] = "medium";
LPDaac_Category_Resolution_Order_1[1] = "medium";
LPDaac_Category_Resolution_Order_1[2] = "medium";
LPDaac_Category_Resolution_Order_1[3] = "medium";
LPDaac_Category_Resolution_Order_1[4] = "medium";
LPDaac_Category_Resolution_Order_1[5] = "medium,High";
LPDaac_Category_Resolution_Order_1[6] = "medium,High";
LPDaac_Category_Resolution_Order_1[7] = "medium,High";
LPDaac_Category_Resolution_Order_1[8] = "High";
LPDaac_Category_Resolution_Order_1[9] = "High";
LPDaac_Category_Resolution_Order_1[10] = "High";

//for FCC 
LPDaac_Category_Resolution_Order_2[0] = "Low";
LPDaac_Category_Resolution_Order_2[1] = "Low";
LPDaac_Category_Resolution_Order_2[2] = "Low";
*/

LPDaac_Category_Order6[0] = "1962";
LPDaac_Category_Order6[1] = "1963";
LPDaac_Category_Order6[2] = "1964";
LPDaac_Category_Order6[3] = "1965";
LPDaac_Category_Order6[4] = "1966";
LPDaac_Category_Order6[5] = "1967";
LPDaac_Category_Order6[6] = "1968";
LPDaac_Category_Order6[7] = "1969";
LPDaac_Category_Order6[8] = "1970";
LPDaac_Category_Order6[9] = "1971";
LPDaac_Category_Order6[10] = "1972";


LPDaac_Category_ID6[0] = "1962";
LPDaac_Category_ID6[1] = "1963";
LPDaac_Category_ID6[2] = "1964";
LPDaac_Category_ID6[3] = "1965";
LPDaac_Category_ID6[4] = "1966";
LPDaac_Category_ID6[5] = "1967";
LPDaac_Category_ID6[6] = "1968";
LPDaac_Category_ID6[7] = "1969";
LPDaac_Category_ID6[8] = "1970";
LPDaac_Category_ID6[9] = "1971";
LPDaac_Category_ID6[10] = "1972";

LPDaac_Category_Camera_Order6[0] = "aft,for,Carto";
LPDaac_Category_Camera_Order6[1] = "aft,for,Carto";
LPDaac_Category_Camera_Order6[2] = "aft,for,Carto";
LPDaac_Category_Camera_Order6[3] = "aft,for";
LPDaac_Category_Camera_Order6[4] = "aft,for";
LPDaac_Category_Camera_Order6[5] = "aft,for";
LPDaac_Category_Camera_Order6[6] = "aft,for";
LPDaac_Category_Camera_Order6[7] = "aft,for";
LPDaac_Category_Camera_Order6[8] = "aft,for";
LPDaac_Category_Camera_Order6[9] = "aft,for";
LPDaac_Category_Camera_Order6[10] = "aft,for";


//Resolutions for 1962
LPDaac_Category_Resolution_Order_0[0] = "medium";
LPDaac_Category_Resolution_Order_0[1] = "medium";
LPDaac_Category_Resolution_Order_0[2] = "low";

//for 1963
LPDaac_Category_Resolution_Order_1[0] = "medium";
LPDaac_Category_Resolution_Order_1[1] = "medium";
LPDaac_Category_Resolution_Order_1[2] = "low";

//for 1964
LPDaac_Category_Resolution_Order_2[0] = "medium";
LPDaac_Category_Resolution_Order_2[1] = "medium";
LPDaac_Category_Resolution_Order_2[2] = "low";

//for 1965
LPDaac_Category_Resolution_Order_3[0] = "medium";
LPDaac_Category_Resolution_Order_3[1] = "medium";

//for 1966
LPDaac_Category_Resolution_Order_4[0] = "medium";
LPDaac_Category_Resolution_Order_4[1] = "medium";

//for 1967
LPDaac_Category_Resolution_Order_5[0] = "medium,high";
LPDaac_Category_Resolution_Order_5[1] = "medium,high";

//for 1968
LPDaac_Category_Resolution_Order_6[0] = "medium,high";
LPDaac_Category_Resolution_Order_6[1] = "medium,high";

//for 1969
LPDaac_Category_Resolution_Order_7[0] = "medium,high";
LPDaac_Category_Resolution_Order_7[1] = "medium,high";

//for 1970
LPDaac_Category_Resolution_Order_8[0] = "high";
LPDaac_Category_Resolution_Order_8[1] = "high";

//for 1971
LPDaac_Category_Resolution_Order_9[0] = "high";
LPDaac_Category_Resolution_Order_9[1] = "high";

//for 1972
LPDaac_Category_Resolution_Order_10[0] = "high";
LPDaac_Category_Resolution_Order_10[1] = "high";



//for ETM
var LPDaac_Category_Order8 = new Array();
var LPDaac_Category_ID8 = new Array();
var LPDaac_Category_Year_Order8 = new Array();

//Default Categories in order are:

LPDaac_Category_Order8[0] = "2003";
LPDaac_Category_Order8[1] = "2002";
LPDaac_Category_Order8[2] = "2001";
LPDaac_Category_Order8[3] = "2000";
LPDaac_Category_Order8[4] = "1999";

//
LPDaac_Category_ID8[0] = "2003";
LPDaac_Category_ID8[1] = "2002";
LPDaac_Category_ID8[2] = "2001";
LPDaac_Category_ID8[3] = "2000";
LPDaac_Category_ID8[4] = "1999";


//Years available per band
//LPDaac_Category_Year_Order8[0]  = "Full Year,Winter,Spring,Fall";       //ming 9/5/06
LPDaac_Category_Year_Order8[0]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order8[1]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order8[2]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order8[3]  = "Full Year,Winter,Spring,Summer,Fall";
LPDaac_Category_Year_Order8[4]  = "Full Year,Summer,Fall";

//for ETM
var LPDaac_Category_Order9 = new Array();
var LPDaac_Category_ID9 = new Array();
var LPDaac_Category_Year_Order9 = new Array();

//Default Categories in order are:

LPDaac_Category_Order9[0] = "2004";
LPDaac_Category_Order9[1] = "2003";
LPDaac_Category_Order9[2] = "2002";
LPDaac_Category_Order9[3] = "2001";
LPDaac_Category_Order9[4] = "2000";
LPDaac_Category_Order9[5] = "1999";


//
LPDaac_Category_ID9[0] = "2004";
LPDaac_Category_ID9[1] = "2003";
LPDaac_Category_ID9[2] = "2002";
LPDaac_Category_ID9[3] = "2001";
LPDaac_Category_ID9[4] = "2000";
LPDaac_Category_ID9[5] = "1999";


//Years available per band
LPDaac_Category_Year_Order9[0]  = "Fall,Spring,Summer,Winter";
LPDaac_Category_Year_Order9[1]  = "Fall,Spring,Summer,Winter";
LPDaac_Category_Year_Order9[2]  = "Fall,Spring,Summer,Winter";
LPDaac_Category_Year_Order9[3]  = "Fall,Spring,Summer,Winter";
LPDaac_Category_Year_Order9[4]  = "Fall,Spring,Summer,Winter";
LPDaac_Category_Year_Order9[5]  = "Fall";

var LPDaac_Category_Order10 = new Array();
var LPDaac_Category_ID10 = new Array();
var LPDaac_Category_Year_Order10 = new Array();

//Default Categories in order are:

LPDaac_Category_Order10[0] = "2005";
LPDaac_Category_Order10[1] = "2004";
LPDaac_Category_Order10[2] = "2003";
LPDaac_Category_Order10[3] = "2002";

//
LPDaac_Category_ID10[0] = "2005";
LPDaac_Category_ID10[1] = "2004";
LPDaac_Category_ID10[2] = "2003";
LPDaac_Category_ID10[3] = "2002";

//Years available per band
LPDaac_Category_Year_Order10[0]  = "Spring,Summer,Winter";
LPDaac_Category_Year_Order10[1]  = "Fall,Spring,Summer,Winter";
LPDaac_Category_Year_Order10[2]  = "Fall,Spring,Summer,Winter";
LPDaac_Category_Year_Order10[3]  = "Fall,Spring,Summer,Winter";



//*****************************************************************************
// Function IVM_Keyword_check
// This will search a string for keywords from the IVM_Keyword_Array and returns
// the index of the LAST one that is within the string to check
//*****************************************************************************
function IVM_Keyword_check(string2check) {
//alert("IVM_Keyword_check");
  var tempCheck = -1;
  var j=0;
  var TempArray = new Array();
  for (var i=0; i<IndexedOriginalName.length; i++) {
    if (IndexedOriginalName[i].indexOf(",")>0) {
      //Must cycle through the list of ID's and see if there are any matches
      TempArray = IndexedOriginalName[i].split(",");
      for (j=0; j<TempArray.length; j++) {
        if (string2check==TempArray[j]) {
          tempCheck = i;
        }
      }
    } else {
      //Simple keyword check, just return the index value
      if (string2check==IndexedOriginalName[i]) {
        tempCheck = i;
      }
    }
  }
  return tempCheck;
}

//*****************************************************************************
// Function IVM_Init_Selected_Layer
// Cycle through Layer list and set the IVM Layer to top-most visible Layer...
// NOTE:  Top-most layer is actually the last one in the layer array...
// Uses IVM_Keyword_Array to tell if a layer is part of IVM Interface
// Add the line below to the BeforeMapRefresh function in the MapFrame.htm to setup the initial settings.
// if (IVM_Selected_Layer_Name[0]=='[start]') IVM_Init_Selected_Layer();
//*****************************************************************************
function IVM_Init_Selected_Layer() {
  if (Display_Only_OGC) {
    IVM_OGC_Init_Selected_Layer();
  } else {
    for (var j=0; j<IVM_Keyword_Array.length; j++) {
      //First set the control variables to initial values
      IVM_Selected_Layer_Name[j] = IVM_Keyword_Name[j];
	       IVM_Selected_Layer_SubSelect[j] = '[Not Selected]';
      IVM_Selected_Layer_Transparency[j] = '0.5';
      IVM_Selected_Layer_Displayed[j] = false;
    }
    var Temp_Keyword = -1;
    //Handle the regular ArcIMS layers
    if (layerCount>0) {
      //Cycle through the Layer List
      for (var i=0; i<layerCount; i++) {
        Temp_Keyword = IVM_Keyword_check(LayerID[i]);
        if (Temp_Keyword>-1) {
          if (IVM_Keyword_Type[Temp_Keyword]=="Single") {
            if (LayerVisible[i]) {
              //Set the IVM_Selected_Layer_ID to the current layer ID
              IVM_Selected_Layer_ID[Temp_Keyword] = LayerID[i];
              if (IVM_Selected_Layer_SubSelect[Temp_Keyword]=='[Not Selected]' || IVM_Selected_Layer_SubSelect[Temp_Keyword] == undefined) {
                if (LayerName[i].indexOf('-')>0) {
                  Temp_Array3 = LayerName[i].split('-');
                  IVM_Selected_Layer_Name[Temp_Keyword] = Temp_Array3[0];
                  IVM_Selected_Layer_SubSelect[Temp_Keyword] = Temp_Array3[1];
                } else {
                  IVM_Selected_Layer_Name[Temp_Keyword] = LayerName[i];
                  IVM_Selected_Layer_SubSelect[Temp_Keyword] = '';
                }
              }
            }
          } else {
            //Set the IVM_Selected_Layer_ID to the current layer Visibility
            IVM_Selected_Layer_ID[Temp_Keyword] = LayerVisible[i];
          }
            //alert('Undefined!!! - ' + LayerID[i] + ' - ' + Temp_Keyword + ' - ' + IVM_Selected_Layer_SubSelect[Temp_Keyword] + ' - ' + LayerName[i]);
          if (IVM_Selected_Layer_SubSelect[Temp_Keyword] == undefined) {
            IVM_Selected_Layer_SubSelect[Temp_Keyword] = '[Not Selected]';
          }
        }
      }
    }
  }
  IVM_Initialized = true;
}

//*****************************************************************************
// Function IVM_Update_Layer
// Cycle through Layer list and set visibility to false of all IVM layers that do not match selected...
// Uses IVM_Keyword_Array to tell if a layer is part of IVM Interface
// This should be called by the BeforeMapRefresh in the MapFrame.htm to update layer visibility before the map is drawn
//*****************************************************************************
function IVM_Update_Layer() {
  if (Display_Only_OGC) {
    IVM_OGC_Update_Layer();
  } else {
    var Temp_Keyword = -1;
    if (layerCount>0) {
      for (var i=0; i<layerCount; i++) {
        Temp_Keyword = IVM_Keyword_check(LayerID[i]);
        if (Temp_Keyword>-1) {
          //Set the layer visibility based upon the Type
          if (IVM_Keyword_Type[Temp_Keyword]=="Single") {
            //alert(LayerID[i] + "==" + IVM_Selected_Layer_ID[Temp_Keyword]);
            if ( LayerID[i]==IVM_Selected_Layer_ID[Temp_Keyword] ) {
             LayerVisible[i]=true;
            } else {
             LayerVisible[i]=false;
            }
          } else {
            LayerVisible[i]=IVM_Selected_Layer_ID[Temp_Keyword];
          }
        }
      }
    }
  }
}


//*****************************************************************************
// Function IVM_Change_OGC_Layer_DAAC
// Used by the change Layer prompt to set the new layer to display
// Get Band, Year and Date string 
//*****************************************************************************
function IVM_Change_OGC_Layer_CORONA(band, year, date, Temp_Index) {
  var DAAC_String = "";

  //Cycle through the Categories from the Category_Order array
 for (var i=Category_Order.length-1;i>=0;i--) {
   if (Category_Layer_Order[i].length>0) {

      //For each category, get the Layer_Order and split into some temp arrays.
      TempArray = Category_Layer_Order[i].split(',');
      TempArray2 = Category_Layer_Visibility[i].split(',');
      //Cycle through the layers for this current category in Layer_Order
      for (var j=TempArray.length-1;j>=0;j--) {
        if (IVM_Keyword_check(SRC_Layer_Name[TempArray[j]]) == Temp_Index) {
		TempArray3 = IndexedDisplayNames[Temp_Index].split('|');
		TempArray4 = IndexedWMSLayers[Temp_Index].split('|');
		TempArray5 = IndexedWMSServices[Temp_Index].split('|');

		//cycle through IndexedDisplayNames 
		for(var k=0; k<TempArray3.length; k++) {
	   		if (TempArray3[k].indexOf(band)>-1 && TempArray3[k].indexOf(year)>-1 && TempArray3[k].indexOf(date)>-1) { 
		 		DAAC_String = IndexedOriginalName[Temp_Index] + "|" +  band + " " + year + " " + date + "|" + TempArray3[k] + "|" + TempArray4[k] + '|' + TempArray5[k] + '|' + 'true';
		 		break;
			}else{
				DAAC_String = IndexedOriginalName[Temp_Index] + "|" + "[Not Selected]";
			}
		}
        }
      }		
    }
  }
		 
  IVM_Change_OGC_Layer2(Temp_Index, DAAC_String);  
}


//*****************************************************************************
// Function IVM_Change_Layer
// Present a list of layers (actually just a SubSelect) matching a keyword index passed in
// This should only be used for "Single" type groupings.  It is called from a button or Checkbox
// in the TOC entry for the grouped layers.
//*****************************************************************************
function IVM_Change_Layer(Keyword_Index) {

  var WindowContent='';
  var ChooserString = 'document.IVMChooser.IVMChooser.value';
	var theFrame = "parent.MapFrame";
  theFrame = "opener";
  if (parent.MapFrame!=null) { theFrame = "opener.parent.MapFrame"; }
  if (isNav4) { ChooserString = 'document.IVMChooser.IVMChooser[document.IVMChooser.IVMChooser.selectedIndex].value'; }
  WindowContent += '<form name="IVMChooser" onsubmit="return false;">';
  WindowContent += '<strong>Layer to Display:</strong><br />';
  WindowContent += '<select name="IVMChooser" onchange="' + theFrame + '.IVM_Change_Layer2(' + Keyword_Index + ',' + ChooserString + ');window.close();">';
  WindowContent += '<option value = "[none]- - ">Select a layer to display</option>';
  WindowContent += '<option value = "' + IVM_Keyword_Name[Keyword_Index] + '- [Not Selected] - ">None</option>';
  if (layerCount>0) {
    for (var i=0; i<layerCount; i++) {
      if (IVM_Keyword_check(LayerID[i])==Keyword_Index) {
        if (Get_Display_LayerName(LayerName[i]).indexOf('-')>0) {
          WindowContent += '<option value = "' + Get_Display_LayerName(LayerName[i]) + '-' + LayerID[i] + '">' + Get_Display_LayerName(LayerName[i]) + '</option>';
        } else {
          WindowContent += '<option value = "' + Get_Display_LayerName(LayerName[i]) + '- -' + LayerID[i] + '">' + Get_Display_LayerName(LayerName[i]) + '</option>';
        }
      }
    }
  }
  WindowContent += '</select>';
  WindowContent += '</form>';
  WindowContent += '<small>Choosing a new IVM layer will turn off all other IVM layers.  Only one may be viewed at a time.</small>';
  Create_Pop_Up_Window('IVM Layer to Display', '', WindowContent, 'IVMChooserWindow', 'width=375,height=180,scrollbars=no,resizable=yes');
}

//*****************************************************************************
// Function IVM_Change_Layer2
// Used by the change Layer prompt to set the new layer to display
//*****************************************************************************
function IVM_Change_Layer2(Keyword_Index, IVMString) {
  var Temp_Array = IVMString.split('-');
  //Code added just for IVM, to ensure only one IVM layer is displayed at a time
  //Even though multiple entries are on the TOC
  for (var i=0; i<5; i++) {
    IVM_Selected_Layer_Name[i] = IVM_Keyword_Name[i];
    IVM_Selected_Layer_SubSelect[i] = '[Not Selected]';
    IVM_Selected_Layer_ID[i] = false;
  }

  IVM_Selected_Layer_Name[Keyword_Index] = Temp_Array[0];
  if (Temp_Array[2]=="false") {
    IVM_Selected_Layer_ID[Keyword_Index] = false;
  } else if (Temp_Array[2]=="true") {
    IVM_Selected_Layer_ID[Keyword_Index] = true;
  } else {
    IVM_Selected_Layer_ID[Keyword_Index] = Temp_Array[2];
  }
  IVM_Selected_Layer_SubSelect[Keyword_Index] = Temp_Array[1];
  refreshMap();
  parent.TOCFrame.location="toc.htm";
}

//*****************************************************************************
// Function IVM_Reset_Display
// Reset the IVM Display variable so the TOC will work - only displaying one TOC Entry of each keyword...
// This also updates any layers using the "Multiple" Grouping type to display the 
// Top-Most Layer name
//*****************************************************************************
function IVM_Reset_Display() {
  for (var j=0; j<IVM_Keyword_Array.length; j++) {
    IVM_Selected_Layer_Displayed[j] = false;
  }

  var Temp_Keyword = -1;
  if (layerCount>0) {
    for (var i=0; i<layerCount; i++) {
      Temp_Keyword = IVM_Keyword_check(LayerID[i]);
      if (Temp_Keyword>-1) {
        //Set the layer visibility based upon the Type
        if (IVM_Keyword_Type[Temp_Keyword]=="Multiple") {
          IVM_Selected_Layer_Name[Temp_Keyword] = LayerName[i];
          IVM_Selected_Layer_ID[Temp_Keyword] = LayerVisible[i];
          IVM_Selected_Layer_SubSelect[Temp_Keyword] = ' ';
        }
      }
    }
  }

}

//*****************************************************************************
// Function IVM_Display_Layer
// Display a single entry in the TOC for a keyword layer
//*****************************************************************************
function IVM_Display_Layer(Keyword_Index, Source_Name) {
  if (!Boolean(Source_Name)) { Source_Name=" "; }
  if (IVM_Selected_Layer_SubSelect[Keyword_Index] == undefined) {
    //IVM_Selected_Layer_SubSelect[Temp_Keyword] == '[Not Selected]';
    IVM_Init_Selected_Layer();
  }
  var TempString = '';
  if (!IVM_Selected_Layer_Displayed[Keyword_Index]) {
    IVM_Selected_Layer_Displayed[Keyword_Index]=true;
    if (IVM_Keyword_Type[Keyword_Index]=="Single") {
      if (IVM_Selected_Layer_SubSelect[Keyword_Index].indexOf('Not Selected')!=-1) {
        TempString += ('<tr><td align="center"><input type="Button" style="font-size: 6pt; padding: 0px; border-style: inset;" name="GroupButton' + Keyword_Index + '" value=" O " onclick="parent.MapFrame.IVM_Change_Layer(' + Keyword_Index + ');" /></td>');
      } else {
        TempString += ('<tr><td align="center"><input type="Button" style="font-size: 6pt; padding: 0px;" name="GroupButton' + Keyword_Index + '" value=" X " onclick="parent.MapFrame.IVM_Change_Layer(' + Keyword_Index + ');" /></td>');
      }
    } else {
      if (IVM_Selected_Layer_ID[Keyword_Index]==true) { 
        TempString += ('<tr><td><input type="checkbox" name="GroupCheck' + Keyword_Index + '" checked="checked" onclick="parent.MapFrame.IVM_Selected_Layer_ID[' + Keyword_Index + ']=!parent.MapFrame.IVM_Selected_Layer_ID[' + Keyword_Index + '];" /></td>');
      } else {
        TempString += ('<tr><td><input type="checkbox" name="GroupCheck' + Keyword_Index + '" onclick="parent.MapFrame.IVM_Selected_Layer_ID[' + Keyword_Index + ']=!parent.MapFrame.IVM_Selected_Layer_ID[' + Keyword_Index + '];" /></td>');
      }
    }
    TempString += ('<td>&nbsp;</td>');
    //if the keyword name is empty try to get the layername that should have been passed in.
    if (IVM_Keyword_Name[Keyword_Index]!="") {
      TempNameString = Get_Display_LayerName(IVM_Selected_Layer_Name[Keyword_Index]);
    } else {
      if (Source_Name.length>2) {
        TempNameString = Source_Name;
      } else {
        TempNameString = "Error Getting Layername";
      }
    }
    if (IVM_Keyword_URLS[Keyword_Index].length>0) {
      TempString += ('<td><a href="' + IVM_Keyword_URLS[Keyword_Index] + '" target="_blank" title="Link to Documentation on ' + IVM_Keyword_Name[Keyword_Index] + '">' + TempNameString);
      if (IVM_Selected_Layer_SubSelect[Keyword_Index]!='[Not Selected]') {
        if (IVM_Selected_Layer_SubSelect[Keyword_Index]!='') { TempString += ' - ' + IVM_Selected_Layer_SubSelect[Keyword_Index]; }
      }
      TempString += ('</a></td>');
    } else {
      TempString += ('<td>' + TempNameString);
      if (IVM_Selected_Layer_SubSelect[Keyword_Index]!='[Not Selected]') {
        if (IVM_Selected_Layer_SubSelect[Keyword_Index]!='') { TempString += ' - ' + IVM_Selected_Layer_SubSelect[Keyword_Index]; }
      }
      TempString += ('</td>');
    }
    TempString += ('</tr>');
  }
  return TempString;
}

//*****************************************************************************
// Function IVM_Get_Layer_For_Display
// This returns the Group layer name for a layer, mainly used by things like the
// Extraction display that needs to list all the layers individually, but needs
// to match those to the displayed name in the TOC.
//*****************************************************************************
function IVM_Get_Layer_For_Display(Keyword_Index) {
  var TempString = '';
  TempString += Get_Display_LayerName(IVM_Selected_Layer_Name[Keyword_Index]);
  if (IVM_Selected_Layer_SubSelect[Keyword_Index]!='[Not Selected]') {
    if (IVM_Selected_Layer_SubSelect[Keyword_Index]!='') { TempString += ' - ' + IVM_Selected_Layer_SubSelect[Keyword_Index]; }
  }
  return TempString;
}

//*****************************************************************************
// Function IVM_OGC_Init_Selected_Layer
// Cycle through OGC Layer list and set the IVM Layer to top-most visible Layer...
// NOTE:  Top-most layer is actually the last one in the layer array...
// Uses IVM_Keyword_Array to tell if a layer is part of IVM Interface
//*****************************************************************************
function IVM_OGC_Init_Selected_Layer() {
  for (var k=0; k<IVM_Keyword_Array.length; k++) {
    //First set the control variables to initial values
    IVM_Selected_Layer_Name[k] = IVM_Keyword_Name[k];
    IVM_Selected_Layer_SubSelect[k] = '[Not Selected]';
    //IVM_Selected_Layer_Transparency[k] = '0.5';
    IVM_Selected_Layer_Displayed[k] = false;
  }
  var Temp_Keyword = -1;
  //Cycle through the Categories from the Category_Order array
	for (var i=Category_Order.length-1;i>=0;i--) {
    if (Category_Layer_Order[i].length>0) {
      //For each category, get the Layer_Order and Layer_Visibility and split into some temp arrays.
      TempArray = Category_Layer_Order[i].split(',');
      TempArray2 = Category_Layer_Visibility[i].split(',');
      //Cycle through the layers for this current category in Layer_Order
	    for (var j=TempArray.length-1;j>=0;j--) {
        Temp_Keyword = IVM_Keyword_check(SRC_Layer_Name[TempArray[j]]);
        if (Temp_Keyword>-1) {
          if (IVM_Keyword_Type[Temp_Keyword]=="Single") {
            if (TempArray2[j]=='true') {                                               
              if (IVM_Selected_Layer_SubSelect[Temp_Keyword]=='[Not Selected]') {
                //Set the IVM_Selected_Layer_ID to the current layer ID
                IVM_Selected_Layer_ID[Temp_Keyword] = TempArray[j];

                if (SRC_Layer_Name[TempArray[j]].indexOf('-')) {
                  Temp_Array3 = SRC_Layer_Name[TempArray[j]].split('-');
                  IVM_Selected_Layer_Name[Temp_Keyword] = Temp_Array3[0];
                  IVM_Selected_Layer_SubSelect[Temp_Keyword] = Temp_Array3[1];
                } else {
                  IVM_Selected_Layer_Name[Temp_Keyword] = SRC_Layer_Name[TempArray[j]];
                  IVM_Selected_Layer_SubSelect[Temp_Keyword] = SRC_Layer_Name[TempArray[j]];       
                }
              }
            }
          } else {
            //Set the IVM_Selected_Layer_ID to the current layer Visibility
            IVM_Selected_Layer_ID[Temp_Keyword] = TempArray2[j];
          }  //end if single
        }
      }
    }
  }
  IVM_Initialized = true;
}

//*****************************************************************************
// Function IVM_OGC_Update_Layer
// Cycle through OGC Layer list and set visibility to false of all IVM layers that do not match selected...
// Uses IVM_Keyword_Array to tell if a layer is part of IVM Interface
//*****************************************************************************
function IVM_OGC_Update_Layer() {
  var Change_Category = false;
  var Temp_Keyword = -1;
  var SRC_Layer_URL_FirstPart = '';
  var SRC_Layer_URL_LastPart = '';
  var pos=-1;
  var pos2=-1;

  //Cycle through the Categories from the Category_Order array
	for (var i=Category_Order.length-1;i>=0;i--) {
    if (Category_Layer_Order[i].length>0) {
      Change_Category = false;
      //For each category, get the Layer_Order and Layer_Visibility and split into some temp arrays.
      TempArray = Category_Layer_Order[i].split(',');
      TempArray2 = Category_Layer_Visibility[i].split(',');
      //Cycle through the layers for this current category in Layer_Order
	    for (var j=TempArray.length-1;j>=0;j--) {
        Temp_Keyword = IVM_Keyword_check(SRC_Layer_Name[TempArray[j]]);
        if (Temp_Keyword>-1) {
          //Set the layer visibility based upon the Type
//          if (IVM_Keyword_Type[Temp_Keyword]=="Single") {                 //ming commented it for ceos (display multiple layers at once)
	    if(IVM_Selected_Layer_SubSelect[Temp_Keyword] !== "[Not Selected]" || IVM_Selected_Layer_SubSelect[Temp_Keyword] !== undefined){
	    //alert(TempArray[j] + j + TempArray2[j]);

	      if (SRC_Layer_Name[TempArray[j]].indexOf(IVM_IndexedWMSOriginalName[Temp_Keyword])>-1) {  
		TempArray3 = IndexedDisplayNames[Temp_Keyword].split('|');
		TempArray4 = IndexedWMSLayers[Temp_Keyword].split('|');
		TempArray5 = IndexedWMSServices[Temp_Keyword].split('|');
		
		for(var k=0; k<TempArray3.length; k++) {
	      		if (TempArray3[k].indexOf(IVM_IndexedWMSDisplayNames[Temp_Keyword])>-1 && IVM_Selected_Layer_ID[Temp_Keyword] == true) {
			//alert(IVM_IndexedWMSDisplayNames[Temp_Keyword]);
			//prompt('', SRC_Layer_URL[TempArray[j]]);

			    //change WMS Layer and WMS Service
			    if (SRC_Layer_URL[TempArray[j]]!="") {
				var urlstring = SRC_Layer_URL[TempArray[j]].toUpperCase();
        			pos = urlstring.indexOf("&LAYERS=");
        			pos2 = urlstring.indexOf("&SERVICENAME=");
			    }

    			    if (pos!=-1) {
    				startpos = pos + 8;
    				endpos = urlstring.indexOf("&",startpos);
    				if (endpos==-1) { endpos = urlstring.length; }
    				SRC_Layer_URL_FirstPart = unescape(SRC_Layer_URL[TempArray[j]].substring(0,startpos));
    				SRC_Layer_URL_LastPart = unescape(SRC_Layer_URL[TempArray[j]].substring(endpos,urlstring.length));
				SRC_Layer_URL[TempArray[j]]= SRC_Layer_URL_FirstPart + IVM_IndexedWMSLayers[Temp_Keyword] + SRC_Layer_URL_LastPart;
				//prompt("", SRC_Layer_URL[TempArray[j]]);
    			    }  else {
        			SRC_Layer_URL[TempArray[j]] = ""
     			    }
			    if(IVM_IndexedWMSServices[Temp_Keyword] != ''){
 			        if (pos2!=-1) {
    					startpos2 = pos2 + 13;
    					endpos2 = urlstring.indexOf("&",startpos2);
    					if (endpos2==-1) { endpos2 = urlstring.length; }
    					SRC_Layer_URL_Temp = unescape(SRC_Layer_URL[TempArray[j]].substring(0,startpos2));

					SRC_Layer_URL[TempArray[j]]= SRC_Layer_URL_Temp + IVM_IndexedWMSServices[Temp_Keyword];
					
    			        }  else {
        				SRC_Layer_URL[TempArray[j]] = ""
      			        }
			    }			   
			    
			    //change the layer's visibility
                	    TempArray2[j]='true';
			    //Added the following line is for layer identify (CEOS)                    //ming
			    parent.MapFrame.SRC_Layer_IDLayers[TempArray[j]] = TempArray4[k];  //"CEOS.mss1yr83"

			    break;

	      		}else{
                	    TempArray2[j]='false';
	      		}
		}//end for loop
	      }
	        Change_Category = true;    
            }
         /* } else {                                                                  //ming comment it for ceos (display multiple layers at once)
	 
	 
		if (TempArray2[j]!=IVM_Selected_Layer_ID[Temp_Keyword]) {
			TempArray2[j]=IVM_Selected_Layer_ID[Temp_Keyword];
			Change_Category = true;
		}
	    
	  */  
	    
	    
//          }//end if single
	  


        }//end if (Temp_Keyword>-1)
      }
      if (Change_Category) {
        Category_Layer_Visibility[i]=TempArray2.join();
        parent.TOCFrame.location="toc.htm";    								
      }
    }
  }

}

//*****************************************************************************
// Function IVM_Change_OGC_Layer
// Change the IVM visibility entry for the OGC layer and then refresh the 
// map images.
//*****************************************************************************
function IVM_Change_OGC_Layer(LayerID) {
  var Temp_Keyword = -1;
  Temp_Keyword = IVM_Keyword_check(SRC_Layer_Name[LayerID]);
  if (Temp_Keyword>-1) {
    if (IVM_Keyword_Type[Temp_Keyword]=="Single") {
      if (IVM_Selected_Layer_ID[Temp_Keyword]=='true') {IVM_Selected_Layer_ID[Temp_Keyword] = 'false'; } else {IVM_Selected_Layer_ID[Temp_Keyword] = 'true'; }
    } else {
      if (IVM_Selected_Layer_ID[Temp_Keyword]=='true') { IVM_Selected_Layer_ID[Temp_Keyword] = 'false'; } else { IVM_Selected_Layer_ID[Temp_Keyword] = 'true'; }
    }
    afterMapRefresh();
    //parent.TOCFrame.location="toc.htm";
  }
}

//*****************************************************************************
// Function IVM_OGC_Reset_Display
// Reset the IVM Display variable so the TOC will work - only displaying one TOC Entry of each keyword...
// This also updates any layers using the "Multiple" Grouping type to display the 
// Top-Most Layer name
//*****************************************************************************
function IVM_OGC_Reset_Display() {
  for (var j=0; j<IVM_Keyword_Array.length; j++) {
    IVM_Selected_Layer_Displayed[j] = false;
  }
}

//*****************************************************************************
// Function Get_Display_LayerName
// This compares the layer name to an array of layer names and will change 
// to a corresponding display layer if it finds a match.  This allows for 
// a client-side renaming of layers, IE group layers, but with the Map Service
// still having unique layers.
//*****************************************************************************
function Get_Display_LayerName(OriginalLayername) {
  var LocalString = OriginalLayername;

  for (var i=0;i<Original_Display_Layername.length;i++) { 

    if (OriginalLayername == Original_Display_Layername[i]) {

      LocalString = Alt_Display_Layername[i];

    }
  }
  return LocalString;
}

//*****************************************************************************
// Function setLPDAAC
// This function is to open the file lpdaac.asp
//*****************************************************************************
function setLPDAAC(Keyword_Index) {
    parent.TOCFrame.location="toc.htm";
    var Win1;
    var LPDaacURL= "http://" + hostName + appDir + "lpdaac.asp?Temp_Index=" + Keyword_Index;
    Win1=window.open(LPDaacURL,"LPDaacWindow","width=800,height=500,scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes");
    Win1.focus();
}

function setCORONA(Keyword_Index) {
    parent.TOCFrame.location="toc.htm";
    var Win1;
    var CORONAURL= "http://" + hostName + appDir + "lpdaac_corona.asp?Temp_Index=" + Keyword_Index;
    Win1=window.open(CORONAURL,"LPDaacWindow","width=800,height=500,scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes");
    Win1.focus();
}


//*****************************************************************************
// Function setLPDAAC
// This function is to open the file lpdaac.asp
//*****************************************************************************


//*****************************************************************************
// Function IVM_Change_OGC_Layer2
// Used by the change Layer prompt to set the new layer to display
//*****************************************************************************
function IVM_Change_OGC_Layer2(Keyword_Index, IVMString) {
//alert(Keyword_Index + IVMString);
  var Temp_Array = IVMString.split('|');
  //Code added just for LPDaac, to ensure only one LPDaac layer is displayed at a time
  //Even though multiple entries are on the TOC
  if (IVM_Keyword_Type[Keyword_Index]=="Single") {
  for (var i=0; i<IndexedOriginalName.length; i++) {
    if (IVM_Keyword_Type[i]=="Single") {                                            //ming added it for ceos (display multiple layers at once)
	IVM_Selected_Layer_Name[i] = IVM_Keyword_Name[i];
	IVM_Selected_Layer_SubSelect[i] = '[Not Selected]';
	IVM_Selected_Layer_ID[i] = false;
    }
  }
  }
  
  IVM_IndexedWMSOriginalName[Keyword_Index] = Temp_Array[0];
  IVM_Selected_Layer_SubSelect[Keyword_Index] = Temp_Array[1];
  IVM_IndexedWMSDisplayNames[Keyword_Index] = Temp_Array[2];
  IVM_IndexedWMSLayers[Keyword_Index] = Temp_Array[3];
  IVM_IndexedWMSServices[Keyword_Index] = Temp_Array[4];

  if (Temp_Array[5]=="false") {
    IVM_Selected_Layer_ID[Keyword_Index] = false;
  } else if (Temp_Array[5]=="true") {
    IVM_Selected_Layer_ID[Keyword_Index] = true;
  } else {
    IVM_Selected_Layer_ID[Keyword_Index] = Temp_Array[5];
  }
  afterMapRefresh();
}

//*****************************************************************************
// Function IVM_Change_OGC_Layer_DAAC
// Used by the change Layer prompt to set the new layer to display
// Get Band, Year and Date string 
//*****************************************************************************
function IVM_Change_OGC_Layer_DAAC(Year, Season, Temp_Index) {
  var DAAC_String = "";
  var seasonVal = "";
  var indexLayers = "";
  var foundLayer = false;
  var yearVal = "";
  var yearSeasonVal = "";

//alert("year: " + Year + "  Season: " + Season);
//alert(IVM_Change_OGC_Layer_DAAC);
  //Cycle through the Categories from the Category_Order array

 for (var i=Category_Order.length-1;i>=0;i--) {
   if (Category_Layer_Order[i].length>0) {

      //For each category, get the Layer_Order and split into some temp arrays.
      TempArray = Category_Layer_Order[i].split(',');
      TempArray2 = Category_Layer_Visibility[i].split(',');

      //Cycle through the layers for this current category in Layer_Order
      for (var j=TempArray.length-1;j>=0;j--) {
//	alert("name: " + SRC_Layer_Name[TempArray[j]] + " Index: " + Temp_Index);


        if (IVM_Keyword_check(SRC_Layer_Name[TempArray[j]]) == Temp_Index) {
		TempArray3 = IndexedDisplayNames[Temp_Index].split('|');
		TempArray4 = IndexedWMSLayers[Temp_Index].split('|');
		TempArray5 = IndexedWMSServices[Temp_Index].split('|');
		TempArraySeason = Season.split('|');		//season array
		TempArrayYear = Year.split('|');			// year array
		
		DAAC_String = IndexedOriginalName[Temp_Index] + "|" + "[Not Selected]";
		//alert(DAAC_String);
		//cycle through IndexedDisplayNames 
		for(var k=0; k<TempArray3.length; k++) {
		    for(var m=0; m<TempArraySeason.length; m++) {
				//alert("for loop");
				for(var s=0; s<TempArrayYear.length; s++){
				//for(var L=0; L<TempArrayYear.lenght; L++){
	  //		if (TempArray3[k].indexOf(TempArrayYear[L])>-1 && TempArray3[k].indexOf(TempArraySeason[m])>-1) {
	   //		if (TempArray3[k].indexOf(Year)>-1 && TempArray3[k].indexOf(Season)>-1) {
					if (TempArray3[k].indexOf(TempArrayYear[s])>-1 && TempArray3[k].indexOf(TempArraySeason[m])>-1) {

		 		//DAAC_String = IndexedOriginalName[Temp_Index] + "|" + "CEO_91MSS2WTR " + Year + " " + Season + " |" + TempArray3[k] + "|" + TempArray4[k] + '|' + TempArray5[k] + '|' + 'true';
				//yearVal = yearVal + TempArrayYear[L];
				seasonVal = seasonVal + TempArraySeason[m];
				yearVal = yearVal + TempArrayYear[s];
				
				if (TempArrayYear.length == 1 && s==0 && m==TempArraySeason.length-1 ){
					yearSeasonVal = yearSeasonVal + TempArrayYear[s] + " " + TempArraySeason[m];
				}else {
					yearSeasonVal = yearSeasonVal + TempArrayYear[s] + " " + TempArraySeason[m] + ",     ";				
				}
				
				//alert("seasonVal: 2 " + seasonVal);
				//alert("Year: 2 " + yearVal);

				indexLayers = indexLayers + "," + TempArray4[k];
		 		//DAAC_String = IndexedOriginalName[Temp_Index] + "|" + "MSS2 Coverages " +  yearVal + " " + seasonVal + " |" + TempArray3[k] + "|" + indexLayers + '|' + TempArray5[k] + '|' + 'true';
		 		DAAC_String = IndexedOriginalName[Temp_Index] + "|" +  yearSeasonVal + " |" + TempArray3[k] + "|" + indexLayers + '|' + TempArray5[k] + '|' + 'true';
				
				
				//alert(DAAC_String);
		 		//break;
				foundLayer = true;
		 	
			//}else{
				//DAAC_String = IndexedOriginalName[Temp_Index] + "|" + "[Not Selected]";
				
			}

		    }//for m++
			} //for s++
		}
        }
      }		
    }
  }
  if (!foundLayer){
	DAAC_String = IndexedOriginalName[Temp_Index] + "|" + "[Not Selected]";
  }

//alert("	DAAC_String: " +DAAC_String);	 
  IVM_Change_OGC_Layer2(Temp_Index, DAAC_String);  
}

//*****************************************************************************
// Function setMODIS
// Present a list of layers (actually just a SubSelect) matching a keyword index passed in
// This should only be used for "Single" type groupings.  It is called from a button 
// in the TOC entry for the grouped layers.
//*****************************************************************************
function setMODIS(Keyword_Index) {
  parent.TOCFrame.location="toc.htm";
  var WindowContent='';
  var ChooserString = 'document.IVMChooser.IVMChooser.value';
  var theFrame = "parent.MapFrame";
  theFrame = "opener";
  if (parent.MapFrame !=null) {theFrame = "opener.parent.MapFrame"; }
  var Local_useExternalWindow = parent.MapFrame.useExternalWindow;
  parent.MapFrame.useExternalWindow= true;
  //if (isNav4) { ChooserString = 'document.IVMChooser.IVMChooser[document.IVMChooser.IVMChooser.selectedIndex].value'; }
  ChooserString = 'document.IVMChooser.IVMChooser[document.IVMChooser.IVMChooser.selectedIndex].value';
  WindowContent += '<form name="IVMChooser" onsubmit="return false;">';
  WindowContent += '<strong>Layer to Display:</strong><br />';
  WindowContent += '<select name="IVMChooser" onchange="' + theFrame + '.IVM_Change_OGC_Layer2(' + Keyword_Index + ',' + ChooserString + ');window.close();">';
  WindowContent += '<option value = "[none]- - ">Select a layer to display</option>';
  WindowContent += '<option value = "' + IndexedOriginalName[Keyword_Index] + '|[Not Selected]">None</option>';

  //Cycle through the Categories from the Category_Order array
 for (var i=0;i<Category_Order.length;i++) {
   if (Category_Layer_Order[i].length>0) {

      //For each category, get the Layer_Order and split into some temp arrays.
      TempArray = Category_Layer_Order[i].split(',');
      TempArray2 = Category_Layer_Visibility[i].split(',');
      //Cycle through the layers for this current category in Layer_Order
      for (var j=0;j<TempArray.length;j++) {
        if (IVM_Keyword_check(SRC_Layer_Name[TempArray[j]]) == Keyword_Index) {
		
		TempArray3 = IndexedDisplayNames[Keyword_Index].split('|');
		TempArray4 = IndexedWMSLayers[Keyword_Index].split('|');
		TempArray5 = IndexedWMSServices[Keyword_Index].split('|');

		//cycle through IndexedDisplayNames 
		for(var k=0; k<TempArray3.length; k++) {
		  WindowContent += '<option value = "' + IndexedOriginalName[Keyword_Index] + '|' + Get_Display_LayerName(TempArray3[k]) + '|' + TempArray3[k] + '|' + TempArray4[k] + '|' +TempArray5[k] + '|true' + '">' + Get_Display_LayerName(TempArray3[k]) + '</option>';
		}
        }
      }		
    }
  }

  WindowContent += '</select>';
  WindowContent += '</form>';
  WindowContent += '<small>Choose a new CEOS Coverage layer.  Only one may be viewed at a time.</small>';

  Create_Pop_Up_Window('CEOS Coverage Layer to Display', '', WindowContent, 'IVMChooserWindow', 'width=475,height=280,scrollbars=no,resizable=yes');
  parent.MapFrame.useExternalWindow = Local_useExternalWindow;
}
