var INFO_STYLE_BASE = "style/walk.box.";

function loadStyle(id, index, style)
{
    if (index == null) index = 1;
    
    var l = _m.vpage.overlays[0].getLocationById(id);
    var oldInfoStyle = l.infoStyle;
    l.infoStyle = _buildInfoStyleResourcePath(style);
    
    var w = _m.map.infoWindow;
    w.contentArea.innerHTML = "<img src='icons/loading.gif'></img>";
    var oldSrc = w.closeButton.src;
    w.closeButton.src = "icons/revert.gif";

    showLocationInfo(id);
    
    // Set up all the necessary methods
    // to revert back to the old info window
    var onClose = w.onCloseMouseDown;
    var hide = w.hide;
    var showInfo = _m.map.showInfoWindow;
    
    var resetAll = function()
    {
        l.infoStyle = oldInfoStyle;
        w.closeButton.src = oldSrc;
        w.onCloseMouseDown = onClose;
        w.hide = hide;
        _m.map.showInfoWindow = showInfo;        
    };
    
    w.onCloseMouseDown = function(a)
    {
        D(a);
        resetAll();
        showLocationInfo(id);        
    }       
    
    w.hide = function()
    {
        resetAll();
        w.hide();        
    }
    
    _m.map.showInfoWindow = function(a)
    {
        resetAll();
        _m.map.showInfoWindow(a);        
    }   
}

function _buildInfoStyleResourcePath(style)
{
    return INFO_STYLE_BASE + style + ".xsl";
}