function  fnCheckValue(selectBox)
{
	if (selectBox.options[0].selected || selectBox.value=="")
	{
		for(var i = 0; i<selectBox.options.length; i++)
		{	
			if (i == 0)
			{
				selectBox.options[i].selected = true
			}
			else
			{
				selectBox.options[i].selected = false
			}
		}
		//these next two lines are inserted to make sure the cursor is set at the first position
		selectBox.options[0].selected = false
		selectBox.options[0].selected = true
	}				
}


	
// form submit
function fnCheckAndSubmitSearch()
{
	var strCity = lstCity.value
	
	var selectedProjTypes = new Array()
	for(var i = 0; i<lstProjectType.options.length; i++)
	{
		if (lstProjectType.options[i].selected && i>0)
		{
			selectedProjTypes[selectedProjTypes.length] = lstProjectType.options[i].value
		}
	}
	
	var selectedZoneTypes = new Array()
	for(var i = 0; i<lstZoningType.options.length; i++)
	{
		if (lstZoningType.options[i].selected && i>0)
		{
			selectedZoneTypes[selectedZoneTypes.length] = lstZoningType.options[i].value
		}
	}
	
		
	if (selectedProjTypes.length > 0)
		CurrentFilter.fnSetFilterItem('strProjType', FilterType.IntegerArray, selectedProjTypes)
	else
		CurrentFilter.fnSetFilterItem('strProjType', null)
	
	
	if (strCity != "")
		CurrentFilter.fnSetFilterItem('strCity', FilterType.Integer, strCity)
	else
		CurrentFilter.fnSetFilterItem('strCity', null)
	
	if (selectedZoneTypes.length > 0)
		CurrentFilter.fnSetFilterItem('strZoneType', FilterType.IntegerArray, selectedZoneTypes)
	else
		CurrentFilter.fnSetFilterItem('strZoneType', null)
	
	
	CurrentFilter.fnExecuteFilter()
}
	
// Parse Selected ProjectTypes
var selectedProjTypes = new Array()

if (CurrentFilter.fnGetFilterItem('strProjType') != null)
	selectedProjTypes = CurrentFilter.fnGetFilterItem('strProjType').fnGetFilterValue(FilterType.IntegerArray)
for(var i = 0; i<lstProjectType.options.length; i++)
{
	lstProjectType.options[i].selected = false
	if (selectedProjTypes.length == 0)
	{
		lstProjectType.options[i].selected = (i==0)			
	}		
	else
	{
		for(var j = 0; j<selectedProjTypes.length; j++)
		{
			if (lstProjectType.options[i].value==selectedProjTypes[j])
			{
				lstProjectType.options[i].selected = true
			}
		}
	}
}
	
// Parse Selected City
if (CurrentFilter.fnGetFilterItem('strCity') == null)
	lstCity.value = ""
else
	lstCity.value = CurrentFilter.fnGetFilterItem('strCity').fnGetFilterValue(FilterType.String)
	
// Parse Selected ZoningType
var selectedZoneTypes = new Array()

if (CurrentFilter.fnGetFilterItem('strZoneType') != null)
	selectedZoneTypes = CurrentFilter.fnGetFilterItem('strZoneType').fnGetFilterValue(FilterType.IntegerArray)
for(var i = 0; i<lstZoningType.options.length; i++)
{
	lstZoningType.options[i].selected = false
	if (selectedZoneTypes.length == 0)
	{
		lstZoningType.options[i].selected = (i==0)			
	}		
	else
	{
		for(var j = 0; j<selectedZoneTypes.length; j++)
		{
			if (lstZoningType.options[i].value==selectedZoneTypes[j])
			{
				lstZoningType.options[i].selected = true
			}
		}
	}
}