function ShowAll(cnt)
{

	//cnt = cnt+1
	cnt = 30;
	for(i=1; i<cnt; i++)
	{
		//alert(i);
		if (document.getElementById('service' + i))
		{
			var style = document.getElementById('service' + i).style;
			style.display = style.display? "":"block";
		}
	}
	
	if (document.getElementById("expand").innerHTML == 'Collapse All')
	{
		document.getElementById("expand").innerHTML = 'Expand All';
	}
	else
	{
		document.getElementById("expand").innerHTML = 'Collapse All';
	}
}

function ShowHide(whichLayer, img)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";

		if (img)
		{
			if (style2.display == "block")
			{
				var theimage = document.getElementById('img' + img);
				theimage.src  = "images/minus.gif";
			}
			else
			{
				var theimage = document.getElementById('img' + img);
				theimage.src  = "images/plus.gif";
			}
		}
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}

function init()
{
	optionTest = true;
	lgth = document.forms['searchform'].town.options.length - 1;
	document.forms['searchform'].town.options[lgth] = null;
	if (document.forms['searchform'].town.options[lgth]) optionTest = false;
}

function populate()
{
	if (!optionTest) return;

	var box = document.forms['searchform'].county;
	var number = box.options[box.selectedIndex].value;
	
	//alert(number);
	if (number != 0)
	{
		if (!number) return;
			var list = store[number];

		var box2 = document.forms['searchform'].town;
		box2.options.length = 0;

		for(i=0; i<list.length; i+=2)
		{
			box2.options[i/2] = new Option(list[i],list[i+1]);
		}
	}
}
	
function validateTownForm(theForm)
{
	var returnValue = true;
	var errMessage = "";

	// Validate town
	if(theForm.town.value == "")
	{
		errMessage += "Please select at least one town.\n";
		returnValue = false;
	}
	
	if(!returnValue)
		alert(errMessage);

	return returnValue;
}
	
function validateZipForm(theForm)
{
	var returnValue = true;
	var errMessage = "";
	
	// Validate zipcode
	if(theForm.zipcode.value == "")
	{
		errMessage += "Please enter zip code.\n";
		returnValue = false;
	}
	else if (isNaN(theForm.zipcode.value))
	{
		errMessage += "Please enter a numeric value for zip code.\n";
		returnValue = false;
	}
	else if (theForm.zipcode.value.length != 5)
	{
		errMessage += "Please enter a five-digit zip code.\n";
		returnValue = false;
	}
	
	if(!returnValue)
		alert(errMessage);

	return returnValue;
}

function moveOption(fromSelectBxID, toSelectBxID, action)
{
	var fromSelectBx = eval("document.searchform." + fromSelectBxID);
	var toSelectBx   = eval("document.searchform." + toSelectBxID);

	if(fromSelectBx.selectedIndex != -1)
	{
		if (action == "1")
		{
			var fromSelectBxLen = fromSelectBx.length;
			for(i=0; i<fromSelectBxLen; i++)
				if(fromSelectBx.options[i].selected)
				{
					if (fromSelectBx.options[i].value != 0)
						toSelectBx.options[toSelectBx.length] = new Option(fromSelectBx.options[i].text, fromSelectBx.options[i].value, false, false);
				}
		}
		else if (action == "-1")
		{
			var toSelectBxLen = toSelectBx.length;
			for(i=toSelectBxLen-1; i>=0; i--)
				if(toSelectBx.options[i].selected)
					toSelectBx.options[i] = null;
		}
	}
	else
	{
		if (action == "-1")
		{
			var toSelectBxLen = toSelectBx.length;
			for(i=toSelectBxLen-1; i>=0; i--)
                  if(toSelectBx.options[i].selected)
   	   	                toSelectBx.options[i] = null;
		}
	}
}

function selectAll()
{
	temp = "document.searchform.areasServed";
	source = eval(temp);

	for(x=0; x<(source.length); x++)
	{
		source.options[x].selected = "true";
	}
}


function validateForm(theForm)
{
	// ---------------------------------//
	temp = "document.searchform.areasServed";
	source = eval(temp);

	for(x=0; x<(source.length); x++)
	{
		source.options[x].selected = "true";
	}
	// ---------------------------------//
	
	//name
	if(theForm.name.value == "")
	{
		alert("Please enter a provider name.\n");
		theForm.name.focus();
		return false;
	}

	//address
	if(theForm.address.value == "")
	{
		alert("Please enter a street address name.\n");
		theForm.address.focus();
		return false;
	}

	//city
	if(theForm.city.value == "")
	{
		alert("Please enter a city.\n");
		theForm.city.focus();
		return false;
	}

	//state
	if(theForm.state.selectedIndex == 0)
	{
		alert("Please select a state.\n");
		theForm.state.focus();
		return false;
	}

	//zip code
	if(theForm.zipcodeid.selectedIndex == 0)
	{
		alert("Please select a zip code.\n");
		theForm.zipcodeid.focus();
		return false;
	}

	//phone
	if(theForm.phone.value == "")
	{
		alert("Please enter a phone number.\n");
		theForm.phone.focus();
		return false;
	}

	//fax
	if(theForm.fax.value == "")
	{
		alert("Please enter a fax number.\n");
		theForm.fax.focus();
		return false;
	}

	//fax
	if(theForm.fax.value == "")
	{
		alert("Please enter a fax number.\n");
		theForm.fax.focus();
		return false;
	}

	//contact name
	if(theForm.contactName.value == "")
	{
		alert("Please enter a contact name.\n");
		theForm.contactName.focus();
		return false;
	}

	//contact title
	if(theForm.contactTitle.value == "")
	{
		alert("Please enter a contact title.\n");
		theForm.contactTitle.focus();
		return false;
	}

	//contact phone
	if(theForm.contactPhone.value == "")
	{
		alert("Please enter a contact phone.\n");
		theForm.contactPhone.focus();
		return false;
	}

	//contact email
	if(theForm.contactEmail.value == "")
	{
		alert("Please enter a contact email.\n");
		theForm.contactEmail.focus();
		return false;
	}

	//areasServed
	if(theForm.areasServed.value == "")
	{
		alert("Please select at least one area that this location serves.\n");
		theForm.areasServed.focus();
		return false;
	}

	//Daily Hours of Operation
	if(theForm.serviceHour.value == "")
	{
		alert("Please select at least one option from Daily Hours of Operation.\n");
		theForm.serviceHour.focus();
		return false;
	}

	//Seasonal Hours of Operation
	if(theForm.seasonalHour.value == "")
	{
		alert("Please select at least one option from Seasonal Hours of Operation.\n");
		theForm.seasonalHour.focus();
		return false;
	}

	//Age group
	if(theForm.ageGroup.value == "")
	{
		alert("Please select at least one option from Age Group.\n");
		theForm.ageGroup.focus();
		return false;
	}

	//Target
	if(theForm.target.value == "")
	{
		alert("Please select at least one option from Target Population.\n");
		theForm.target.focus();
		return false;
	}

	//Enrollment Status
	if(theForm.EnrollmentStatus.value == "")
	{
		alert("Please select at least one option from Enrollment Status.\n");
		theForm.EnrollmentStatus.focus();
		return false;
	}

	//Eligibility Requirements
	if(theForm.eligibility.value == "")
	{
		alert("Please select at least one option from Eligibility Requirements.\n");
		theForm.eligibility.focus();
		return false;
	}

	//Language
	if(theForm.language.value == "")
	{
		alert("Please select at least one option from Language.\n");
		theForm.language.focus();
		return false;
	}

	return true;
}

