// JavaScript Document

	var HAWAII = "3";
	var KAUAI = "4";
	var NEW = "14";
	var PR = "14";

	function cleanUp(obj)
	{
		theForm = obj.nodeName != "FORM" ? obj.form : obj;

		if(obj.nodeName=="FORM") //true if the form is being submitted.
		{
			//Start of code to deal with the county and multi-district stuff.

			/*
			obj.nodeName=="FORM" ==> action source is the onSubmit() in the form
			i.e. The above if statement is true if and only if the form is being
			submitted
			*/

			if(theForm.DIST.options[0].selected && theForm.DIST.options[0].value=="")
			{
				var countyId = document.createElement("input");
				countyId.setAttribute("type", "hidden");
				countyId.setAttribute("name", "countyId");
				countyId.setAttribute("value", HAWAII); //change to KAUAI (case sensitive) for Kauai county.
				theForm.appendChild(countyId);

				countyId = null;

				// theForm.DIST.parentNode.removeChild(dist);
			}

			//End of code to deal with the county and multi-district stuff.



			//Start of code to deal with the new/price reduced listings.

			listings = document.getElementsByName("LISTINGS");

			if(listings!=null)
			{
				if(listings[0].type!="checkbox" && !listings[0].options[0].selected)
				{
					if(listings[0].options[1].selected) //for new listings
					{
						var daysAgoNew = document.createElement("input");
						daysAgoNew.setAttribute("type", "hidden");
						daysAgoNew.setAttribute("name", "daysAgoNew");
						daysAgoNew.setAttribute("value", NEW);
						theForm.appendChild(daysAgoNew);

						daysAgoNew=null;
					}
					else
				//	if(listings[0].options[2].selected) //for price reduced listings.
					{
						var daysAgoPrRed = document.createElement("input");
						daysAgoPrRed.setAttribute("type", "hidden");
						daysAgoPrRed.setAttribute("name", "daysAgoPrRed");
						daysAgoPrRed.setAttribute("value", PR);
						theForm.appendChild(daysAgoPrRed);

						daysAgoPrRed=null;
					}
				}
			}

			//End of code to deal with the new/price reduced listings.
		}
		else //true if form is not being submitted.
		{
			if(theForm.DIST.multiple && theForm.countyId != null) //theForm.DIST.options[0].value!="")
			{
				if(obj.name == "countyId")
				{
					if(obj.checked)
					{
						for(var i=0; i<theForm.DIST.length; i++)
							theForm.DIST.options[i].selected = false;
					}
				}
				else
					theForm.countyId.checked = false;
			}
		}

		return true;
	}