var tst_obj;
var tstint_obj;
var map_obj;
var map_address_obj;
var mySlidemap_obj;
var overviewmap_obj;
var overmap_obj;
var xml_obj;
var imageovl_obj;
var directions_obj;
var zoomlevel;
function gmap_lightbox(elementID, address, zoom, height, width)
{
    map_address_obj = address;
	zoomlevel = zoom;
    tst_obj=document.getElementById(elementID);
    if (GBrowserIsCompatible()) 
	{
        window.onunload=function(){window.onunload;GUnload()};
        tst_obj.setAttribute("oldValue",0);
        tst_obj.setAttribute("refreshMap",0);
        if (window.MooTools==null)
        {	
            tstint_obj=setInterval("checkMap_obj()",500);
        }
        else
        {
            window.addEvent('domready', function() {tstint_obj=setInterval('checkMap_obj()', 500);});
        }
    }

	directions = "http://maps.google.com/maps?daddr=" + map_address_obj;
	caption = "<p>" + map_address_obj + "<p>";
    caption = caption + "<p><a href=\"" + directions + "\" target=\"_blank\">Get Directions</a></p>";
    MOOdalBox.open("googlemap_obj", caption, width + " " + height, map_obj, {});
	return false;	
}




function initearth_obj(geplugin) 
{
    geplugin_obj = geplugin;
    geplugin_obj.getLayerRoot().enableLayerById(geplugin_obj.LAYER_BUILDINGS, false);
    geplugin_obj.getLayerRoot().enableLayerById(geplugin_obj.LAYER_TERRAIN, false);
}

function savePositionKML_obj() 
{
    ok = true;
    for (x=0;x<xml_obj.length;x++) 
	{
        if (!xml_obj[x].hasLoaded())
        {
            ok = false;
		}
    }

    if (ok)
	{
        map_obj.savePosition();
    }
    else
    {
        setTimeout('savePositionKML_obj()',100);
    }
}
							
function checkMap_obj()
{
    if (tst_obj) 
    {
        if (tst_obj.getAttribute("refreshMap")==0)
		{
            clearInterval(tstint_obj);
		}
        getMap_obj();
        tst_obj.setAttribute("refreshMap", 1);
    }
}
				
function getMap_obj()
{
    map_obj = new GMap2(document.getElementById('googlemap_obj'));
    map_obj.getContainer().style.overflow='hidden';
    map_obj.addMapType(G_PHYSICAL_MAP);map_obj.addMapType(G_SATELLITE_3D_MAP);
   var centerpoint;
    var geocoder = new GClientGeocoder();
    geocoder.getLatLng(
        map_address_obj,
        function(centerpoint) 
        {
            if (!centerpoint) {
                alert(address + " not found");
            } else {
                map_obj.setCenter(centerpoint, zoomlevel);
				var marker_obj = new GMarker(centerpoint);
				map_obj.addOverlay(marker_obj);
           }
       }
    );

	map_obj.addControl(new GLargeMapControl3D());
	map_obj.addControl(new GMapTypeControl());
    map_obj.setMapType(G_HYBRID_MAP);
	map_obj.disableContinuousZoom();
	map_obj.disableDoubleClickZoom();					
}

