﻿// JScript File

function clearOverlays(map) {
	map.clearOverlays();
}

function setCenter(map, point, zoom) {
	map.setCenter(point, zoom); 
	map.setZoom(zoom);
}

function addOverlay(map, marker) {
	map.addOverlay(marker); 
}

function createDraggableMarker(map, lat, lon, image, hover, shadow, outLatitude, outLongitude) {
	//alert('creating');
	var GoogleMap1_Icon1 = new GIcon(); 
	GoogleMap1_Icon1.image = image; 
	GoogleMap1_Icon1.hover = hover; 
	GoogleMap1_Icon1.iconSize = new GSize(20, 32); 
	GoogleMap1_Icon1.shadow = shadow; 
	GoogleMap1_Icon1.shadowSize = new GSize(43, 32); 
	GoogleMap1_Icon1.iconAnchor = new GPoint(9, 32); 
	GoogleMap1_Icon1.infoWindowAnchor = new GPoint(10, 10); 
	
	var GoogleMap1_Marker1 = new BpMarker(new GLatLng(lat, lon), {icon:GoogleMap1_Icon1, draggable:true}); 
	GoogleMap1_Marker1.enableDragging();
	GoogleMap1_Marker1.setHoverImage(GoogleMap1_Icon1.hover); 
	
	var outLatControl = document.getElementById(outLatitude);
	var outLngControl = document.getElementById(outLongitude);
	
	GEvent.addListener(GoogleMap1_Marker1, "drag", function() {
		document.getElementById(outLatitude).value = GoogleMap1_Marker1.getPoint().lat();
		document.getElementById(outLongitude).value = GoogleMap1_Marker1.getPoint().lng();
	});
	
	addOverlay(map, GoogleMap1_Marker1);
	setCenter(map, GoogleMap1_Marker1.getLatLng(), 15);
}

function ping() {
	alert('Pong');
}