// menu functions
var showOutdoors = true;
var showCuisines= true;

function toggleOutdoors(wSelector, wText) {
	showOutdoors = !showOutdoors;
	toggleAll(wSelector, wText,showOutdoors);
}
function toggleCuisines(wSelector, wText) {
	showCuisines = !showCuisines;
	toggleAll(wSelector, wText,showCuisines);
	
}
function toggleAll(wSelector, wText,showAll) {
	runAllInputs($(wSelector), 'checkbox', function(obj) { obj.checked = showAll });
	var showText = document.getElementById(wText);
	var showTextHTML;
	if (!showAll) showTextHTML = "Show All";
	else showTextHTML = "Hide All";
	showText.innerHTML = showTextHTML;
	
	$J("#" + wSelector + " .dropItem").each(function(){
			checkDropSet(this);
		})
	updateSelectedOutdoorCategories();
	updateSelectedCuisineCategories();	
	triggerRefresh();
}





function triggerRefresh() {
	setTimeout('setPoints();', 100);
}

var cDrop;
var dropTimeout;
function showDrop(show, element) {
	if (cDrop != $(element))	hideDropNow(cDrop);		// hide any open menus	
	cDrop = $(element) || cDrop;
	if (!cDrop) return;
	window.clearTimeout(dropTimeout);	
	if (show) {
		//cDrop.style.display = "block";
		$J(cDrop).fadeIn(300);
	}
	else 
		dropTimeout = window.setTimeout(function() { hideDropNow(cDrop); },350);
}


function hideDropNow(obj) {
	if (!cDrop) cDrop = obj;
	if (!cDrop) return;
	clearTimeout(dropTimeout);
	cDrop.style.display = "none";
}

function switchLocation() {
	clearRequests();
	var locationID = $F('drpLocations')
	if (locationID > 0 &&  locationID != "0" && locationID != curLocation)
	{
		var location = null;
		mapLocations.each(function(item) {
			if(item) {
				if (item.LocID == locationID)
				{
					location = item;
				}
			}
		});
		$D(sprintf('Setting map to Lat: %d, Lng: %d, Zoom; %d', location.Pos.lat(),location.Pos.lng(), location.Zoom));
		map.setCenter(location.Pos);
		map.setZoom(location.Zoom);
		curLocation = locationID;
	}
}
