$(document).ready(function(){ 
	/*
	$('UL.members LI.item').each(function(i,a){
		$('H2 A', a).click(function(){
			$(a).toggleClass('closed');
			return false;
		});
	});
	$('UL.members LI.item').addClass('closed');
	*/

	$('#search_company').superinput({
		canAdd: false,
		suggestURL: js_site_url + 'static/TehnopolMap/searchCompany/' + _var.active_lang,
		cellSeparator: ',',
		limit: 1,
		value: '',
		onItemSelect: compList.showCompanyInfo,
		postExisting: false
	});
});

var map;
var kmlObject;
var kmlRoad;
var ge;

var vfdoors_map_fn = function(){

	map = new GMap2(document.getElementById("vfdoors_div"));

	map.setCenter(new GLatLng(59.3979, 24.6589), 16);
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl())
	map.addMapType(G_SATELLITE_3D_MAP);
	map.enableContinuousZoom();

	var allowedBounds = map.getBounds();

	GEvent.addListener(map, "move", function() {
		keepBounds(map, allowedBounds);
	});

	if (!google.earth.isInstalled()) {
		$('#vfdoors_sidebar').before('<div class="ge_missing">' + _var.msg_install_google_earth + '</div>');
		map.setMapType(G_SATELLITE_3D_MAP);
	} else {
		map.setMapType(G_SATELLITE_3D_MAP);
	}

	map.getEarthInstance(function(geInstance){

		ge = geInstance;

		if (google.earth.fetchKml) {
			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_01-07.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_08.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_09.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_10.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_11+12.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_13.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_15+16.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_17.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_18.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_19.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_21.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_22.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_23.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_24.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_25.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_lisa1.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_lisa2.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});

			google.earth.fetchKml(ge, js_site_url + 'visiofly/models/Tehnopol_lisa3.kmz', function(obj) {
				// set global variable
				kmlObject = obj;
				ge.getFeatures().appendChild(kmlObject);
			});
		}

		var gfn = function (){
			if (ge!=null && ge.getView != null) {
				var camera = ge.getView().copyAsCamera(ge.ALTITUDE_RELATIVE_TO_GROUND);
				camera.setTilt(camera.getTilt() + 40.0);
				camera.setLatitude(camera.getLatitude() - 0.01);
				ge.getView().setAbstractView(camera);
			}
		}
		// setTimeout(gfn, 10);
	});

	compList.init(map);

	var mt = map.getMapTypes();
	for (var i = 0; i < mt.length; i++) {
		mt[i].getMinimumResolution = function() { return 15; }
		mt[i].getMaximumResolution = function() { return 17; }
	}
};

function keepBounds(map, allowedBounds) {
	// Perform the check and return if OK
	if (allowedBounds.contains(map.getCenter())) {
		return;
	}
	// It`s not OK, so find the nearest allowed point and move there
	var C = map.getCenter();
	var X = C.lng();
	var Y = C.lat();

	var AmaxX = allowedBounds.getNorthEast().lng();
	var AmaxY = allowedBounds.getNorthEast().lat();
	var AminX = allowedBounds.getSouthWest().lng();
	var AminY = allowedBounds.getSouthWest().lat();

	if (X < AminX) {X = AminX;}
	if (X > AmaxX) {X = AmaxX;}
	if (Y < AminY) {Y = AminY;}
	if (Y > AmaxY) {Y = AmaxY;}
	//alert ("Restricting "+Y+" "+X);
	map.setCenter(new GLatLng(Y, X));
}

