// JavaScript Document
function Init ()
{
		if (document.getElementById('FilterMod'))
		{
			SelectFilter ('mod', document.getElementById('XFormField_mar'), document.getElementById('XFormField_mar').value, document.getElementById('FilterMod').value)
		}
		
		if (document.getElementById('FilterPrv'))
		{
			SelectFilter ('prv', document.getElementById('XFormField_rgn'), document.getElementById('XFormField_rgn').value, document.getElementById('FilterPrv').value)
		}
	
}
	
	
function SelectFilter (theKind, theSelect, source, theSelIndex)
{
		if (source)
		{
			if (theSelIndex == '')	theSelIndex = 0;
			theModList = (document.getElementById(theKind + 'data').value).match (new RegExp ('#' + source + '[^#]*'));
			
			if (theModList)
			{
				theModItems = theModList[0].split ('|');
				with (theSelect.form[theKind])
				{
					options.length = 0;
					options[0] = new Option( '', '')
					
					for ( theIndex = 1; theIndex < theModItems.length -1; theIndex++) 
					{
						options[theIndex] = new Option( theModItems[theIndex], theModItems[theIndex])
						if (theModItems[theIndex] == theSelIndex)	
						{
							options.selectedIndex=theIndex;
						}
					}
				}
			}
			else
				theSelect.form[theKind].options.length = 0;
		}
		else
			theSelect.form[theKind].options.length = 0;
}
	
function i_obj (theID, isOptional)
{
		var theObj = document.getElementById(theID);

		if (theObj)
			return theObj;
		else if (!isOptional)
			alert ('Error. i_objRead: ' + theID);

		return null;
}

function i_formobj (theFormName, theID, isOptional)
{
		var theForm = i_obj (theFormName, true);
		if (theForm)
		{
			var theObj = theForm.elements.namedItem(theID);
			if (theObj)
				return theObj;
			else if (!isOptional)
				alert ('Error. i_objRead: ' + theID);
		}
		return null;
}

function imposta(inq)
{
	switch (inq){
		case "Biossido di zolfo":
			f.Um.value = "µg/m³";
			f.Sigla.value = "SO2";
			break;
		case "Biossido di azoto":
			f.Um.value = "µg/m³";
			f.Sigla.value = "NO2";
			break;
		case "Monossido di carbonio":
			f.Um.value = "mg/m³";
			f.Sigla.value = "CO";
			break;
		case "Ozono":
			f.Um.value = "µg/m³";
			f.Sigla.value = "O3";
			break;
		case "PM10":
			f.Um.value = "µg/m³";
			f.Sigla.value = "PM10";
			break;
		case "Benzene":
			f.Um.value = "µg/m³";
			f.Sigla.value = "BENZENE";
			break;
	}
}