var targets = new Array();

var RESULT_ZOOM_LEVEL = 12;

window.addEvent('domready', function(){
		
	log("event 2");
				
	if (GBrowserIsCompatible()) {
		
		if (lheim != null && lheim.point != null) {

			log("compatible browser found");
			
			tmp = $('location_map');
			
			log(tmp);
			
			buildLocationMap(tmp);
		}
		
		log("finished");
		
	}else{
		log('Ihr Browser entspricht nicht den Anforderungen für die Darstellung einer dynamischen Landkarte');
	}
	
});

function buildLocationMap(container){
	location_map = new GMap2(container);
	location_map.clearOverlays();
	location_map.setCenter(new GLatLng(53,10), RESULT_ZOOM_LEVEL);
	location_map.addControl(new GSmallZoomControl());
	location_map.setMapType(G_NORMAL_MAP);
	location_map.disableDragging();
	marker = new GMarker(lheim.point,{
		title: lheim.title,
		icon: createHeimIcon(lheim.customer),		
		clickable: false
	})
	GEvent.addDomListener(container, "click", function(){
		showShadowMap();
	});
	location_map.addOverlay(marker);
	location_map.panTo(lheim.point);
}

function buildShadowMap(container){
	shadow_map = new GMap2(container);
	shadow_map.clearOverlays();
	shadow_map.setCenter(lheim.point, RESULT_ZOOM_LEVEL);
	shadow_map.addControl(new GLargeMapControl());
	shadow_map.addControl(new GMapTypeControl());
	shadow_map.setMapType(G_NORMAL_MAP);
//	shadow_map.disableDragging();
	marker = new GMarker(lheim.point,{
		title: lheim.title,
		icon: createHeimIcon(lheim.customer)
	})
	shadow_map.addOverlay(marker);
	shadow_map.panTo(lheim.point);
}


function showShadowMap(){
    Shadowbox.open({
        player:     'html',
        content:    '',
        height:     350,
        width:      550,
		title:		'Anfahrt - '+lheim.title,
        options:    {
            onFinish: function(item){
                if(GBrowserIsCompatible()){
                    var body = document.getElementById("shadowbox_content");
					buildShadowMap(body);
                }
            }
        }
    });
}

