

var naryAgencyList = { //Array of named indices
  
          '001':Array(  //Nodes for Adams County
             {id:'0010000', name:"Adams County Sheriff's Office"}
	        , {id:'0010100', name:"Othello Police Department"}
	        , {id:'0010200', name:"Ritzville Police Department"}
	        
          )
        ,
          '002':Array(  //Nodes for Asotin County
             {id:'0020000', name:"Asotin County Sheriff's Office"}
	        , {id:'0020100', name:"Clarkston Police Department"}
	        , {id:'0020200', name:"Asotin Police Department"}
	        
          )
        ,
          '003':Array(  //Nodes for Benton County
             {id:'0030000', name:"Benton County Sheriff's Office"}
	        , {id:'0030100', name:"Kennewick Police Department"}
	        , {id:'0030200', name:"Richland Police Department"}
	        , {id:'0030300', name:"Prosser Police Department"}
	        , {id:'0030500', name:"West Richland Police Department"}
	        
          )
        ,
          '004':Array(  //Nodes for Chelan County
             {id:'0040000', name:"Chelan County Sheriff's Office"}
	        , {id:'0040200', name:"Chelan Police Department"}
	        , {id:'0040400', name:"Wenatchee Police Department"}
	        
          )
        ,
          '005':Array(  //Nodes for Clallam County
             {id:'0050000', name:"Clallam County Sheriff's Office"}
	        , {id:'0050100', name:"Port Angeles Police Department"}
	        , {id:'0050200', name:"Forks Police Department"}
	        , {id:'0050300', name:"Sequim Police Department"}
	        
          )
        ,
          '006':Array(  //Nodes for Clark County
             {id:'0060000', name:"Clark County Sheriff's Office"}
	        , {id:'0060100', name:"Battle Ground Police Department"}
	        , {id:'0060200', name:"Camas Police Department"}
	        , {id:'0060300', name:"Vancouver Police Department"}
	        , {id:'0060400', name:"Washougal Police Department"}
	        , {id:'0060500', name:"Ridgefield Police Department"}
	        , {id:'0060600', name:"La Center Police Department"}
	        , {id:'0061000', name:"Wa. State Univ.-Vancouver PD"}
	        
          )
        ,
          '007':Array(  //Nodes for Columbia County
             {id:'0070000', name:"Columbia County Sheriff's Office"}
	        , {id:'0070100', name:"Dayton Police Department"}
	        
          )
        ,
          '008':Array(  //Nodes for Cowlitz County
             {id:'0080000', name:"Cowlitz County Sheriff's Office"}
	        , {id:'0080100', name:"Kelso Police Department"}
	        , {id:'0080200', name:"Longview Police Department"}
	        , {id:'0080300', name:"Castle Rock Police Department"}
	        , {id:'0080400', name:"Kalama Police Department"}
	        , {id:'0080500', name:"Woodland Police Department"}
	        
          )
        ,
          '009':Array(  //Nodes for Douglas County
             {id:'0090000', name:"Douglas County Sheriff's Office"}
	        , {id:'0090200', name:"East Wenatchee Police Department"}
	        
          )
        ,
          '010':Array(  //Nodes for Ferry County
             {id:'0100000', name:"Ferry County Sheriff's Office"}
	        , {id:'0100100', name:"Republic Police Department"}
	        
          )
        ,
          '011':Array(  //Nodes for Franklin County
             {id:'0110000', name:"Franklin County Sheriff's Office"}
	        , {id:'0110100', name:"Connell Police Department"}
	        , {id:'0110200', name:"Pasco Police Department"}
	        
          )
        ,
          '012':Array(  //Nodes for Garfield County
             {id:'0120000', name:"Garfield County Sheriff's Office"}
	        , {id:'0120100', name:"Pomeroy Police Department"}
	        
          )
        ,
          '013':Array(  //Nodes for Grant County
             {id:'0130000', name:"Grant County Sheriff's Office"}
	        , {id:'0130100', name:"Ephrata Police Department"}
	        , {id:'0130200', name:"Moses Lake Police Department"}
	        , {id:'0130300', name:"Quincy Police Department"}
	        , {id:'0130400', name:"Soap Lake Police Department"}
	        , {id:'0130500', name:"Coulee City Police Department"}
	        , {id:'0130700', name:"Grand Coulee Police Department"}
	        , {id:'0130900', name:"Mattawa Police Department"}
	        , {id:'0131000', name:"Royal City Police Department"}
	        , {id:'0131100', name:"Warden Police Department"}
	        
          )
        ,
          '014':Array(  //Nodes for Grays Harbor County
             {id:'0140000', name:"Grays Harbor County Sheriff's Office"}
	        , {id:'0140100', name:"Aberdeen Police Department"}
	        , {id:'0140200', name:"Elma Police Department"}
	        , {id:'0140300', name:"Hoquiam Police Department"}
	        , {id:'0140400', name:"Mc Cleary Police Department"}
	        , {id:'0140500', name:"Montesano Police Department"}
	        , {id:'0140600', name:"Cosmopolis Police Department"}
	        , {id:'0140700', name:"Oakville Police Department"}
	        , {id:'0140800', name:"Ocean Shores Police Department"}
	        , {id:'0140900', name:"Westport Police Department"}
	        
          )
        ,
          '015':Array(  //Nodes for Island County
             {id:'0150000', name:"Island County Sheriff's Office"}
	        , {id:'0150100', name:"Oak Harbor Police Department"}
	        , {id:'0150200', name:"Coupeville Police Department"}
	        , {id:'0150300', name:"Langley Police Department"}
	        
          )
        ,
          '016':Array(  //Nodes for Jefferson County
             {id:'0160000', name:"Jefferson County Sheriff's Office"}
	        , {id:'0160100', name:"Port Townsend Police Department"}
	        
          )
        ,
          '017':Array(  //Nodes for King County
             {id:'0170000', name:"King County Sheriff's Office"}
	        , {id:'0170100', name:"Auburn Police Department"}
	        , {id:'0170200', name:"Bellevue Police Department"}
	        , {id:'0170300', name:"Bothell Police Department"}
	        , {id:'0170400', name:"Enumclaw Police Department"}
	        , {id:'0170600', name:"Issaquah Police Department"}
	        , {id:'0170700', name:"Kent Police Department"}
	        , {id:'0170800', name:"Kirkland Police Department"}
	        , {id:'0170900', name:"Mercer Island Police Department"}
	        , {id:'0171000', name:"Normandy Park Police Department"}
	        , {id:'0171100', name:"North Bend Police Department"}
	        , {id:'0171200', name:"Redmond Police Department"}
	        , {id:'0171300', name:"Renton Police Department"}
	        , {id:'0171400', name:"Algona Police Department"}
	        , {id:'0171500', name:"Black Diamond Police Department"}
	        , {id:'0171600', name:"Carnation Police Department"}
	        , {id:'0171700', name:"Des Moines Police Department"}
	        , {id:'0171800', name:"Duvall Police Department"}
	        , {id:'0172000', name:"Medina Police Department"}
	        , {id:'0172100', name:"Pacific Police Department"}
	        , {id:'0172200', name:"Snoqualmie Police Department"}
	        , {id:'0172300', name:"Tukwila Police Department"}
	        , {id:'0172400', name:"University of Washington Police Dept"}
	        , {id:'0172500', name:"Clyde Hill Police Department"}
	        , {id:'0172600', name:"Lake Forest Park Police Department"}
	        , {id:'0173100', name:"Yarrow Point Police Department"}
	        , {id:'0173200', name:"Port of Seattle Police Department"}
	        , {id:'0173600', name:"Federal Way Police Department"}
	        , {id:'0173700', name:"Sea Tac Police Department"}
	        , {id:'0174000', name:"Woodinville Police Department"}
	        , {id:'0174100', name:"Burien Police Department"}
	        , {id:'0174200', name:"Newcastle Police Department"}
	        , {id:'0174300', name:"Shoreline Police Department"}
	        , {id:'0174700', name:"Maple Valley Police Department"}
	        , {id:'0174800', name:"Covington Police Department"}
	        , {id:'0174900', name:"Kenmore Police Department"}
	        , {id:'0175000', name:"Sammamish Police Department"}
	        , {id:'0179900', name:"Seattle Police Department"}
	        
          )
        ,
          '018':Array(  //Nodes for Kitsap County
             {id:'0180000', name:"Kitsap County Sheriff's Office"}
	        , {id:'0180100', name:"Bremerton Police Department"}
	        , {id:'0180400', name:"Port Orchard Police Department"}
	        , {id:'0180500', name:"Poulsbo Police Department"}
	        , {id:'0180700', name:"Bainbridge Island Police Department"}
	        
          )
        ,
          '019':Array(  //Nodes for Kittitas County
             {id:'0190000', name:"Kittitas County Sheriff's Office"}
	        , {id:'0190100', name:"Ellensburg Police Department"}
	        , {id:'0190200', name:"Cle Elum Police Department"}
	        , {id:'0190400', name:"Roslyn Police Department"}
	        , {id:'0190600', name:"Kittitas Police Department"}
	        , {id:'0190800', name:"Central Washington University"}
	        
          )
        ,
          '020':Array(  //Nodes for Klickitat County
             {id:'0200000', name:"Klickitat County Sheriff's Office"}
	        , {id:'0200100', name:"Goldendale Police Department"}
	        , {id:'0200200', name:"Bingen Police Department"}
	        , {id:'0200600', name:"White Salmon Police Department"}
	        
          )
        ,
          '021':Array(  //Nodes for Lewis County
             {id:'0210000', name:"Lewis County Sheriff's Office"}
	        , {id:'0210100', name:"Centralia Police Department"}
	        , {id:'0210200', name:"Chehalis Police Department"}
	        , {id:'0210300', name:"Morton Police Department"}
	        , {id:'0210400', name:"Mossyrock Police Department"}
	        , {id:'0210700', name:"Napavine Police Department"}
	        , {id:'0210900', name:"Pe Ell Police Department"}
	        , {id:'0211000', name:"Toledo Police Department"}
	        , {id:'0211100', name:"Vader Police Department"}
	        , {id:'0211200', name:"Winlock Police Department"}
	        
          )
        ,
          '022':Array(  //Nodes for Lincoln County
             {id:'0220000', name:"Lincoln County Sheriff's Office"}
	        , {id:'0220100', name:"Davenport Police Department"}
	        , {id:'0220200', name:"Wilbur Police Department"}
	        , {id:'0220500', name:"Harrington Police Department"}
	        , {id:'0220600', name:"Odessa Police Department"}
	        , {id:'0220700', name:"Reardan Police Department"}
	        , {id:'0220800', name:"Sprague Police Department"}
	        
          )
        ,
          '023':Array(  //Nodes for Mason County
             {id:'0230000', name:"Mason County Sheriff's Office"}
	        , {id:'0230400', name:"Shelton Police Department"}
	        , {id:'0230700', name:"Skokomish Police Department"}
	        
          )
        ,
          '024':Array(  //Nodes for Okanogan County
             {id:'0240000', name:"Okanogan County Sheriff's Office"}
	        , {id:'0240100', name:"Brewster Police Department"}
	        , {id:'0240300', name:"Omak Police Department"}
	        , {id:'0240400', name:"Oroville Police Department"}
	        , {id:'0240500', name:"Pateros Police Department"}
	        , {id:'0240600', name:"Tonasket Police Department"}
	        , {id:'0240700', name:"Coulee Dam Police Department"}
	        , {id:'0240800', name:"Elmer City Police Department"}
	        , {id:'0240900', name:"Twisp Police Department"}
	        , {id:'0241000', name:"Winthrop Police Department"}
	        , {id:'0241200', name:"Conconully Police Department"}
	        
          )
        ,
          '025':Array(  //Nodes for Pacific County
             {id:'0250000', name:"Pacific County Sheriff's Office"}
	        , {id:'0250100', name:"Raymond Police Department"}
	        , {id:'0250200', name:"South Bend Police Department"}
	        , {id:'0250300', name:"Ilwaco Police Department"}
	        , {id:'0250400', name:"Long Beach Police Department"}
	        
          )
        ,
          '026':Array(  //Nodes for Pend Oreille County
             {id:'0260000', name:"Pend Oreille County Sheriff's Office"}
	        , {id:'0260200', name:"Newport Police Department"}
	        , {id:'0260300', name:"Ione Police Department"}
	        , {id:'0260500', name:"Cusick Police Department"}
	        
          )
        ,
          '027':Array(  //Nodes for Pierce County
             {id:'0270000', name:"Pierce County Sheriff's Office"}
	        , {id:'0270100', name:"Puyallup Police Department"}
	        , {id:'0270200', name:"Sumner Police Department"}
	        , {id:'0270300', name:"Tacoma Police Department"}
	        , {id:'0270400', name:"Buckley Police Department"}
	        , {id:'0270500', name:"Eatonville Police Department"}
	        , {id:'0270700', name:"Fife Police Department"}
	        , {id:'0270900', name:"Milton Police Department"}
	        , {id:'0271000', name:"Roy Police Department"}
	        , {id:'0271100', name:"Steilacoom Police Department"}
	        , {id:'0271300', name:"Orting Police Department"}
	        , {id:'0271400', name:"Bonney Lake Police Department"}
	        , {id:'0271600', name:"Du Pont Police Department"}
	        , {id:'0271700', name:"Fircrest Police Department"}
	        , {id:'0271800', name:"Gig Harbor Police Department"}
	        , {id:'0271900', name:"Ruston Police Department"}
	        , {id:'0272000', name:"Wilkeson Police Department"}
	        , {id:'0272300', name:"Lakewood P.D."}
	        , {id:'0272400', name:"University Place P.D."}
	        , {id:'0272500', name:"Edgewood P.D."}
	        
          )
        ,
          '028':Array(  //Nodes for San Juan County
             {id:'0280000', name:"San Juan County Sheriff's Office"}
	        
          )
        ,
          '029':Array(  //Nodes for Skagit County
             {id:'0290000', name:"Skagit County Sheriff's Office"}
	        , {id:'0290100', name:"Anacortes Police Department"}
	        , {id:'0290200', name:"Mount Vernon Police Department"}
	        , {id:'0290300', name:"Sedro Wooley Police Department"}
	        , {id:'0290400', name:"Burlington Police Department"}
	        , {id:'0290600', name:"La Conner Police Department"}
	        , {id:'0297500', name:"Swinomish Tribal Police Department"}
	        
          )
        ,
          '030':Array(  //Nodes for Skamania County
             {id:'0300000', name:"Skamania County Sheriff's Office"}
	        , {id:'0300100', name:"North Bonneville Police Department"}
	        , {id:'0300200', name:"Stevenson Police Department"}
	        
          )
        ,
          '031':Array(  //Nodes for Snohomish County
             {id:'0310000', name:"Snohomish County Sheriff's Office"}
	        , {id:'0310100', name:"Arlington Police Department"}
	        , {id:'0310200', name:"Edmonds Police Department"}
	        , {id:'0310300', name:"Everett Police Department"}
	        , {id:'0310400', name:"Lynnwood Police Department"}
	        , {id:'0310500', name:"Marysville Police Department"}
	        , {id:'0310600', name:"Mountlake Terrace Police Department"}
	        , {id:'0310700', name:"Snohomish Police Department"}
	        , {id:'0310800', name:"Brier Police Department"}
	        , {id:'0310900', name:"Darrington Police Department"}
	        , {id:'0311100', name:"Granite Falls Police Department"}
	        , {id:'0311200', name:"Monroe Police Department"}
	        , {id:'0311300', name:"Mukilteo Police Department"}
	        , {id:'0311400', name:"Stanwood Police Department"}
	        , {id:'0311500', name:"Sultan Police Department"}
	        , {id:'0311600', name:"Woodway Police Department"}
	        , {id:'0311900', name:"Lake Stevens Police Department"}
	        , {id:'0312100', name:"Mill Creek Police Department"}
	        
          )
        ,
          '032':Array(  //Nodes for Spokane County
             {id:'0320000', name:"Spokane County Sheriff's Office"}
	        , {id:'0320100', name:"Cheney Police Department"}
	        , {id:'0320300', name:"Medical Lake Police Department"}
	        , {id:'0320400', name:"Spokane Police Department"}
	        , {id:'0320600', name:"Airway Heights Police Department"}
	        , {id:'0320900', name:"Eastern Washington University Police"}
	        , {id:'0321300', name:"Liberty Lake Police Department"}
	        , {id:'0321500', name:"Spokane Valley Police Department"}
	        
          )
        ,
          '033':Array(  //Nodes for Stevens County
             {id:'0330000', name:"Stevens County Sheriff's Office"}
	        , {id:'0330100', name:"Chewelah Police Department"}
	        , {id:'0330200', name:"Colville Police Department"}
	        , {id:'0330300', name:"Kettle Falls Police Department"}
	        , {id:'0330500', name:"Northport Police Department"}
	        , {id:'0330600', name:"Springdale Police Department"}
	        
          )
        ,
          '034':Array(  //Nodes for Thurston County
             {id:'0340000', name:"Thurston County Sheriff's Office"}
	        , {id:'0340100', name:"Olympia Police Department"}
	        , {id:'0340200', name:"Tumwater Police Department"}
	        , {id:'0340400', name:"Lacey Police Department"}
	        , {id:'0340600', name:"Rainier Police Department"}
	        , {id:'0340800', name:"Tenino Police Department"}
	        , {id:'0340900', name:"Yelm Police Department"}
	        , {id:'0341900', name:"Evergreen St. College P.D."}
	        , {id:'0348800', name:"Nisqually Tribal Police Department"}
	        
          )
        ,
          '035':Array(  //Nodes for Wahkiakum County
             {id:'0350000', name:"Wahkiakum County Sheriff's Office"}
	        
          )
        ,
          '036':Array(  //Nodes for Walla Walla County
             {id:'0360000', name:"Walla Walla County Sheriff's Office"}
	        , {id:'0360100', name:"Walla Walla Police Department"}
	        , {id:'0360200', name:"College Place Police Department"}
	        , {id:'0360300', name:"Waitsburg Police Department"}
	        
          )
        ,
          '037':Array(  //Nodes for Whatcom County
             {id:'0370000', name:"Whatcom County Sheriff's Office"}
	        , {id:'0370100', name:"Bellingham Police Department"}
	        , {id:'0370200', name:"Blaine Police Department"}
	        , {id:'0370300', name:"Everson Police Department"}
	        , {id:'0370400', name:"Ferndale Police Department"}
	        , {id:'0370500', name:"Lynden Police Department"}
	        , {id:'0370700', name:"Sumas Police Department"}
	        , {id:'0370800', name:"Western Washington University Police"}
	        , {id:'0371000', name:"Lummi Tribal Police Department"}
	        , {id:'0379900', name:"Nooksak Tribal Police Department"}
	        
          )
        ,
          '038':Array(  //Nodes for Whitman County
             {id:'0380000', name:"Whitman County Sheriff's Office"}
	        , {id:'0380100', name:"Colfax Police Department"}
	        , {id:'0380200', name:"Albion Police Department"}
	        , {id:'0380300', name:"Pullman Police Department"}
	        , {id:'0380400', name:"Rosalia Police Department"}
	        , {id:'0380500', name:"Washington State University"}
	        , {id:'0380600', name:"Colton Police Department"}
	        , {id:'0380700', name:"Garfield Police Department"}
	        , {id:'0380900', name:"Palouse Police Department"}
	        , {id:'0381300', name:"Malden Police Department"}
	        , {id:'0381400', name:"Oakesdale Police Department"}
	        , {id:'0381500', name:"Tekoa Police Department"}
	        , {id:'0381600', name:"Union Town Police Department"}
	        
          )
        ,
          '039':Array(  //Nodes for Yakima County
             {id:'0390000', name:"Yakima County Sheriff's Office"}
	        , {id:'0390100', name:"Grandview Police Department"}
	        , {id:'0390200', name:"Sunnyside Police Department"}
	        , {id:'0390300', name:"Toppenish Police Department"}
	        , {id:'0390400', name:"Union Gap Police Department"}
	        , {id:'0390500', name:"Yakima Police Department"}
	        , {id:'0390600', name:"Zillah Police Department"}
	        , {id:'0390700', name:"Granger Police Department"}
	        , {id:'0390900', name:"Mabton Police Department"}
	        , {id:'0391100', name:"Selah Police Department"}
	        , {id:'0391200', name:"Tieton Police Department"}
	        , {id:'0391300', name:"Wapato Police Department"}
	        , {id:'0391400', name:"Moxee City Police Department"}
	        
          )
        
};
//<script>//This is for the sake of syntax highlighting

//Perform an initial (nearly)alphabetic sort of all the counties' agency lists.
Behaviour.addLoadEvent(function(){
	
	var sortfunc = function(aobj,bobj){
		var retval;
		var a=aobj.name, b=bobj.name;
		var imax=Math.min(a.length,b.length);
		//lengthorder:  Multiplier of return value if the for loop reaches the end of the shorter string.
		var lengthorder = (a.length < b.length) ? -1 : 1;
		for(var i=0; i<imax; i++){
			retval = a.charCodeAt(i) - b.charCodeAt(i);
			if (retval != 0) break;  //Terminate loop when we find a difference
			
			//For the last iteration...
			if (i == imax-1) retval = 1*lengthorder; //Terminate loop when end of shorter string is reached
		}
		return retval;
	};
	
	//The head:tail model (Haskell list notation) is used here because it's nice to keep the Sheriff's office at the head of the list.
	var tmphead, tmptail;
	for (var c in naryAgencyList){
		tmphead = naryAgencyList[c].slice(0,1);
		tmptail = naryAgencyList[c].slice(1);
		tmptail.sort(sortfunc);
		naryAgencyList[c] = tmphead.concat(tmptail);
	}
});
