﻿    var map = null;
    function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(60.146974, 11.173096), 9);
        map.addControl(new GSmallMapControl());
		var point = new GLatLng(60.193510701,11.099796295);
		var OSLicon = new GIcon();
		OSLicon.image = "./images/Osl-farge3.gif";
		OSLicon.shadow = "./images/Osl-farge3.gif";
		OSLicon.iconSize = new GSize(40, 17);
		OSLicon.shadowSize = new GSize(0, 0);
		OSLicon.iconAnchor = new GPoint(0, 0);
		OSLicon.infoWindowAnchor = new GPoint(0, 0);
		OSLicon.infoShadowAnchor = new GPoint(0, 0);
		map.addOverlay(new GMarker(point,OSLicon));
        GEvent.addListener(map, "moveend", function() {
		});
	    var url=document.location.href;
	    url=url.substring(url.indexOf("?"));
	    var tmpid=url.indexOf("TLcat");
	    if(tmpid > -1){
		    tryll();
	    }
      }
    }

    function load() {
      if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.setCenter(new GLatLng(60.185233, 11.307678), 9);
        GEvent.addListener(map, "moveend", function() {
		});
	    var url=document.location.href;
	    url=url.substring(url.indexOf("?"));
	    var tmpid=url.indexOf("TLcc");
	    if(tmpid > -1){
		    tryll();
	    }
      }
    }
	var pois=new Array();
	function createIcon(latitude,longitude,url,productname,iconurl,iconWidth,iconHeight){
		while(iconurl.indexOf("&amp;") > -1){
			iconurl = iconurl.replace("&amp;","&");
		}
		var icon = new GIcon();
		icon.image = iconurl;
		icon.shadow = iconurl;
		icon.iconSize = new GSize(iconWidth, iconHeight);
		icon.shadowSize = new GSize(0, 0);
		icon.iconAnchor = new GPoint(0, 0);
		icon.infoWindowAnchor = new GPoint(0,0);
		var point = new GLatLng(latitude,longitude);
		var tmpLatLong=latitude+longitude;
		tmpLatLong = tmpLatLong+"";
		var poi = (Array)(pois[tmpLatLong]);
		if(poi == null){
		  poi=new Array();
		}
		poi[poi.length]="<tr><td><img src=\""+iconurl+"\" /></td><td><a href="+url+">"+productname.replace(",","¤")+"</a></td></tr>";
		pois[tmpLatLong]=poi;
		map.addOverlay(createMarker(point,icon,tmpLatLong,url));
	}
	function createMarker(point, icon,tmpLatLong, url) {
		
		var marker = new GMarker(point,icon);
		GEvent.addListener(marker, "click", function() {
			document.location.href=url;
			}
		);
		GEvent.addListener(marker, "mouseover", function() {
			var a = pois[tmpLatLong]+"";
			
			if(a.indexOf(",") == 0){
				a = a.substring(1,a.length);
			}
			try{
				while(a.indexOf("¤") > -1){
					a = a.replace("¤",",");
				}
			}

			catch(e){alert(e);};
			a = "<div><table class=\"maplist\">"+a+"</table></div>";
			marker.openInfoWindowHtml(a);
			}
		);
		return marker;
	}
