	var oldIE = /(MSIE (5\.5))|(MSIE 6)/.test(navigator.userAgent) && navigator.platform == "Win32";
    var map;
    var coords;

    var smallerMapWnd = {width:190, height:250};
    var smallerMapBorderWnd = {width:200, height:260};
    var smallerMapOuterWnd = {width:200};
    var smallerMapFrameWnd = {width:212};

    var largerMapWnd = {width:673, height:396};
    var largerMapBorderWnd = {width:683, height:406};
    var largerMapOuterWnd = {width:683};
    var largerMapFrameWnd = {width:695};
    
    function Load(outer, coordinates, markerInfoTab) 
    {
      if (GBrowserIsCompatible()) 
      {
		var itab = [
/*  			new GInfoWindowTab("EN", "This english text"),
  			new GInfoWindowTab("ä¸­æ-+", "chinese"),*/
//  			new GInfoWindowTab("Multilingual", "<img src=\"http://www.earthinpictures.com/world/usa/san_francisco/th_hilton_hotel.jpg\" width=\"20%\" height=\"20%\" title=\"nazov\"/><a href=\"#\">slovensky</a>")
  			new GInfoWindowTab("Multilingual", markerInfoTab)
		];
   	
	        function createMarker(point, infoTabs) {
			// Create our "tiny" marker icon
			var icon = new GIcon();
			icon.image = "/design/eipmarker.png";
			icon.shadow = "/design/eipmarkershad.png";
			icon.iconSize = new GSize(12, 20);
			icon.shadowSize = new GSize(22, 20);
			icon.iconAnchor = new GPoint(6, 20);
			icon.infoWindowAnchor = new GPoint(5, 1);
		
			var marker = new GMarker(point, icon);

			GEvent.addListener(marker, "mouseover", function() {
				Resize(1);
				marker.openInfoWindowTabsHtml(infoTabs);
			});

			return marker;
		}


		
/*SMALL MAP TYPE CONTROL*/		
		
		function SmallMapTypeControl() {}
		SmallMapTypeControl.prototype = new GControl();
		
		SmallMapTypeControl.prototype.initialize = function(map) 
		{
			var container = document.createElement("div");
			var mapDiv = document.createElement("div");
			var satDiv = document.createElement("div");
			var hybDiv = document.createElement("div");

			GEvent.addDomListener(mapDiv, "click", function() {map.setMapType(G_NORMAL_MAP);});
			GEvent.addDomListener(satDiv, "click", function() {map.setMapType(G_SATELLITE_MAP);});
			GEvent.addDomListener(hybDiv, "click", function() {map.setMapType(G_HYBRID_MAP);});

			container.style.width = "90px";
			container.style.height = "20px";
			container.style.textAlign = "left";
			if (oldIE)
				container.innerHTML = "<img src=\"/design/pixel.gif\" width=\"0px\" height=\"0px\" style=\"width:90px; height:20px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/design/pix-transp-orn.png', sizingMethod='scale'); z-index:-1; position:relative; top:0; left:0;\" />";
			else
				container.style.background = "url(\"/design/pix-transp-orn.png\")";	
			
		  mapDiv.style.position = "relative";
		  mapDiv.style.width = "26px";
		  mapDiv.style.height = "14px";
		  mapDiv.style.left = "3px";
		  mapDiv.style.top = "3px";
		  if (oldIE) mapDiv.style.top = "-17px";
		  mapDiv.style.cursor = "pointer";
		  mapDiv.style.background= "url(\"/design/but-map.png\") no-repeat";

		  satDiv.style.position = "relative";
		  satDiv.style.width = "26px";
		  satDiv.style.height = "14px";
		  satDiv.style.left = "32px";
		  satDiv.style.top = "-11px";
		  if (oldIE) satDiv.style.top = "-33px";
		  satDiv.style.cursor = "pointer";
		  satDiv.style.background= "url(\"/design/but-sat.png\") no-repeat";

		  hybDiv.style.position = "relative";
		  hybDiv.style.width = "26px";
		  hybDiv.style.height = "14px";
		  hybDiv.style.left = "61px";
		  hybDiv.style.top = "-25px";
		  if (oldIE) hybDiv.style.top = "-49px";
		  hybDiv.style.cursor = "pointer";
		  hybDiv.style.background= "url(\"/design/but-hyb.png\") no-repeat";

		  if (oldIE)
			  hybDiv.style.marginBottom = "-14px";	//lebo IE je sprosty magor, a vlozenim divov odignoruje vysku kontainera. Ak nie je definovany doctype strixt xhtml v IE7. V starsich aj tak...:)
			  
		  container.appendChild(mapDiv);
		  container.appendChild(satDiv);
		  container.appendChild(hybDiv);
		  map.getContainer().appendChild(container);
		  return container;
		}
		
		SmallMapTypeControl.prototype.getDefaultPosition = function() 
		{
		  return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(5, 5));
		}
				
/*RESIZE CONTROL*/
		function ResizeControl() {}
		ResizeControl.prototype = new GControl();
		
		ResizeControl.prototype.initialize = function(map) 
		{
			var container = document.createElement("div");
			var resDiv = document.createElement("div");
		  
			GEvent.addDomListener(resDiv, "click", function() {Resize();});
		  
			container.style.width = "46px";
			container.style.height = "36px";
			container.style.textAlign = "left";
			if (oldIE)
				container.innerHTML = "<img src=\"/design/pixel.gif\" width=\"0px\" height=\"0px\" style=\"width:46px; height:36px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/design/pix-transp-orn.png', sizingMethod='scale'); z-index:-1; position:relative; top:0; left:0;\" />";
			else
				container.style.background = "url(\"/design/pix-transp-orn.png\")";	
			
		  resDiv.style.position = "relative";
		  resDiv.style.left = "3px";
		  resDiv.style.top = "3px";
		  if (oldIE) resDiv.style.top = "-33px";
		  resDiv.style.border = "0";
		  resDiv.style.margin = "0";
		  resDiv.style.width = "40px";
		  resDiv.style.height = "30px";
		  resDiv.style.background = "url(\"/design/resize.png\") no-repeat";	
		  resDiv.style.cursor = "pointer";

		  if (oldIE)
			  resDiv.style.marginBottom = "-30px";	//lebo IE je sprosty magor, a vlozenim divov odignoruje vysku kontainera. Ak nie je definovany doctype strixt xhtml v IE7. V starsich aj tak...:)
		
		  container.appendChild(resDiv);
		  map.getContainer().appendChild(container);
		  return container;
		}
		
		ResizeControl.prototype.getDefaultPosition = function() 
		{
			return new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(5, 20));
		}
		
