// JavaScript Document
	
var geoXml = new GGeoXml("http://www.thailandresor.se/kohlipe/kl.kml");
var toggleState = 1;

// == set up a default value for the id ==
var id =-1;

// == have we been passed an id ? ==
var query = location.search.substring(1);
var pairs = query.split("&");
for (var i=0; i<pairs.length; i++) {
  var pos = pairs[i].indexOf("=");
  var argname = pairs[i].substring(0,pos).toLowerCase();
  var value = pairs[i].substring(pos+1).toLowerCase();
  if (argname == "id") {id = parseInt(value);}
}

var baseIcon = new GIcon();
	baseIcon.image = "http://www.thailandkartan.se/gimage/mm_20_red.png";
	baseIcon.iconSize = new GSize(12, 20);
	baseIcon.iconAnchor = new GPoint(6, 20);
	baseIcon.infoWindowAnchor = new GPoint(5, 1);
	
var atmIcon = new GIcon(); 
	atmIcon.image = "http://www.thailandkartan.se/gimage/ATM.png";
	atmIcon.iconSize = new GSize(20, 15);
	atmIcon.iconAnchor = new GPoint(6, 6);
	atmIcon.infoWindowAnchor = new GPoint(5, 1);
	
var elevenIcon = new GIcon();
	elevenIcon.image = "http://www.thailandkartan.se/gimage/7eleven.png";
	elevenIcon.iconSize = new GSize(20, 20);
	elevenIcon.iconAnchor = new GPoint(6, 6);
	elevenIcon.infoWindowAnchor = new GPoint(5, 1);
var divingflagIcon = new GIcon();
	divingflagIcon.image = "http://www.thailandkartan.se/gimage/divingflag.png";
	divingflagIcon.iconSize = new GSize(18, 18);
	divingflagIcon.iconAnchor = new GPoint(6, 6);
	divingflagIcon.infoWindowAnchor = new GPoint(5, 1);
var golfIcon = new GIcon();
	golfIcon.image = "http://www.thailandkartan.se/gimage/golf.png";
	golfIcon.iconSize = new GSize(20, 20);
	golfIcon.iconAnchor = new GPoint(6, 6);
	golfIcon.infoWindowAnchor = new GPoint(5, 1);
	
var northIcon = new GIcon();
	northIcon.image = "http://www.thailandkartan.se/gimage/mm_20_udon.png";
	northIcon.iconSize = new GSize(10, 17);
	northIcon.iconAnchor = new GPoint(6, 6);
	northIcon.infoWindowAnchor = new GPoint(5, 1);
	
var centralIcon = new GIcon();
	centralIcon.image = "http://www.thailandkartan.se/gimage/mm_20_phuket.png";
	centralIcon.iconSize = new GSize(10, 17);
	centralIcon.iconAnchor = new GPoint(6, 6);
	centralIcon.infoWindowAnchor = new GPoint(5, 1);
	
var northeasternIcon = new GIcon();
	northeasternIcon.image = "http://www.thailandkartan.se/gimage/mm_20_northeastern.png";
	northeasternIcon.iconSize = new GSize(10, 17);
	northeasternIcon.iconAnchor = new GPoint(6, 6);
	northeasternIcon.infoWindowAnchor = new GPoint(5, 1);
	
var eastIcon = new GIcon();
	eastIcon.image = "http://www.thailandkartan.se/gimage/mm_20_east.png";
	eastIcon.iconSize = new GSize(10, 17);
	eastIcon.iconAnchor = new GPoint(6, 6);
	eastIcon.infoWindowAnchor = new GPoint(5, 1);

var southIcon = new GIcon();
	southIcon.image = "http://www.thailandkartan.se/gimage/mm_20_south.png";
	southIcon.iconSize = new GSize(10, 17);
	southIcon.iconAnchor = new GPoint(6, 6);
	southIcon.infoWindowAnchor = new GPoint(5, 1);	
	
var btsIcon = new GIcon();
	btsIcon.image = "http://www.thailandkartan.se/gimage/bts.png";
	btsIcon.iconSize = new GSize(20, 20);
	btsIcon.iconAnchor = new GPoint(6, 6);
	btsIcon.infoWindowAnchor = new GPoint(5, 1);
