/**
 * @author ibex.pl
 */
/* google maps */
var mapa_walbrzych_center = new GLatLng(50.787055, 16.287918);
var mapa_piaskowa_center = new GLatLng(50.808701,16.285);
var mapa_szczawienko_center = new GLatLng(50.824292,16.304998);
var mapa_podzamcze_center = new GLatLng(50.823153,16.277704);
var mapa_staryzdroj_center = new GLatLng(50.786513,16.290665);
var mapa_srodmiescie_center = new GLatLng(50.770394,16.279035);
var mapa_nowemiasto_center = new GLatLng(50.773922,16.296887);
var mapa_rusionowa_center = new GLatLng(50.762441,16.330361);
var mapa_podgorze_center = new GLatLng(50.746069,16.295342);
var mapa_poniatow_center = new GLatLng(50.793241,16.316929);
var mapa_lubiechow_center = new GLatLng(50.830364,16.323752);
var mapa_ksiaz_center = new GLatLng(50.841069,16.30075);
var mapa_sobiecin_center = new GLatLng(50.762929,16.242299);
var mapa_bialykamien_center = new GLatLng(50.789443,16.257405);
var mapa_gaj_center = new GLatLng(50.75264,16.26749);
var mapa_glinik_center = new GLatLng(50.736835,16.265945);
var mapa_konradow_center = new GLatLng(50.794923,16.235862);
var mapa_szczawnozdroj_center = new GLatLng(50.806097,16.25144);

var default_zoom = 12;
var district_zoom = 15;
var map;
var marker;

function onstart() {
}

function TextualZoomControl() {
}
TextualZoomControl.prototype = new GControl();

// Creates a one DIV for each of the buttons and places them in a container
// DIV which is returned as our control element. We add the control to
// to the map container and return the element for the map class to
// position properly.
TextualZoomControl.prototype.initialize = function(map) {
  var container = document.createElement("div");

  var zoomInDiv = document.createElement("div");
  this.setButtonStyle_(zoomInDiv);
  container.appendChild(zoomInDiv);
  zoomInDiv.appendChild(document.createTextNode("Przybliż"));
  GEvent.addDomListener(zoomInDiv, "click", function() {
    map.zoomIn();
  });

  var zoomOutDiv = document.createElement("div");
  this.setButtonStyle_(zoomOutDiv);
  container.appendChild(zoomOutDiv);
  zoomOutDiv.appendChild(document.createTextNode("Oddal"));
  GEvent.addDomListener(zoomOutDiv, "click", function() {
    map.zoomOut();
  });

  map.getContainer().appendChild(container);
  return container;
}

// By default, the control will appear in the top left corner of the
// map with 7 pixels of padding.
  TextualZoomControl.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
}

// Sets the proper CSS for the given button element.
TextualZoomControl.prototype.setButtonStyle_ = function(button) {
  button.style.textDecoration = "none";
  button.style.color = "#0000cc";
  button.style.backgroundColor = "white";
  button.style.font = "small Arial";
  button.style.border = "1px solid black";
  button.style.padding = "2px";
  button.style.marginBottom = "3px";
  button.style.textAlign = "center";
  button.style.width = "6em";
  button.style.cursor = "pointer";
}      	


function load() {

	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.addControl(new TextualZoomControl())
		map.addControl(new GOverviewMapControl());
		map.enableContinuousZoom();
		map.enableDoubleClickZoom();
        map.setCenter(mapa_walbrzych_center, 12);
      }
      
	parent.$('.dzielnica').click(function(){
		var variable_name = parent.$(this).attr('id').concat("_center");
		//alert(variable_name);
        if (parent.$(this).attr('id') == 'mapa_walbrzych') {
        	map.setZoom(default_zoom);
        }
        else {
        	map.setZoom(district_zoom);
        }
        map.panTo(eval(variable_name));
	});
      
}


