function SetControls()
{
	LoadStates();
	
	if(ci.length > 0) document.getElementById('txtCity').value = ci;
	if(z.length > 0) document.getElementById('txtZip').value = z;	
	
	
}

function LoadDisplay()
{
	var ddl = document.getElementById('ddlDisplay');
	ddl.options[0] = new Option('', '');
	ddl.options[1] = new Option('15', '15');
	ddl.options[2] = new Option('25', '25');
	ddl.options[3] = new Option('50', '50');
	
	if(ps.length > 0)
	{
		for(i=0; i<ddl.options.length; i++)
			if(ddl.options[i].value == ps)
				ddl.options[i].selected = true;
	}
}

function LoadStates()
{
	var states = getStates();
	var ddl = document.getElementById('ddlStates');
	var i = 1;
	
	ddl.options[0] = new Option('', '');
	for(s in states)
		ddl.options[i++] = new Option(states[s], s);
		
	if(st.length > 0)
	{
		for(i = 0; i < ddl.options.length; i++)
		{
			if(ddl.options[i].value.toLowerCase() == st.toLowerCase())
			{
				ddl.options[i].selected = true;
				StateChanged();
				
				if(cno.length > 0)
				{
					ddl = document.getElementById('ddlCounties');
					
					for(j = 0; j < ddl.options.length; j++)
					{
						if(ddl.options[j].value.toLowerCase() == cno.toLowerCase())
						{
							ddl.options[j].selected = true;
							break;
						}
					}
				}
											
				break;
			}
		}
	}
}

function StateChanged()
{
	st = document.getElementById('ddlStates').value;
	document.getElementById('txtCity').text = "";
	document.getElementById('txtZip').text = "";
	
	var counties = getCounties(st);
	var ddl = document.getElementById('ddlCounties');
	ddl.options.length = 0;
	var i = 1;
	
	ddl.options[0] = new Option('', '');				
	for(c in counties)
		ddl.options[i++] = new Option(counties[c], c);
		
	ddl.disabled = false;
	ddl.options[0].selected = true;
	document.getElementById('txtCity').disabled = false;
	document.getElementById('txtZip').disabled = false;	
}

function ShowAdvanced()
{
	var lnk = document.getElementById('lnkAdv');
	if(lnk.innerHTML == 'Advanced Search')
	{
		lnk.innerHTML = 'Simple Search';
		document.getElementById('trAdvanced').style.display = '';
	}
	else
	{
		lnk.innerHTML = 'Advanced Search';
		document.getElementById('trAdvanced').style.display = 'none';
	}
}


function HighlightListing(over, div, alt)
{
	if(over)
	{
		if(alt)
			div.className = 'listingdiv2hover';
		else
			div.className = 'listingdiv1hover';
	}
	else
	{
		if(alt)
			div.className = 'listingdiv2';
		else
			div.className = 'listingdiv1';
	}
}