/*ZOOM CONTROL*/
		function ZoomControl() {}
		ZoomControl.prototype = new GControl();
		
		ZoomControl.prototype.initialize = function(map) 
		{
			var container = document.createElement("div");
			var zoomInDiv = document.createElement("div");
			var zoomOutDiv = document.createElement("div");

			GEvent.addDomListener(zoomInDiv, "click", function() {map.zoomIn();});
			GEvent.addDomListener(zoomOutDiv, "click", function() {map.zoomOut();});
		  
			container.style.width = "30px";
			container.style.height = "60px";
			container.style.textAlign = "left";
			if (oldIE)
				container.innerHTML = "<img src=\"/design/pixel.gif\" width=\"0px\" height=\"0px\" style=\"width:30px; height:60px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/design/pix-transp-orn.png', sizingMethod='scale'); z-index:-1; position:relative; top:0; left:0;\" />";
			else
				container.style.background = "url(\"/design/pix-transp-orn.png\")";	
			
			zoomInDiv.style.border = "0";
			zoomInDiv.style.margin = "0";
			zoomInDiv.style.width = "30px";
			zoomInDiv.style.height = "30px";
			zoomInDiv.style.cursor = "pointer";
			if (oldIE)
			{
				zoomInDiv.style.position = "relative";
				zoomInDiv.style.top = "-62px";
//				zoomInDiv.style.border = "1px solid green";
				zoomInDiv.innerHTML = "<img src=\"/design/pixel.gif\" width=\"0px\" height=\"0px\" style=\"width:30px; height:30px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/design/zoomin.png', sizingMethod='scale'); z-index:-1; position:relative; top:0; left:0;\" />";
			}
			else
				zoomInDiv.style.background = "url(\"/design/zoomin.png\") no-repeat";	

			zoomOutDiv.style.border = "0";
			zoomOutDiv.style.margin = "0";
			zoomOutDiv.style.width = "30px";
			zoomOutDiv.style.height = "30px";
			zoomOutDiv.style.cursor = "pointer";

			if (oldIE)
			{
				zoomOutDiv.style.position = "relative";
				zoomOutDiv.style.top = "-62px";
//				zoomOutDiv.style.border = "1px solid blue";
				zoomOutDiv.innerHTML = "<img src=\"/design/pixel.gif\" width=\"0px\" height=\"0px\" style=\"width:30px; height:30px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/design/zoomout.png', sizingMethod='scale'); z-index:-1; position:relative; top:0; left:0;\" />";
			}
			else
				zoomOutDiv.style.background = "url(\"/design/zoomout.png\") no-repeat";	

		  if (oldIE)
			  zoomOutDiv.style.marginBottom = "-90px";	//lebo IE je sprosty magor, a vlozenim divov odignoruje vysku kontainera. Ak nie je definovany doctype strixt xhtml v IE7. V starsich aj tak...:)
	
			container.appendChild(zoomInDiv);
			container.appendChild(zoomOutDiv);
			map.getContainer().appendChild(container);
			return container;
		}
		
		ZoomControl.prototype.getDefaultPosition = function() 
		{
			return new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(5, 35));
		}

