
function HideMapDiv(e)
{
    if (!e) var e = window.event;
    e.cancelBubble = true;
    if (e.stopPropagation) e.stopPropagation();
    
    document.getElementById("mapImageDiv").style.display = 'none'
    return false;
}

function DisplayMapDiv(e)
{
    if (!e) var e = window.event;
    e.cancelBubble = true;
    if (e.stopPropagation) e.stopPropagation();
    
    var aId;
    if (e.target) aId = e.target;
    else if (e.srcElement) aId = e.srcElement;
    if (aId.nodeType == 3) // safari bug?
        aId = aId.parentNode;


    d = document.getElementById("mapImageDiv");
    var p = Point.prototype.getAbsolutePosition(aId);
    //map is 400x300. Position so bottom center of map is at clicked point.
    //this will change with new maps!
    w = d.style.width.replace("px", "");
    h = d.style.height.replace("px", "");
    d.style.left = (p.x-w/2-60) + "px";
    d.style.right = (p.x+w/2-60) + "px";
    d.style.top = (p.y-h) + "px";
    d.style.bottom = (p.y) + "px";
    d.style.display = 'block';
    var m = document.getElementById("mapContainer");
    var listingID = aId.parentNode.id;
    map.ClearPushpins();
    /*var lat = document.getElementById(listingID + "_lat").value;
    var lon = document.getElementById(listingID + "_lon").value;
    
    var divObj;
    for(var i=0;i<mapMarkers.length;i++) {
        if (Math.abs(mapMarkers[i].lat) > 5 && Math.abs(mapMarkers[i].lon) > 5) {
        //alert("add pin: " + mapMarkers[i].index + "," + mapMarkers[i].lat + "," +  mapMarkers[i].lon + ",\n" +  38 + "," +  33 + "," +  "pin" + "," +  "" + "," +  (i+4));
        if (mapMarkers[i].listingType == "1") {
        divObj = map.AddPushpin(mapMarkers[i].index, mapMarkers[i].lat, mapMarkers[i].lon, 26, 21, "pinFeatured","" , "");
        }
        else {
        divObj = map.AddPushpin(mapMarkers[i].index, mapMarkers[i].lat, mapMarkers[i].lon, 26, 21, "pin","" , "");
        }
        divObj.onclick = showBubble;   
        divObj.onmouseover = highlightIcon; //"this.style.backgroundImage = url(http://static.homestore.com/Images/Icons/realtor_reg_over.png);";
        divObj.onmouseout =  unhighlightIcon;
        }
    }
    */
    /*
    map.AddPushpin(listingID,lat,lon,36,31,"pin","",3);
    map.SetCenter(lat, lon);
    map.SetZoom(15);
    */
    
    //map.SetCenter(lat, lon);
    //map.PanMap(0,0); //resets the bubble
    //map.PanMap((map.width - m.offsetWidth) / 2, (map.height - m.offsetHeight) / 2);
    //map.removePushPin(0);
    //map.addPushPin(lat,lon);
    
    return false;
}