var mrtIcon = new GIcon();
	mrtIcon.image = "http://www.thailandkartan.se/gimage/mrta.png";
	mrtIcon.iconSize = new GSize(18, 20);
	mrtIcon.iconAnchor = new GPoint(6, 6);
	mrtIcon.infoWindowAnchor = new GPoint(5, 1);
var storeIcon = new GIcon();
	storeIcon.image = "http://www.thailandkartan.se/gimage/mm_20_red.png";
	storeIcon.iconSize = new GSize(12, 20);
	storeIcon.iconAnchor = new GPoint(6, 20);
	storeIcon.infoWindowAnchor = new GPoint(5, 1);
var shoppingIcon = new GIcon();
	shoppingIcon.image = "http://www.thailandkartan.se/gimage/shopping.png";
	shoppingIcon.iconSize = new GSize(20, 20);
	shoppingIcon.iconAnchor = new GPoint(6, 20);
	shoppingIcon.infoWindowAnchor = new GPoint(5, 1);
	
var planeIcon = new GIcon();
	planeIcon.image = "http://www.thailandkartan.se/gimage/flyg.png";
	planeIcon.iconSize = new GSize(22, 22);
	planeIcon.iconAnchor = new GPoint(6, 20);
	planeIcon.infoWindowAnchor = new GPoint(5, 1);
	
var trainIcon = new GIcon();
	trainIcon.image = "http://www.thailandkartan.se/gimage/train.png";
	trainIcon.iconSize = new GSize(18, 20);
	trainIcon.iconAnchor = new GPoint(6, 20);
	trainIcon.infoWindowAnchor = new GPoint(5, 1);
var busIcon = new GIcon();
	busIcon.image = "http://www.thailandkartan.se/gimage/buss.png";
	busIcon.iconSize = new GSize(26, 20);
	busIcon.iconAnchor = new GPoint(6, 20);
	busIcon.infoWindowAnchor = new GPoint(5, 1);
	busIcon.infoShadowAnchor = new GPoint(10, 15);
var clubIcon = new GIcon();
	clubIcon.image = "http://www.thailandkartan.se/gimage/mm_20_bar.png";
	clubIcon.iconSize = new GSize(18, 20);
	clubIcon.iconAnchor = new GPoint(6, 20);
	clubIcon.infoWindowAnchor = new GPoint(5, 1);
	clubIcon.infoShadowAnchor = new GPoint(10, 15);
var attractionIcon = new GIcon();
	attractionIcon.image = "http://www.thailandkartan.se/gimage/attraction.png";
	attractionIcon.iconSize = new GSize(26, 20);
	attractionIcon.iconAnchor = new GPoint(6, 20);
	attractionIcon.infoWindowAnchor = new GPoint(5, 1);
	attractionIcon.infoShadowAnchor = new GPoint(10, 15);
var foodIcon = new GIcon();
	foodIcon.image = "http://www.thailandkartan.se/gimage/mm_20_food.png";
	foodIcon.iconSize = new GSize(22, 22);
	foodIcon.iconAnchor = new GPoint(6, 20);
	foodIcon.infoWindowAnchor = new GPoint(5, 1);
	foodIcon.infoShadowAnchor = new GPoint(10, 15);
var spaIcon = new GIcon();
	spaIcon.image = "http://www.thailandkartan.se/gimage/spa.png";
	spaIcon.iconSize = new GSize(27, 27);
	spaIcon.shadowSize = new GSize(27, 27);
	spaIcon.iconAnchor = new GPoint(6, 20);
	spaIcon.infoWindowAnchor = new GPoint(5, 1);
	spaIcon.infoShadowAnchor = new GPoint(10, 15);
var sportIcon = new GIcon();
	sportIcon.image = "http://www.thailandkartan.se/gimage/mm_20_white.png";
	sportIcon.iconSize = new GSize(12, 20);
	sportIcon.iconAnchor = new GPoint(6, 20);
	sportIcon.infoWindowAnchor = new GPoint(5, 1);
var uniIcon = new GIcon();
	uniIcon.image = "http://www.thailandkartan.se/gimage/mm_20_blue.png";
	uniIcon.iconSize = new GSize(12, 20);
	uniIcon.iconAnchor = new GPoint(6, 20);
	uniIcon.infoWindowAnchor = new GPoint(5, 1);
	