/*NAVIG CONTROL*/		
		
		function NavigControl() {}
		NavigControl.prototype = new GControl();
		
		NavigControl.prototype.initialize = function(map) 
		{
			var container = document.createElement("div");
			
			var northDiv = document.createElement("div");
			var westDiv = document.createElement("div");
			var eastDiv = document.createElement("div");
			var southDiv = document.createElement("div");
			var returnDiv = document.createElement("div");

			GEvent.addDomListener(northDiv, "click", function() {map.panDirection(0, 1);});
			GEvent.addDomListener(westDiv, "click", function() {map.panDirection(1, 0);});
			GEvent.addDomListener(eastDiv, "click", function() {map.panDirection(-1, 0);});
			GEvent.addDomListener(southDiv, "click", function() {map.panDirection(0, -1);});
			GEvent.addDomListener(returnDiv, "click", function() {map.returnToSavedPosition(); map.savePosition();});
		  
			container.style.width = "80px";
			container.style.height = "80px";
			container.style.textAlign = "left";
//			container.style.border = "solid white 1px;";
			if (oldIE)
				container.innerHTML = "<img src=\"/design/pixel.gif\" width=\"0px\" height=\"0px\" style=\"width:80px; height:80px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/design/compass.png', sizingMethod='scale'); z-index:-1; position:relative; top:0; left:0;\" />";
			else
				container.style.background = "url(\"/design/compass.png\") no-repeat";	
			
//			northDiv.style.background ="red";
		  northDiv.style.position = "relative";
		  northDiv.style.width = "18px";
		  northDiv.style.height = "31px";
  		  northDiv.style.left = "31px";
		  northDiv.style.top = "0px";
		  if (oldIE) northDiv.style.top = "-80px";
		  northDiv.style.cursor = "pointer";

//			westDiv.style.background ="blue";
		  westDiv.style.position = "relative";
		  westDiv.style.width = "31px";
		  westDiv.style.height = "18px";
  		  westDiv.style.left = "0px";
		  westDiv.style.top = "0px";
		  if (oldIE) westDiv.style.top = "-80px";
		  westDiv.style.cursor = "pointer";

//			returnDiv.style.background ="yellow";
		  returnDiv.style.position = "relative";
		  returnDiv.style.width = "18px";
		  returnDiv.style.height = "18px";
  		  returnDiv.style.left = "31px";
		  returnDiv.style.top = "-18px";
		  if (oldIE) returnDiv.style.top = "-98px";
		  returnDiv.style.cursor = "pointer";
		  
//			eastDiv.style.background ="magenta";
  		  eastDiv.style.position = "relative";
		  eastDiv.style.width = "31px";
		  eastDiv.style.height = "18px";
  		  eastDiv.style.left = "49px";
		  eastDiv.style.top = "-36px";
		  if (oldIE) eastDiv.style.top = "-116px";
		  eastDiv.style.cursor = "pointer";

//			southDiv.style.background ="green";
		  southDiv.style.position = "relative";
		  southDiv.style.width = "18px";
		  southDiv.style.height = "31px";
  		  southDiv.style.left = "31px";
		  southDiv.style.top = "-36px";
		  if (oldIE) southDiv.style.top = "-116px";
		  southDiv.style.cursor = "pointer";
		
		  if (oldIE)
			  southDiv.style.marginBottom = "-116px";	//lebo IE je sprosty magor, a vlozenim divov odignoruje vysku kontainera. Ak nie je definovany doctype strixt xhtml v IE7. V starsich aj tak...:)

		  container.appendChild(northDiv);
		  container.appendChild(westDiv);
		  container.appendChild(returnDiv);
		  container.appendChild(eastDiv);
		  container.appendChild(southDiv);
		  map.getContainer().appendChild(container);

		  return container;
		}
		
		NavigControl.prototype.getDefaultPosition = function() {
		  return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(5, 5));
		}

