var points = new Array();
points[0]={gmaplat:"52.211329",gmaplng:"20.961931"};
points[1]={gmaplat:"52.242289",gmaplng:"20.961931"};


function Engine() {
	this.points = points; // global variable

	this.map; // GMap2 object

	this.stdZoom = 12;

	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.setCenter(new GLatLng(s.gmaplat, s.gmaplng), this.retStdZoom());
			var baseIcon = new GIcon();
			baseIcon.iconSize=new GSize(60,48);
			baseIcon.shadowSize=new GSize(78,51);
			baseIcon.iconAnchor=new GPoint(30,48);
			baseIcon.infoWindowAnchor=new GPoint(60,48);

			this.icon = new GIcon(baseIcon, 'images/gIcon.png');
			this.setMarkers();
		}
		else {
			// unable to use service, notice the user
			alert('Nie udało się załadować mapy.');
		}
	}

		this.createMarker = function createMarker(point, icon, servIndex, title) {
		var marker = new GMarker(point, icon);

		GEvent.addListener (
			marker,
			"click",
			function() {
				//pokaz zdjęcie
				$('onyxHouseLayer').style.display = 'block';
			}
		);
		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.onload = function() {
	engine.load();
	//zainicjuj mechanizm do zminany zdjęć firmy
	Seasons.init();
}

window.onunload = function() {
	GUnload();
}
