DIRECTION_TYPE_FROM = "From";
DIRECTION_TYPE_TO = "To";
DIRECTION_TYPE = "endDirection";
LOCATION_DIRECTIONS = "locationDirections";
SEARCH_DIRECTIONS = "searchDirections";
LOCATION_VALUE = "locationValue";
SEARCH_VALUE = "searchValue";

function getDirections(button, id, title)
{
    var to = document.getElementById(DIRECTION_TYPE).innerHTML == DIRECTION_TYPE_TO ?
        true : false;
    
    var l1 = _m.vpage.overlays[0].getLocationById(id);
    var loc1 = l1.point.y + "," + l1.point.x + "+(" + title + ")";
    
    var loc2 = button.id == LOCATION_DIRECTIONS ?
        document.getElementById(LOCATION_VALUE).value :
        document.getElementById(SEARCH_VALUE).value;
        
    if (loc2 == "") return;
        
    var query = new Array();
    query[query.length] = "http://maps.google.com/maps?saddr=";
    
    if (to) 
    {
        query[query.length] = loc1;
    }
    else
    {
        query[query.length] = loc2;
    }
    
    query[query.length] = "&daddr=";
    
    if (to) 
    {
        query[query.length] = loc2;
    }
    else
    {
        query[query.length] = loc1;
    }
    window.open(query.join(""),'','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
}

function switchToFrom(a, b)
{
    var c = document.getElementById(a);
    var d = document.getElementById(b);
    if (c.style.textDecoration == "none") return;
    
    var styles = ["textDecoration", "fontWeight"];
    
    for (var i=0; i<styles.length; i++)
    {
        var e = c.style[styles[i]];
        c.style[styles[i]] = d.style[styles[i]];
        d.style[styles[i]] = e;
    }
    
    c.blur();
    d.blur();
    
    document.getElementById(DIRECTION_TYPE).innerHTML = d.innerHTML;
}

