var weatherStation={
10:"Alvdal"
,11:"Apelsvoll"
,12:"Balestrand"
,13:"Bø"
,86:"Darbu"
,14:"Etne"
,15:"Frosta"
,16:"Fureneset"
,17:"Fåvang"
,18:"Gausdal"
,88:"Gjennestad"
,19:"Gjerpen"
,20:"Gran"
,21:"Gvarv"
,97:"Heradsbygd"
,87:"Hesthammar"
,22:"Hjelmeland"
,67:"Hjuksebø"
,23:"Hokksund"
,24:"Holt"
,25:"Hønefoss"
,66:"Høyheimsvik"
,26:"Ilseng"
,27:"Kise"
,28:"Kvam"
,93:"Kvelde"
,57:"Kvithamar"
,29:"Landvik"
,30:"Lier"
,31:"Linge"
,92:"Linge2"
,65:"Ljøsne"
,62:"Loen"
,32:"Lyngdal"
,33:"Løken"
,82:"Meldal"
,71:"Moelv"
,34:"Mære"
,35:"Njøs"
,90:"Nå"
,81:"Oppdal"
,84:"Orre"
,36:"Pasvik"
,37:"Rakkestad"
,38:"Ramnes"
,124:"Randaberg"
,83:"Rennebu"
,39:"Rissa"
,40:"Roverud"
,41:"Rygge"
,63:"Sandane"
,94:"Sandane2"
,42:"Sande"
,43:"Skjetlein"
,108:"Skjetten"
,44:"Skogmo"
,64:"Slinde"
,45:"Sortland"
,46:"Surnadal"
,47:"Svelvik"
,48:"Særheim"
,91:"Søve"
,49:"Tingvoll"
,50:"Tjølling"
,51:"Tjøtta"
,52:"Tomb"
,53:"Udnes"
,54:"Ullensvang"
,55:"Ulvik"
,56:"Vågønes"
,118:"Øsaker"
,5:"Ås"
,61:"Åsbakken"
,72:"Åsnes"
}

var region={
1:{"name":"Nordøstlandet","weatherStations":new Array(11,20,25,26,27,33,108,53)}
,2:{"name":"Gudbrandsdalen/Østerdalen","weatherStations":new Array(17,18,10,40)}
,3:{"name":"Sørøstlandet","weatherStations":new Array(13,86,88,19,21,23,27,93,30,29,37,38,41,42,47,50,91,52,118,5,61)}
,4:{"name":"Sørvestlandet","weatherStations":new Array(48,22,32,124,14)}
,5:{"name":"Vestlandet","weatherStations":new Array(12,16,87,66,28,31,65,62,35,90,63,64,54,55)}
,6:{"name":"Midt-Norge og Nordland","weatherStations":new Array(15,57,34,39,43,44,46,49)}
,7:{"name":"Troms og Finnmark","weatherStations":new Array(24,36)}
}

function initializeWeatherStationList(weatherStationListId,weatherStationId)
{
	
	var weatherStationList = document.getElementById(weatherStationListId);
	weatherStationList.options.length=0;
	weatherStationList.options[0] = new Option("-- Velg klimastasjon --","-1");
	
	if(weatherStationId > 0)
	{
		var regionList = document.getElementById("regionList");
		var regionId = regionList.options[regionList.selectedIndex].value
		updateWeatherStationList(weatherStationListId,regionId, weatherStationId);
	}
	else
	{
		weatherStationList.options[0] = new Option("-- Velg region først --","-1");
	}
	
	/*
	for(var regionId in region)
	{
		weatherStationList.options[weatherStationList.options.length] = new Option("-- " + region[regionId].name, "-1");
		//alert (region[regionId].weatherStations);
		for(var i=0; i< region[regionId].weatherStations.length;i++)
		{
			var anOption = new Option(weatherStation[region[regionId].weatherStations[i]], region[regionId].weatherStations[i]);
			if(region[regionId].weatherStations[i] == weatherStationId) anOption.selected=true;
			weatherStationList.options[weatherStationList.options.length] = anOption;
		}
	}
	*/
}

function intializeRegionList(regionListId, selectedRegionId)
{
	var regionList = document.getElementById(regionListId);
	regionList.options[0] = new Option("-- Velg region --","-1");
	for(var regionId in region)
	{
		var anOption = new Option(region[regionId].name, regionId);
		if(regionId == selectedRegionId) anOption.selected=true;
		regionList.options[regionList.options.length] = anOption;
	}
}

function updateWeatherStationList(weatherStationListId,regionId, weatherStationId)
{
	var weatherStationList = document.getElementById(weatherStationListId);
	weatherStationList.options.length=0;
	weatherStationList.options[0] = new Option("-- Velg klimastasjon --","-1");
	for(var i=0; i< region[regionId].weatherStations.length;i++)
	{
		var anOption = new Option(weatherStation[region[regionId].weatherStations[i]], region[regionId].weatherStations[i]);
		if(anOption.value == weatherStationId) anOption.selected = true;
		weatherStationList.options[weatherStationList.options.length] = anOption;
	}
}

