var points = new Array();
//points[0]={gmaplat:"52.145789",gmaplng:"21.066135"};
//points[1]={gmaplat:"52.150789",gmaplng:"21.066135"};
points[0]={gmaplat:"52.171299",gmaplng:"21.082336"};
points[1]={gmaplat:"52.171194",gmaplng:"21.08242"};

function Engine() {
	this.points = points; // global variable
	
	this.map; // GMap2 object
	
	this.stdZoom = 14;
	
	this.geocoder = new GClientGeocoder();
	
	this.icon;
	
	this.addPoint = null;
	
	//this.localization; // Searched by user
	
	this.retStdZoom = function retStdZoom() {
		return this.stdZoom;
	}
	
	this.load = function load() {
	if (GBrowserIsCompatible()) {
			this.map = new GMap2(document.getElementById("map"));
			//this.map.setUIToDefault();
			var customUI = new GMapUIOptions();
			var customMaptypecontrol = new GMenuMapTypeControl(true,false);
			customUI.maptypes = {};
			customUI.zoom = {};
			customUI.controls = {};
			customUI.maptypes.normal = true;
			customUI.maptypes.hybrid = true;
			customUI.maptypes.satellite = true;
			customUI.zoom.doubleclick = true;
			customUI.zoom.scrollwheel = true;
			customUI.controls.smallzoomcontrol3d = false;
			customUI.controls.largemapcontrol3d = true;
			customUI.controls.menumaptypecontrol = false;
			this.map.setUI(customUI);
			this.map.addControl(customMaptypecontrol);

			var mt = this.map.getMapTypes();
			var s = this.points[0];
			for (var i=0; i<mt.length; i++) {
				mt[i].getMinimumResolution = function() {return 6;}
				mt[i].getMaximumResolution = function() {return 17;}
			}
			//this.map.addControl(new GScaleControl());
			//this.map.addControl(new GLargeMapControl3D());
			//this.map.setMapType(G_HYBRID_MAP);

			this.map.setCenter(new GLatLng(this.points[1].gmaplat, this.points[1].gmaplng), this.retStdZoom());
			var baseIcon = new GIcon();
			baseIcon.iconSize=new GSize(49,38);
			baseIcon.shadowSize=new GSize(60,56);
			baseIcon.iconAnchor=new GPoint(24,40);
			baseIcon.infoWindowAnchor=new GPoint(12,38);

			this.icon = new GIcon(baseIcon, 'uploads/ikona.png');
			this.setMarkers();
			this.points[0].marker.openInfoWindowTabsHtml(engine.constructHTML());
		}
		else {
			// unable to use service, notice the user
		}
	}

		this.constructHTML = function constructHTML() {
			var infoHTML = '<p>Nasz adres:</p><p><strong>AGA ANALYTICAL</strong></p><p>Wiertnicza 52A<br>02-952 Warszawa<br>tel.: 022 649 10 41<br>fax: 022 859 12 23<br>e-mail: <a href="mailto:biuro@aga-analytical.com.pl">biuro@aga-analytical.com.pl</a></p>';
			var tab = new Array(new GInfoWindowTab('info', infoHTML));
			return tab;
		}

		this.createMarker = function createMarker(point, icon, title) {
		var marker = new GMarker(point, icon);
		
		GEvent.addListener (
			marker,
			"click",
			function() {
				//marker.openInfoWindowTabsHtml(engine.constructHTML(servIndex));
				marker.openInfoWindowTabsHtml(engine.constructHTML());
			}
		);
		return marker;
	}
	
	this.setMarkers = function setMarkers() {
			point = new GLatLng(this.points[0].gmaplat,this.points[0].gmaplng);
			this.points[0].marker = this.createMarker(point, this.icon);
			this.map.addOverlay(this.points[0].marker);
	}
} // End of Engine() class

var engine = new Engine();

window.onunload = function() {
	GUnload();
}

