//on property sub, submit offset
function submit_offset (num) {
	document.forms.search_submenu.offset.value=num;
	document.forms.search_submenu.submit();
}

//toggle view on properties
function toggle_view (img_obj) {
	view = document.forms.search_submenu.view.value;
	//alert (view);
	if (view == "map") {
		document.forms.search_submenu.view.value = "list";
		img_obj.src = '/i/button_map_v_list_list.gif';
	} else {
		document.forms.search_submenu.view.value = "map";
		img_obj.src = '/i/button_map_v_list_map.gif';
	}
	
	//resubmit form
	document.forms.search_submenu.submit();
}

//highlight result row large map
function highlight_row (resultRow) {
	//highlight row
	for (i=1; i<=10; i++) {
		window.document.getElementById("resultRow"+i).style.backgroundImage = 'url(/i/bg_selector.gif)';
	}
	window.document.getElementById("resultRow"+resultRow).style.backgroundImage = 'url(/i/bg_selector_on.gif)';
}

//open google map info window
function open_info(resultRow) {
	gmarkers[resultRow].openInfoWindowHtml(ghtmls[resultRow]);
	highlight_row (resultRow);
}

//use to geocode address strings
function geocode_address (geocoder, map_id, address, icon, bigmap, bounds, resultRow, html) {

	// Retrieve location information, add it to map
	geocoder.getLocations (
		address,
		function (response) {
		
			// Retrieve the object
			if (response.Placemark) {
				var place = response.Placemark[0];
			}
			
			
			if (place) {
				
				// Retrieve the latitude and longitude
				point = new GLatLng(place.Point.coordinates[1],
						  place.Point.coordinates[0]);
						
				// Create a marker
				marker = new GMarker(point, icon);
				
				// Add the marker to map
				map_id.addOverlay(marker);

				if (bigmap) {
					
					//add to markers array
					gmarkers[resultRow] = marker;
					ghtmls[resultRow] = html;
					
					//add listener to marker
					GEvent.addListener(gmarkers[resultRow], 'click', function() {
							gmarkers[resultRow].openInfoWindowHtml(ghtmls[resultRow]);
							highlight_row (resultRow);
						}
					);

					//Each time a point is found, extent the bounds to include it
					bounds.extend(point);

					//determine the zoom level from the bounds
					map_id.setZoom(map_id.getBoundsZoomLevel(bounds));
					
					//determine the centre from the bounds
					map_id.setCenter(bounds.getCenter());

				} else {

					// Center the map on this point
					map_id.setCenter(point, 13);
				
				}
			}
		}
	);
}