var hotelIcon = new GIcon();
	hotelIcon.image = "http://www.thailandkartan.se/gimage/lyx.png";
	hotelIcon.iconSize = new GSize(20, 20);
	hotelIcon.iconAnchor = new GPoint(6, 6);
	hotelIcon.infoWindowAnchor = new GPoint(5, 1);
	hotelIcon.infoShadowAnchor = new GPoint(10, 15);
var hotelIcon2 = new GIcon();
	hotelIcon2.image = "http://www.thailandkartan.se/gimage/budget.png";
	hotelIcon2.iconSize = new GSize(20, 20);
	hotelIcon2.iconAnchor = new GPoint(6, 6);
	hotelIcon2.infoWindowAnchor = new GPoint(5, 1);
	hotelIcon2.infoShadowAnchor = new GPoint(10, 15);
var hotelIcon3 = new GIcon();
	hotelIcon3.image = "http://www.thailandkartan.se/gimage/mellan.png";
	hotelIcon3.iconSize = new GSize(20, 20);
	hotelIcon3.iconAnchor = new GPoint(6, 6);
	hotelIcon3.infoWindowAnchor = new GPoint(5, 1);
	hotelIcon3.infoShadowAnchor = new GPoint(10, 15);
var areaIcon = new GIcon();
	areaIcon.image = "http://www.thailandkartan.se/gimage/mm_20_area.png";
	areaIcon.iconSize = new GSize(12, 20);
	areaIcon.iconAnchor = new GPoint(6, 20);
	areaIcon.infoWindowAnchor =new GPoint(5, 1);
var markers;
var infoHtml;
var map;
var smap; 
function onLoad() {var panel = document.getElementById('panel');
var CategoryCurr = "";var CategoryNew = "";
var html = "";

var layerTerCross = [ G_PHYSICAL_MAP.getTileLayers()[0]];
var mtTerCross = new GMapType(G_PHYSICAL_MAP.getProjection());
		
map = new GMap2(document.getElementById("map"));
map.addMapType(G_PHYSICAL_MAP);
map.setMapType(G_HYBRID_MAP);
map.setCenter(new GLatLng(9.49478,100.00511), 12);
map.addControl(new GScaleControl());
map.addControl(new GSmallMapControl());
var mapControl = new GHierarchicalMapTypeControl();  <!-- G_NORMAL_MAP  G_SATELLITE_MAP G_HYBRID_MAP  G_PHYSICAL_MAP  -->
map.addControl(mapControl);
map.addOverlay(geoXml);


var request = GXmlHttp.create();
request.open("GET", "lb.xml", true);
request.onreadystatechange = function() {if (request.readyState == 4) 
    
{var xmlDoc = request.responseXML;
	var markerElements = xmlDoc.documentElement.getElementsByTagName("marker");
markers = new Array( markerElements.length );
infoHtml = new Array( markerElements.length );

for (var i = 0; 
i < markerElements.length; i++) {
	var Lat = parseFloat(markerElements[i].getAttribute("lat"));
	var Lng = parseFloat(markerElements[i].getAttribute("lng"));
	var Descr = markerElements[i].getAttribute("descr");
	var Url = markerElements[i].getAttribute("url");
	var Addr = markerElements[i].getAttribute("addr");
	var Phone = markerElements[i].getAttribute("phone");
	var Fax = markerElements[i].getAttribute("fax");
	var Img = markerElements[i].getAttribute("img");
	var ref = markerElements[i].getAttribute("ref");
       
CategoryNew = markerElements[i].getAttribute("category");  
    if (CategoryNew == "Uttagsautomater") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), atmIcon);} 
	if (CategoryNew == "7eleven") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), elevenIcon);} 
	if (CategoryNew == "Diving Flag") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), divingflagIcon);} 
    if (CategoryNew == "South") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), southIcon);} 
	if (CategoryNew == "Northeastern") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), northeasternIcon);} 
	if (CategoryNew == "East") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), eastIcon);} 
	if (CategoryNew == "Central") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), centralIcon);} 
    if (CategoryNew == "North") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), northIcon);} 
	if (CategoryNew == "Silom Skytrain") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), btsIcon);} 
	if (CategoryNew == "Sukhumvit Skytrain") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), btsIcon);}
	if (CategoryNew == "Tunnelbana") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), mrtIcon);} 
	if (CategoryNew == "Fashion Shops") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), storeIcon);}
	if (CategoryNew == "Bars and Clubs") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), clubIcon);}
	if (CategoryNew == "Restaurants") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), foodIcon);}
	if (CategoryNew == "Spas") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), spaIcon);}
	if (CategoryNew == "Sports") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), sportIcon);}
	if (CategoryNew == "Golfbanor i Thailand") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), golfIcon);}
	if (CategoryNew == "Hotell Lyx") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), hotelIcon);}
	if (CategoryNew == "Hotell Budget") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), hotelIcon2);}
	if (CategoryNew == "Hotell Mellan") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), hotelIcon3);}
	if (CategoryNew == "Areas") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), areaIcon);}
	if (CategoryNew == "Air Port") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), planeIcon);}
	if (CategoryNew == "Train Station") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), trainIcon);}
	if (CategoryNew == "Bus Station") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), busIcon);}
	if (CategoryNew == "Shopping") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), shoppingIcon);}
	if (CategoryNew == "Attraction") {markers[i] = new GMarker( new GPoint( parseFloat(Lng), parseFloat(Lat) ), attractionIcon);}
	
