function mainChangeDisplay()
{
	var cat_field = document.getElementById("property_category");
	var cat_field_selected = cat_field.selectedIndex;
	var cat_field_value = cat_field.options[cat_field_selected].value;
	
	hideHelp();
	hideAll();
	disableAll();
	
	if(cat_field_value == 1)
	{
		// SHOW SALES LAYERS
		document.getElementById("sale_search").style.display = 'block';
		
		// ENABLE SALES LAYERS
		enableSection('sale_search');
		
		document.getElementById('submit').disabled = false;
	}
	if(cat_field_value == 2)
	{
		// SHOW RENTAL LAYERS
		document.getElementById("rental_search").style.display = 'block';
		
		// ENABLE RENTAL LAYERS
		enableSection('rental_search');
		
		document.getElementById('submit').disabled = false;
	}
	if(cat_field_value == 3)
	{
		// SHOW COMMERCIAL LAYERS
		document.getElementById("commercial_search").style.display = 'block';
		
		// ENABLE COMMERCIAL LAYERS
		enableSection('commercial_search');
		
		document.getElementById('submit').disabled = false;
	}
	if(cat_field_value == 4)
	{
		// SHOW MOORING LAYERS
		document.getElementById("mooring_search").style.display = 'block';
		
		// ENABLE MOORING LAYERS
		enableSection('mooring_search');
		
		document.getElementById('submit').disabled = false;
	}
	
	if(cat_field_value == -1)
	{
		document.getElementById('submit').disabled = true;
		showHelp();
	}
}

function hideAll()
{
	document.getElementById("sale_search").style.display = 'none';
	document.getElementById("rental_search").style.display = 'none';
	document.getElementById("commercial_search").style.display = 'none';
	document.getElementById("mooring_search").style.display = 'none';
}

function disableAll()
{
	disableSection('sale_search');
	disableSection('rental_search');
	disableSection('commercial_search');
	disableSection('mooring_search');
}

function disableSection(sectionname)
{
	var allSelect = document.getElementById(sectionname).getElementsByTagName("SELECT");
	var allInput = document.getElementById(sectionname).getElementsByTagName("INPUT");
	var allTextarea = document.getElementById(sectionname).getElementsByTagName("TEXTAREA");
	
	if (allSelect != null)
	{
	    for(i=0; i < allSelect.length; i++) 
	      allSelect[i].disabled = true;
	}
	if (allInput != null)
	{
	    for(i=0; i < allInput.length; i++) 
	      allInput[i].disabled = true;
	}
	if (allTextarea != null)
	{
	    for(i=0; i < allTextarea.length; i++) 
	      allTextarea[i].disabled = true;
	}
}

function enableSection(sectionname)
{
	var allSelect = document.getElementById(sectionname).getElementsByTagName("SELECT");
	var allInput = document.getElementById(sectionname).getElementsByTagName("INPUT");
	var allTextarea = document.getElementById(sectionname).getElementsByTagName("TEXTAREA");
	
	if (allSelect != null)
	{
	    for(i=0; i < allSelect.length; i++) 
	      allSelect[i].disabled = false;
	}
	if (allInput != null)
	{
	    for(i=0; i < allInput.length; i++) 
	      allInput[i].disabled = false;
	}
	if (allTextarea != null)
	{
	    for(i=0; i < allTextarea.length; i++) 
	      allTextarea[i].disabled = false;
	}
}

function showHelp()
{
	document.getElementById("search_help").style.display = 'block';
}

function hideHelp()
{
	document.getElementById("search_help").style.display = 'none';
}