  var sMsgId = "";
  

  function pArray(n)
  {
    this.length = n;
    for ( var i = 0 ; i < n ; i++)
    {
      this[i] = null;
    } 
    return this;
  }  
  
  function SetNamesSubmit(state_abr, fips, location)
  {
    var pForm = document.prefform;
    var nCount = 0
    var aMsgId2 = new Array(500);
    var indexOfMin = 0
    var temp 

//document.write("Starting 1<br>")


    if (fips != "")
    {
      for (var i = 0; i < aFips.length ; i++)
      {
        if (aFips[i] == fips || aFips[i].indexOf("ALL") != -1 )
        {
	  aMsgId2[nCount] =  aMsgId[i]         
          nCount += 1;
        }
      }

//document.write("Starting 2<br>")

	for ( var pass = 0; pass < nCount - 1; pass++ ) 
	{ 
           indexOfMin = pass; 

           for ( var j = pass + 1; j < nCount; j++ ) { 
               if ( aMsgId2[j] < aMsgId2[indexOfMin] ) {
                   indexOfMin = j
				}
			}

		     if (indexOfMin > pass) {      
				temp = aMsgId2[pass]                     
				aMsgId2[pass] = aMsgId2[indexOfMin]
				aMsgId2[indexOfMin] = temp
			}               	   
	} 

	for ( var k = 0; k < nCount; k++ ) {
	    sMsgId = aMsgId2[k] + "," + sMsgId
	}
      
      if (sMsgId != "") 
      {
        sMsgId = sMsgId.substring(0,sMsgId.length);
      }
    }
  
    pForm.state_abr.value = state_abr;
    pForm.fips.value = fips;
    pForm.location.value = location;
    pForm.msg_names.value = sMsgId;
    pForm.nmsgs.value = nCount;
    
    
    pForm.submit();
    //top.location.href=self.location.href;
	//top.location.href=location.hostname + location.pathname + "?cmd=<%=request("cmd")%>&state_abr=" + state_abr +"&fips=" + fips + "&location=" + location + "&msg_names=<%=request("msg_names")%>&nmsgs=<%=request("nmsgs")%>"
  }


  // Object
  function eGroup(n)
  {
    // data
    this.nId = new pArray(n);
    this.strName = new pArray(n);
    this.strColor = new pArray(n);
    this.strURL = new pArray(n);
    this.nLength = n;
    this.nCurrent = 0;
    
    // methods
    this.add = _Add;
    this.getColor = _GetColor;
    this.getName = _GetName;
    this.getURL = _GetURL;
  }

  // Methods
  function _Add(sId,sName,sColor, sURL)
  {
   if (this.nLength <= this.nCurrent)
     return false;
   
   
   this.nId[this.nCurrent] = sId;
   
   if (sId <= 0)
   {
    this.strName[this.nCurrent] = "<font color=\"#800000\">INVALID GROUP ID of " + sId + "</font>";
    this.strColor[this.nCurrent] = "#000000";
   } else {
    this.strName[this.nCurrent] = sName;
    this.strColor[this.nCurrent] = sColor;
    this.strURL[this.nCurrent] = sURL;
   }

   this.nCurrent++
   return true;
  }

  function _GetName(sId)
  {
     for(var i = 0; i < this.nCurrent; i++)
     {
       if (this.nId[i] == sId)
         return this.strName[i];
     }
      
     return "<font color=\"#800000\">INVALID GROUP ID of " + sId + "</font>";
  }

  function _GetColor(sId)
  {
     for(var i = 0; i < this.nCurrent; i++)
     {
       if (this.nId[i] == sId)
         return this.strColor[i];
     }
     return "#000000";
  }
  
  function _GetURL(sId)
  {
     for(var i = 0; i < this.nCurrent; i++)
     {
       if (this.nId[i] == sId)
       {
        if(this.strURL[i] != "")
         return "<a href=\"" + this.strURL[i] + "\"><img align=middle src=\"images/storminfo.gif\" border=0 width=15 height=15 alt=\"" + this.strName[i] + " Safety Info...\"></a>";
        else return "";
       }
     }
     return "";
  }
  