/*Creating and setting the map*/
		map = new GMap2(document.getElementById(outer));

//      	coords = "37.80570682522318, -122.4174534566069, 15";

		coords = coordinates.split(' ').join('').split(',');

		if (coords.length > 2)
			zoom = parseInt(coords[2]);
		else
			zoom = 18;

	        map.setCenter(new GLatLng(coords[0], coords[1]), zoom, G_HYBRID_MAP);
		

		map.addControl(new SmallMapTypeControl());
		map.addControl(new ResizeControl());
		map.addControl(new ZoomControl());
		map.addControl(new NavigControl());

		map.addOverlay(createMarker(new GLatLng(coords[0], coords[1]), itab));
		
      }

    }
    
    function Resize(setLarger)
    {
      if (GBrowserIsCompatible() && map) {
      		if (setLarger || (document.getElementById("map").style.width == smallerMapWnd['width'] + "px"))
      		{
      			document.getElementById("map").style.width = largerMapWnd['width'] + "px";
      			document.getElementById("map").style.height = largerMapWnd['height'] + "px";
      			document.getElementById("map-border").style.width = largerMapBorderWnd['width'] + "px";
      			document.getElementById("map-border").style.height = largerMapBorderWnd['height'] + "px";
      			document.getElementById("map-outer").style.width = largerMapOuterWnd['width'] + "px";
//      			document.getElementById("map-outer").style.height = largerMapOuterWnd['height'] + "px";
      			document.getElementById("map-frame").style.width = largerMapFrameWnd['width'] + "px";
//      			document.getElementById("map-frame").style.height = largerMapFrameWnd['height'] + "px";
      		}
      		else
      		{
      			document.getElementById("map").style.width = smallerMapWnd['width'] + "px";
      			document.getElementById("map").style.height = smallerMapWnd['height'] + "px";
      			document.getElementById("map-border").style.width = smallerMapBorderWnd['width'] + "px";
      			document.getElementById("map-border").style.height = smallerMapBorderWnd['height'] + "px";
      			document.getElementById("map-outer").style.width = smallerMapOuterWnd['width'] + "px";
//      			document.getElementById("map-outer").style.height = smallerMapOuterWnd['height'] + "px";
      			document.getElementById("map-frame").style.width = smallerMapFrameWnd['width'] + "px";
//      			document.getElementById("map-frame").style.height = smallerMapFrameWnd['height'] + "px";
      		}
      		map.checkResize();
      		map.returnToSavedPosition();
      }
    }
    
    function MoveToMap2()
    {
      if (GBrowserIsCompatible() && map) 
      {
      		GUnload();
      		document.getElementById("map").style.width="0";
      		document.getElementById("map").style.height="0";
      		document.getElementById("map").innerHTML="";
	        Load("map2");
      }
    }

