<!--
	// functions for dynamic lists for län, kommuner, stadsdelar
	//
	function updateLanList() {

		var type = "sok";
			
		var objArea = document.areakommun.sLan;
		var intCountLan = 0;
			
		var intLan = 0;
		var arrLanItem = new Array();

		for (intLan=0; intLan<arrLan.length; intLan++)
		{
			arrLanItem = arrLan[intLan].split(",");
			//if ((type == "sok") && (arrLanItem[3] != 0))
			if (type == "sok")
			{
				if (intCountLan >= (objArea.options.length))
					objArea.options.length = objArea.options.length + 1;
				if (arrLanItem[3] > 0)
					objArea.options[intCountLan].text = arrLanItem[2]; // + "(" + arrLanItem[3] + ")";
				else
					objArea.options[intCountLan].text = arrLanItem[2];
				objArea.options[intCountLan].value = arrLanItem[1];
				intCountLan++;
			}	
			if (type == "bev")
			{
				if (intCountLan >= (objArea.options.length))
					objArea.options.length = objArea.options.length + 1;
				objArea.options[intCountLan].text = arrLanItem[2];
				objArea.options[intCountLan].value = arrLanItem[1];
				intCountLan++;
			}	
		}
	}		
	
	function updateKommunList(sSelectThisKommun)
	{
		var type = "sok";
			
		var objArea = document.areakommun.sLan;
		var objKommun = document.areakommun.sKommunStadsdel;
		
		// Töm eventuella poster i kommunlistan
		while (objKommun.length > 0)
			objKommun[0] = null;
		
		// Välj ut rätt län-värde
		var intSelectedIndex = objArea.selectedIndex;
		var intSelected = parseInt(objArea.options[intSelectedIndex].value);
		intAreaID = intSelected
		if (intSelected > 0) {
			aTemp = arrLan[intSelected].split(",");
			intAreaID = aTemp[1];
		}

		var intCountKommun = 0;
			
		var intKommun = 0;
		var intStadsdel = 0;
		var arrKommunItem = new Array();
		var arrStadsdelItem = new Array();
	
		for (intKommun=0; intKommun<arrKommun.length; intKommun++)
		{
			arrKommunItem = arrKommun[intKommun].split(",");
			if (arrKommunItem[0] == intAreaID)
			{
				//if ((type == "sok") && (arrKommunItem[3] != 0))
				if (type == "sok")
				{
					objKommun.options.length = intCountKommun+1;
					if (arrKommunItem[3] > 0)
						objKommun.options[intCountKommun].text = arrKommunItem[2] + " (" + arrKommunItem[3] + ")";
					else
						objKommun.options[intCountKommun].text = arrKommunItem[2];
					objKommun.options[intCountKommun].value = arrKommunItem[1];
					if (objKommun.options[intCountKommun].value == sSelectThisKommun) { 
						//alert(sSelectThisKommun+" : "+objKommun.options[intCountKommun].value)
						objKommun.options[intCountKommun].selected = true
					}
					intCountKommun++;
			
					for (intStadsdel=0; intStadsdel<arrStadsdel.length; intStadsdel++)
					{
						arrStadsdelItem = arrStadsdel[intStadsdel].split(",");
						if (arrStadsdelItem[0] == arrKommunItem[1])
						{
							//if ((type == "sok") && (arrStadsdelItem[3] > 0))
							if (type == "sok")
							{
								objKommun.options.length = intCountKommun+1;
								if (arrStadsdelItem[3] > 0)
									objKommun.options[intCountKommun].text = "- " + arrStadsdelItem[2] + " (" + arrStadsdelItem[3] + ")";
								else
									objKommun.options[intCountKommun].text = "- " + arrStadsdelItem[2];
								objKommun.options[intCountKommun].value = arrStadsdelItem[1];
								if (objKommun.options[intCountKommun].value == sSelectThisKommun) { 
									//alert(sSelectThisKommun+" : "+objKommun.options[intCountKommun].value)
									objKommun.options[intCountKommun].selected = true
								}
								intCountKommun++;
							}
						}
						// maybe select this index{{
						//if ((objKommun.options[intCountKommun].value+'') == (sSelectThisKommun+'')) { 
						//	alert(sSelectThisKommun)
						//}
						//objKommun.options[intCountKommun].selected = true
					}
				}
				if (type == "bev")
				{
					objKommun.options.length = intCountKommun+1;
					objKommun.options[intCountKommun].text = arrKommunItem[2];
					objKommun.options[intCountKommun].value = arrKommunItem[1];
					intCountKommun++;
					
					for (intStadsdel=0; intStadsdel<arrStadsdel.length; intStadsdel++)
					{
						arrStadsdelItem = arrStadsdel[intStadsdel].split(",");
						if (arrStadsdelItem[0] == arrKommunItem[1])
						{
							objKommun.options.length = intCountKommun+1;
							objKommun.options[intCountKommun].text = "- " + arrStadsdelItem[2];
							objKommun.options[intCountKommun].value = arrStadsdelItem[1];
							intCountKommun++;
						}
					}
				}
			}
		}
	}

	function start()	{
		//updateLanList();
		
		var objArea = document.areakommun.sLan;
		var objKommun = document.areakommun.sKommunStadsdel;
		var blnFound = false;
		
		var arrKommun = new Array();
	

		var arrStadsdel = new Array();
	


		for (i = 0; i < objArea.length; i++)	{
			if (objArea.options[i].value == -1) {
				objArea.selectedIndex = i;
				blnFound = true;
				break;
			}
		}

		updateKommunList('-1');
		
		
		
		unDisable();
	}

/*	
	function disable()	{
		
		document.areakommun.simple.disabled=true;
		document.areakommun.advanced.disabled=true;						
	}
*/
/*	
	function unDisable()	{
		
		
		var select = eval(document.areakommun.sKommunStadsdel.selectedIndex);
		if (select < 0)	
		{

				document.areakommun.simple.disabled=true;
				
		}
		else
		{

				document.areakommun.simple.disabled=false;
								
		}
	}
*/	
/*
	function simple_onClick()
	{
		document.areakommun.submittype.value="simple";
		document.areakommun.submit();
	}
	
	function advanced_onClick()
	{
		document.areakommun.submittype.value="advanced";
		document.areakommun.submit();
	}
*/
/*
	function checkFree() {
		var text = new String(document.freeText.kommun.value);
		if (text.length > 0) {
			return true;
		}
		else {
			return false;
		}
	}
	
	function prepKommunForm() {
		document.freeText.kommun.focus();
	}
*/
	// functions for dynamic lists for categories
	
	
// -->

