function setAll() {
  document.getElementById('id1').className = 'nchoosen';
	document.getElementById('id2').className = 'nchoosen';
	document.getElementById('id3').className = 'nchoosen';	
}

function showTel() {
  setAll();
  document.getElementById('id1').className = 'choosen';
	document.getElementById('mail').style.display = "none";
	document.getElementById('map').style.display = "none";
	document.getElementById('pruh').style.display = "block";
	document.getElementById('tele').style.display = "block";
}
function showEmail() {
  setAll();
  document.getElementById('id2').className = 'choosen';
	document.getElementById('tele').style.display = "none";
	document.getElementById('map').style.display = "none";
	document.getElementById('pruh').style.display = "block";
	document.getElementById('mail').style.display = "block";
}
function showMap() {
  setAll();
  document.getElementById('id3').className = 'choosen';
	document.getElementById('pruh').style.display = "none";
	document.getElementById('map').style.display = "block";
}
var map;
var gdir;
var geocoder = null;
var addressMarker;
var directions;
var marker;
  
function load() {
  if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("gmap"), {draggableCursor: 'pointer', draggingCursor: 'pointer'});	
    map.setCenter(new GLatLng(48.997467, 15.352922), 15);    
		map.addControl(new GSmallMapControl(),new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10)));
		directions = document.getElementById("directions");
		gdir = new GDirections(map, directions);
    GEvent.addListener(gdir, "load", onGDirectionsLoad);
    GEvent.addListener(gdir, "error", handleErrors);    
    map.addMapType(G_SATELLITE_3D_MAP);
    map.addControl(new GHierarchicalMapTypeControl());
    map.addMapType(G_NORMAL_MAP);
    //map.addMapType(G_SKY_VISIBLE_MAP);   
    map.removeMapType(G_SATELLITE_MAP);
    map.removeMapType(G_HYBRID_MAP);
    map.addOverlay(new GLayer("org.wikipedia.cs"));
    //map.addControl(new GLargeMapControl());
    //map.GMenuMapTypeControl(true);
    var infoTabs = [
			new GInfoWindowTab("Adresa", "<a href=\"index.html\" style=\"font-size:13px;\">Besídka</a><br /> Horní náměstí 522<br /> 378 81 Slavonice<br /> Tel.: +420 384 493 293<form action=\"#\" onsubmit=\"setDirections(this.from.value, this.to.value); return false\"><input type=\"text\" size=\"20\" id=\"fromAddress\" name=\"from\" value=\"Zadej adresu.\"/ onclick=\"this.value=''\"><br /><input type=\"text\" size=\"20\" id=\"toAddress\" name=\"to\" value=\"Slavonice\" /><br /><input style=\"margin-left:80px;\" name=\"submit\" type=\"submit\" value=\"Vyhledej\" /></form>")
		];
		marker = new GMarker(map.getCenter());
		GEvent.addListener(marker, "click", function() {
		  marker.openInfoWindowTabsHtml(infoTabs);
		});
		map.addOverlay(marker);
		marker.openInfoWindowTabsHtml(infoTabs);
	}
}	  
function setDirections(fromAddress, toAddress) {
  marker.closeInfoWindow();
  gdir.load("from: " + fromAddress + " to: " + toAddress);
  directions.style.display = "block";                  
}
function handleErrors(){
   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
     alert("Nebylo nalezeno místo odjezdu ! Prosím zkuste to znovu");
     //alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
     alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);   
   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
     alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
     alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);

   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
     alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
    
   else alert("An unknown error occurred.");
   
}
function onGDirectionsLoad(){ }
  




	