function ihcOpenWin(url) {
	var ihcMapWindow = window.open(url, "childWin", "width=990,height=700,resizable=yes,scrollbars=yes,top=5,left=5,border=0");
	ihcMapWindow.focus();
}

function triggerSearch(selectId)
{
	$('#resultsPerPage').attr("value", $("#"+selectId).attr("value"));
	$("form").submit();
}

function convertToDistance(sliderValue)
{
	switch (sliderValue) 
	{
	  	case 0:
			return 0;
	  	case 20:
			return 5;
	  	case 40:
			return 10;
	  	case 60:
			return 25;
	  	case 80:
			return 50;
	  	case 100:
			return 100;
	 	default:
			return 0;
	}
}

function convertToSliderValue(distance)
{
	switch (distance) 
	{
	  	case 5:
			return 20;
	  	case 10:
		 	return	40;
	  	case 25:
			return 60;
	  	case 50:
			return 80;
	  	case 100:
			return 100;
		default:
			return 0;	
	}
}

function isNotEmpty(prop)
{
	if(prop !== null && prop !== "")
	{
		return true;	
	}
	return false;
}

function appendCriteria(propValue, name, str)
{
	if(isNotEmpty(propValue))
	{
		if(isNotEmpty(str))
		{
			return " and " + name;
		}
		else
		{
			return name;
		}
	}
	return "";
}

function submitStats(brand)
{
	try
  	{
		s.pageName="Facility Search Results";
		s.prop2 = $("#name").value;
		s.prop3 = $("#type :selected").text();
		s.prop4 = $("#service").value;
		s.prop5 = brand;		
		
		s.prop1 = "";
		if(isNotEmpty(s.prop2))
		{
			s.prop1 = "Name";
		}	
			
		s.prop1 += appendCriteria(s.prop3, "Type", s.prop1);
		s.prop1 += appendCriteria(s.prop4, "Service", s.prop1);
		s.prop1 += appendCriteria($("#city").attr("value"), "City", s.prop1);
		s.prop1 += appendCriteria($("#zipCode").attr("value"), "Zip", s.prop1);
		s.prop1 += appendCriteria($("#county").attr("value"), "County", s.prop1);
		s.prop1 += appendCriteria($("#plan :selected").text(), "Plan", s.prop1);
		
		if(isNotEmpty($("#distance").value) && $('#distance').value > 0)
		{
			s.prop1 += appendCriteria("Distance", "Distance", s.prop1);
		}
		
		
		if($("#hoursWeekdayEarly").attr("checked") || $("#hoursWeekdayLate").attr("checked") || 
				$("#hoursWeekend").attr("checked") || $("#hours24").attr("checked"))
		{
			s.prop1 += appendCriteria("Extended hours", "Extended hours", s.prop1);
		}
		
    	s.t();
  	}
  	catch(e){ }
}