/*
	Written to manage a checkbox group where the following conditions hold:
	Box 1 can't be checked if any Box 2 to n are checked.
	Box 1 is checked if any Box 2 to n are not checked.
*/
function CheckBoxes(oBox)
{
	oForm = oBox.form
	oBoxes = oForm.elements[oBox.name];
	if( oBox == oBoxes[0] && oBox.checked )
	{
		for( iCount = 1; iCount < oBoxes.length; ++iCount )
		{
			oBoxes[iCount].checked = false;
		}
		oBoxes[0].checked = true;
	}
	else
	{
		bNoneChecked = true;
		// don't count the first one; it is the default
		for( iCount = 1; iCount < oBoxes.length; ++iCount )
		{
			if( oBoxes[iCount].checked == true )
			{
				bNoneChecked = false;
				break;
			}
		}
		oBoxes[0].checked = bNoneChecked;
	}
	
}

function CheckRents(oForm)
{
	oLow = oForm.elements['RentLow'];
	oHigh = oForm.elements['RentHigh'];
	iRentLow = parseInt(oLow[oLow.selectedIndex].value);
	iRentHigh = parseInt(oHigh[oHigh.selectedIndex].value);
	try 
	{
		while( iRentLow >= iRentHigh )
		{
			oLow.selectedIndex--;
			oHigh.selectedIndex--;
			// alert( oLow.selectedIndex + "\n" + oHigh.selectedIndex );
			iRentLow = parseInt(oLow[oLow.selectedIndex].value);
			iRentHigh = parseInt(oHigh[oHigh.selectedIndex].value);
		}
	}
	catch (oEx) 
	{
		oLow.selectedIndex = 1;
		oHigh.selectedIndex = 1;
	}
}

function  ToggleAmenities(onOff, action)
{
	form = document.getElementById('SearchForm');
	amenities = document.getElementById( 'ShowAmenities' );
	amenities.value = onOff;
	form.action = action;
	form.submit();
}