infoHtml[i] = "<font face='verdana, tahoma' size='-2'><b>" + Descr + "</b><br>Address:" + Addr + "<br>";
	if (markerElements[i].getAttribute("phone") != null){infoHtml[i] += "<font face='verdana, tahoma' size='-2'>Tel:" + Phone + "<br>";}
if (markerElements[i].getAttribute("fax") != null)infoHtml[i] += "<font face='verdana, tahoma' size='-2'>Fax:" + Fax + "<br>";
	if (markerElements[i].getAttribute("url") != null){infoHtml[i] += "<a href='http://" + Url + "' target=_new>" + Url + "</a><br>";}infoHtml[i] += "</font>";
	if (markerElements[i].getAttribute("img") != null){infoHtml[i] += "<a href='http://" + ref + "' target=_new><img src='http://" + Img + "' width='150' height='100' vspace='3'  border='0'></a><br>Klicka på bilden för översyn";	}

GEvent.addListener( markers[i], 'mouseover', makeOpenerCaller(i) );
map.addOverlay( markers[i] ); 

	if (CategoryCurr != CategoryNew) { 
	if (CategoryNew == "Uttagsautomater") {html = "<br><img src='http://www.thailandkartan.se/gimage/ATM.png' align='middle' width='18'> ";}
	if (CategoryNew == "7eleven") {html = "<br><img src='http://www.thailandkartan.se/gimage/7eleven.png' align='middle' width='18'> ";}
	if (CategoryNew == "Diving Flag") {html = "<br><img src='http://www.thailandkartan.se/gimage/divingflag.png' align='middle' width='16'> ";}
	if (CategoryNew == "North") {html = "<br><img src='http://www.thailandkartan.se/gimage/yello.png' align='middle' width='10'> ";}
	if (CategoryNew == "Northeastern") {html = "<br><img src='http://www.thailandkartan.se/gimage/mm_20_northeastern.png' align='middle' width='10'> ";}
	if (CategoryNew == "South") {html = "<br><img src='http://www.thailandkartan.se/gimage/mm_20_south.png' align='middle' width='10'> ";}
	if (CategoryNew == "East") {html = "<br><img src='http://www.thailandkartan.se/gimage/mm_20_east.png' align='middle' width='10'> ";}
	if (CategoryNew == "Central") {html = "<br><img src='http://www.thailandkartan.se/gimage/mm_20_phuket.png' align='middle' width='10'> ";}
	if (CategoryNew == "Silom Skytrain") {html = "<br><img src='http://www.thailandkartan.se/gimage/bts.png' align='middle' width='20'> ";} 
	if (CategoryNew == "Sukhumvit Skytrain") {html = "<br><img src='http://www.thailandkartan.se/gimage/bts.png' align='middle' width='20'> ";} 
	if (CategoryNew == "Tunnelbana") {html = "<br><img src='http://www.thailandkartan.se/gimage/mrta.png' align='middle' width='20'> ";} 
	if (CategoryNew == "Shopping") {html = "<br><img src='http://www.thailandkartan.se/gimage/shopping.png' align='middle' width='20'> ";} 
	if (CategoryNew == "Train Station") {html = "<br><img src='http://www.thailandkartan.se/gimage/train.png' align='middle' width='20'> ";} 
	if (CategoryNew == "Bus Station") {html = "<br><img src='http://www.thailandkartan.se/gimage/buss.png' align='middle' width='26'> ";} 
	if (CategoryNew == "Air Port") {html = "<br><img src='http://www.thailandkartan.se/gimage/flyg.png' align='middle' width='22'> ";} 
	if (CategoryNew == "Fashion Shops") {html = "<br><img src='http://www.thailandkartan.se/gimage/mm_20_red.png' align='middle'> ";}
	if (CategoryNew == "Bars and Clubs") {html = "<br><img src='http://www.thailandkartan.se/gimage/mm_20_bar.png' align='middle' width='20'> ";}
	if (CategoryNew == "Restaurants") {html = "<br><img src='http://www.thailandkartan.se/gimage/mm_20_food.png' align='middle' width='20'> ";}
	if (CategoryNew == "Spas") {html = "<br><img src='http://www.thailandkartan.se/gimage/spa.png' align='middle' width='20'> ";}
	if (CategoryNew == "Sports") {html = "<br><img src='http://www.thailandkartan.se/gimage/mm_20_white.png' align='middle'> ";}
	if (CategoryNew == "Golfbanor i Thailand") {html = "<br><img src='http://www.thailandkartan.se/gimage/golf.png' align='middle'> ";}
	if (CategoryNew == "Hotell Budget") {html = "<br><img src='http://www.thailandkartan.se/gimage/budget.png' align='middle' width='20'> ";}
	if (CategoryNew == "Hotell Mellan") {html = "<br><img src='http://www.thailandkartan.se/gimage/mellan.png' align='middle' width='20'> ";}
	if (CategoryNew == "Hotell Lyx") {html = "<br><img src='http://www.thailandkartan.se/gimage/lyx.png' align='middle' width='20'> ";}
	if (CategoryNew == "Attraction") {html = "<br><img src='http://www.thailandkartan.se/gimage/attraction.png' align='middle' width='26'> ";}
	if (CategoryNew == "Areas") {html = "";}html += "<b>" + CategoryNew + "</b><br>";CategoryCurr = CategoryNew;}
	
	
