//clears and restores search default values
function clear_name() {
	if (document.search_form.ben_name.value == "by name")
	document.search_form.ben_name.value = "";
} 

function restore_name() {
	if (document.search_form.ben_name.value == "")
	document.search_form.ben_name.value = "by name";
}




function clear_city() {
	if (document.search_form.ben_city.value == "by city")
	document.search_form.ben_city.value = "";
} 

function restore_city() {
	if (document.search_form.ben_city.value == "")
	document.search_form.ben_city.value = "by city";
}



function clear_zip() {
	if (document.search_form.ben_zip.value == "by zip code")
	document.search_form.ben_zip.value = "";
} 

function restore_zip() {
	if (document.search_form.ben_zip.value == "")
	document.search_form.ben_zip.value = "by zip code";
}



function clear_start_date() {
	if (document.search_form.ben_eff_from.value == "mm/dd/yyyy")
	document.search_form.ben_eff_from.value = "";
} 

function restore_start_date() {
	if (document.search_form.ben_eff_from.value == "")
	document.search_form.ben_eff_from.value = "mm/dd/yyyy";
}



function clear_end_date() {
	if (document.search_form.ben_eff_to.value == "mm/dd/yyyy")
	document.search_form.ben_eff_to.value = "";
} 

function restore_end_date() {
	if (document.search_form.ben_eff_to.value == "")
	document.search_form.ben_eff_to.value = "mm/dd/yyyy";
}


function restore_all() {
	document.search_form.ben_name.value = "by name";
	document.search_form.ben_city.value = "by city";
	document.search_form.ben_zip.value = "by zip code";
	document.search_form.category_id[0].selected = true;
	document.search_form.ben_eff_from.value = "mm/dd/yyyy";
	document.search_form.ben_eff_to.value = "mm/dd/yyyy";
}
//end clears and restores search default values

//runs date chooser popups in search form
events.add(window, 'load', WindowLoad);

function WindowLoad()
{
	/*
		Example 1 Description:
		The DateChooser will close 200 milliseconds after mouseout.
		It will show 10 pixels to the right of, and 10 pixels above the click.
		It will call the FunctionEx1() function (below) when updated.
		Instead of using setLink() or setIcon(), so it attaches an event handler to 'datelinkex1' in the markup.
	*/

	var ndExample1 = document.getElementById('datechooser1');
	ndExample1.DateChooser = new DateChooser();

	// Check if the browser has fully loaded the DateChooser object, and supports it.
	if (!ndExample1.DateChooser.display)
	{
		return false;
	}

	ndExample1.DateChooser.setCloseTime(200);
	ndExample1.DateChooser.setXOffset(10);
	ndExample1.DateChooser.setYOffset(-10);
	ndExample1.DateChooser.setUpdateFunction(FunctionEx1);
	document.getElementById('datelink1').onclick = ndExample1.DateChooser.display;

	
}

function FunctionEx1(objDate)
{
	// objDate is a plain old Date object, with the getPHPDate() property added on.
	document.getElementById('dateinput1').value = objDate.getPHPDate('m/d/Y');
	return true;
}

events.add(window, 'load', WindowLoad2);

function WindowLoad2()
{
	/*
		Example 1 Description:
		The DateChooser will close 200 milliseconds after mouseout.
		It will show 10 pixels to the right of, and 10 pixels above the click.
		It will call the FunctionEx1() function (below) when updated.
		Instead of using setLink() or setIcon(), so it attaches an event handler to 'datelinkex1' in the markup.
	*/

	var ndExample2 = document.getElementById('datechooser2');
	ndExample2.DateChooser = new DateChooser();

	// Check if the browser has fully loaded the DateChooser object, and supports it.
	if (!ndExample2.DateChooser.display)
	{
		return false;
	}

	ndExample2.DateChooser.setCloseTime(200);
	ndExample2.DateChooser.setXOffset(10);
	ndExample2.DateChooser.setYOffset(-10);
	ndExample2.DateChooser.setUpdateFunction(FunctionEx2);
	document.getElementById('datelink2').onclick = ndExample2.DateChooser.display;

	
}

function FunctionEx2(objDate)
{
	// objDate is a plain old Date object, with the getPHPDate() property added on.
	document.getElementById('dateinput2').value = objDate.getPHPDate('m/d/Y');
	return true;
}
//end runs date chooser popups in search form