var map;
var center_address = '2501 S Grange, Sioux Falls, SD';
var theMarkers = {};
var have_search = false;
function initMap() {
	// Create a map object
	map = new YMap(
		$('search_results_mapContainer'),
		YAHOO_MAP_REG,	// or YAHOO_MAP_HYB
		new YSize(522,500));
	map.drawZoomAndCenter(center_address, 6);		// Display the map centered on given address
	map.addPanControl();							// Add a pan control
	map.addZoomLong();								// Add a slider zoom control
	map.addTypeControl();							// Add a map type control

	Event.observe($('map_bttn'), 'click', function(){
			showHideMap();
			return false;
		}, false);

	Effect.BlindUp('search_results_mapContainer',{queue:'end',duration:.1});
	Effect.BlindDown('map_bttn',{queue: 'end',duration:.25});
}
function showMapStuff() {
	$('map_stuff').style.display='block';
}
function hideMapStuff() {
	$('map_stuff').style.display='none';
}
function showMap() {
//	Effect.BlindDown('search_results_mapContainer',{queue: 'end',duration: .25});
	Effect.Appear('search_results_mapContainer',{queue: 'end',duration: .25});
	have_search = true;
	map_showing = true;
}
function hideMap() {
	Effect.BlindUp('search_results_mapContainer',{queue: 'end',duration: .25});
	map_showing = false;
}
var map_showing = false;
function showHideMap() {
//	Effect.toggle('search_results_mapContainer','blind',{queue: 'end',duration: .25});
	if (map_showing) hideMap();
	else showMap();
}
function showDetails(hid) {
	if (hid) {
		top.location.href='http://'+top.location.host+'?hid='+hid;
	}
}
function placeMarker(address, html, hid) {
	if (!hid.toString().match(/^\d+$/)) return false;
	var myImg = new YImage();
	myImg.src = 'http://'+top.location.host+'/images/markerhouse.gif';
	myImg.size = new YSize(21,27);
	//myImg.size = new YSize(30,33);
	myImg.offsetSmartWindow = new YCoordPoint(0,0);
	var marker = new YMarker(address, myImg, 'hid'+hid);
	marker.setSmartWindowColor('grey');
	marker.addAutoExpand(html);
	//marker.openAutoExpand();
	map.addOverlay(marker);
	eval('theMarkers.hid'+hid+'=marker;');
}
function showMarkerInfo(hid) {
	if (!hid.toString().match(/^\d+$/)) return false;
	eval('if(theMarkers.hid'+hid+')theMarkers.hid'+hid+'.openAutoExpand()');
}
function hideMarkerInfo(hid) {
	if (!hid.toString().match(/^\d+$/)) return false;
	eval('if(theMarkers.hid'+hid+')theMarkers.hid'+hid+'.closeAutoExpand()');
}