html += "&nbsp;&nbsp;-<a href='javascript:opener(" + i + ")'>" + Descr + "</a><br>";panel.innerHTML += html;html = ""; }
        GEvent.trigger(markers[id],"click");
	}
}

request.send(null);}
function onMapMove(){
	if (document.getElementById("ToggleSmap").checked) 
{smap.centerAndZoom(map.getCenterLatLng(),smap.getZoomLevel()); }}

function onMapZoom(oldZoom, newZoom){
	if (document.getElementById("ToggleSmap").checked) {
	if(newZoom == 0){smap.centerAndZoom(map.getCenterLatLng(),0);}
	else{smap.centerAndZoom(map.getCenterLatLng(),newZoom-1);} }}

function createMarker(point, html) {
	var marker = new GMarker(point, baseIcon);
	
GEvent.addListener(marker, "click", 
function() {marker.openInfoWindowHtml(html);});
return marker;}function opener(i){markers[i].openInfoWindowHtml( infoHtml[i] );}


function makeOpenerCaller( i ){return function() { opener( i ); };}function zoom(Lng, Lat) {
	if (map.getZoomLevel() != 0) {map.centerAndZoom(new GPoint(Lng, Lat), map.getZoomLevel()-1);}}

function toggleSMap() {
	if (document.getElementById("ToggleSmap").checked) {onMapMove();document.getElementById("smap").style.display = "block";document.getElementById("map").style.width = "00px";} 
	else {document.getElementById("smap").style.display = "none";document.getElementById("map").style.width = "500px";}}
	