var compList = {
	list: [
		{"id":"1","title":"Tehnopoli \u00e4riinkubaator","name":"Tehnopoli \u00e4riinkubaator","address":"M\u00e4ealuse 4","text":null,"latitude":"59.3965","longitude":"24.6566","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee13.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"2","title":"Tehnopoli \u00e4riinkubaator","name":"Tehnopoli \u00e4riinkubaator","address":"M\u00e4ealuse 4","text":null,"latitude":"59.3969","longitude":"24.6563","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee11.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"4","title":"TT\u00dc puidumaja","name":"TT\u00dc puidumaja","address":"Teaduspargi 5","text":null,"latitude":"59.3974","longitude":"24.6567","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee10.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"5","title":"M\u00e4ealuse 2\/2","name":"M\u00e4ealuse 2\/2","address":"M\u00e4ealuse 2\/2","text":null,"latitude":"59.3963","longitude":"24.6573","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee14.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"6","title":"M\u00e4ealuse 2\/2","name":"M\u00e4ealuse 2\/2","address":"M\u00e4ealuse 2\/2","text":null,"latitude":"59.3962","longitude":"24.6587","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee15.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"7","title":"M\u00e4ealuse 2\/3","name":"M\u00e4ealuse 2\/3","address":"M\u00e4ealuse 2\/3","text":null,"latitude":"59.397","longitude":"24.6573","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee12.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"8","title":"Tehnopol","name":"Tehnopol","address":"Teaduspargi 6\/1","text":null,"latitude":"59.3981","longitude":"24.6573","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee09.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"9","title":"Elektroonikamaja, Teaduspargi 6\/2","name":"Elektroonikamaja","address":"Teaduspargi 6\/2","text":null,"latitude":"59.3985","longitude":"24.6573","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee02.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"10","title":"Teaduspargi 8","name":"Teaduspargi 8","address":"Teaduspargi 8","text":null,"latitude":"59.3994","longitude":"24.6565","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee01.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"11","title":"M\u00e4ealuse 3\/2","name":"M\u00e4ealuse 3\/2","address":"M\u00e4ealuse 3\/2","text":null,"latitude":"59.3971","longitude":"24.6599","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee16.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"12","title":"M\u00e4ealuse 3\/1","name":"M\u00e4ealuse 3\/1","address":"M\u00e4ealuse 3\/1","text":null,"latitude":"59.3968","longitude":"24.6607","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee18.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"13","title":"M\u00e4ealuse 3\/1","name":"M\u00e4ealuse 3\/1","address":"M\u00e4ealuse 3\/1","text":null,"latitude":"59.3971","longitude":"24.6606","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee17.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"14","title":"Akadeemia tee 15b","name":"Akadeemia tee 15b","address":"Akadeemia tee 15b","text":null,"latitude":"59.3967","longitude":"24.6613","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee19.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"15","title":"Akadeemia tee 15b","name":"Akadeemia tee 15b","address":"Akadeemia tee 15b","text":null,"latitude":"59.3975","longitude":"24.6613","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee20.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"16","title":"TT\u00dc Loodusteaduste maja Akadeemia tee 15","name":"TT\u00dc Loodusteaduste maja","address":"Akadeemia tee 15","text":null,"latitude":"59.3976","longitude":"24.6622","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee21.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"17","title":"Akadeemia tee 15a","name":"Akadeemia tee 15a","address":"Akadeemia tee 15a","text":null,"latitude":"59.3972","longitude":"24.6629","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee22.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"18","title":"K\u00fcberneetikamaja, Akadeemia tee 21 B","name":"K\u00fcberneetikamaja","address":"Akadeemia tee 21 B","text":null,"latitude":"59.3983","longitude":"24.6615","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee08.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"19","title":"K\u00fcberneetikamaja, Akadeemia tee 21 A","name":"K\u00fcberneetikamaja","address":"Akadeemia tee 21 A","text":null,"latitude":"59.3979","longitude":"24.6598","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee07.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"20","title":"K\u00fcberneetikamaja, Akadeemia tee 21 C","name":"K\u00fcberneetikamaja","address":"Akadeemia tee 21 C","text":null,"latitude":"59.3982","longitude":"24.6598","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee06.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"21","title":"K\u00fcberneetikamaja, Akadeemia tee 21 G, F","name":"K\u00fcberneetikamaja","address":"Akadeemia tee 21 G, F","text":null,"latitude":"59.3983","longitude":"24.6581","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee03.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"22","title":"K\u00fcberneetikamaja, Akadeemia tee 21 E","name":"K\u00fcberneetikamaja","address":"Akadeemia tee 21 E","text":null,"latitude":"59.3983","longitude":"24.659","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee04.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37},
		{"id":"23","title":"K\u00fcberneetikamaja, Akadeemia tee 21 D","name":"K\u00fcberneetikamaja","address":"Akadeemia tee 21 D","text":null,"latitude":"59.3983","longitude":"24.6598","kml":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/logos\/teekonnad\/tee05.kml","icon":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_active.png","icon_hi":"http:\/\/www.tehnopol.ee\/visiofly\/gfx\/markers\/kinnisv_37px_map_highlight.png","iconSizeX":37,"iconSizeY":37}
	],
	objlist: {},
	init: function(map){
		compList.drawList(map);
		window.onresize = function () { compList.reloadList(map); }
	},
	drawList: function(map){
		$.each(compList.list, function(i, obj){
			var curobj = compList.createMarker(obj);
				compList.objlist[i] = obj;
				compList.objlist[i]['marker'] = curobj;
			map.addOverlay(curobj);
		});
	},
	reloadList: function(map){
		map.clearOverlays();
		compList.drawList(map);
		return true;
	},
	showRoad: function(obj) {
		if (kmlRoad) {
			ge.getFeatures().removeChild(kmlRoad);
			// compList.reloadList(map);
		}
		if (obj.kml) {
			google.earth.fetchKml(ge, obj.kml, function(obj) {
				// set global variable
				kmlRoad = obj;
				ge.getFeatures().appendChild(kmlRoad);
			});
		}
	},
	createMarker: function(obj) {
		var markerOptions;
		var point		= new GLatLng(obj['latitude'],obj['longitude']);
		var that		= this;
		var icon		= new GIcon(G_DEFAULT_ICON);

		if (obj['icon']) {
			icon.image = obj['icon'];
			icon.shadow = '';
			if (obj['iconSizeX'] > 0 && obj['iconSizeY'] > 0) {
				icon.iconSize	= new GSize(obj['iconSizeX'], obj['iconSizeY']);
				icon.imageMap	= icon.imageMap = [0, 0, obj['iconSizeY'], 0, obj['iconSizeY'], obj['iconSizeX'], 0, obj['iconSizeX']];
			}
		}
		markerOptions = {icon: icon, draggable: false};
		var marker = new GMarker(point,markerOptions);

		GEvent.addListener(marker, "click", function() {
			compList.showRoad(obj);
			compList.loadCompaniesByAddress(obj.address);
		});

		return marker;
	},
	getObjectById: function(id) {
		$.each(compList.objlist, function(i, obj){
			if (obj.id == id) {
				return obj;
			}
		});
	},
	showCompanyInfo: function(param1, param2) {
		compList.loadCompaniesByCompanyId(param1.selectedItem.id);
	},
	loadCompaniesByCompanyId: function(companyId) {
		$.post(js_site_url + 'static/TehnopolMap/loadCompaniesByCompanyId/' + _var.active_lang, {company_id: companyId}, function(msg){
			$('#companies_list').html(msg);
			$('UL.members LI.item').each(function(i,a){
				$('H2 A', a).click(function(){
					$(a).toggleClass('closed');
					return false;
				});
			});
			$('UL.members LI.item:not("#result_' + companyId +'")').addClass('closed');
		});
	},
	loadCompaniesByAddress: function(address) {
		$.post(js_site_url + 'static/TehnopolMap/loadCompaniesByAddress/' + _var.active_lang, {address: address}, function(msg){
			$('#companies_list').html(msg);
			$('UL.members LI.item').each(function(i,a){
				$('H2 A', a).click(function(){
					$(a).toggleClass('closed');
					return false;
				});
			});
			$('UL.members LI.item').addClass('closed');
		});
	},
	showRoadByAddress: function(address) {
		if (kmlRoad) {
			ge.getFeatures().removeChild(kmlRoad);
		}
		compList.reloadList(map);
		map.panTo(new GLatLng(59.3979, 24.6589));
		$.each(compList.list, function(i, obj){
			if (obj.address == address) {
				compList.showRoad(obj);
				var nLoc = new GLatLng(obj.latitude, obj.longitude);
				map.panTo(nLoc);
			}
		});
	}
};


