function basename (path, suffix) {
    // Returns the filename component of the path  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/basename
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ash Searle (http://hexmen.com/blog/)
    // +   improved by: Lincoln Ramsay
    // +   improved by: djmix
    // *     example 1: basename('/www/site/home.htm', '.htm');
    // *     returns 1: 'home'
    var b = path.replace(/^.*[\/\\]/g, '');
    
    if (typeof(suffix) == 'string' && b.substr(b.length-suffix.length) == suffix) {
        b = b.substr(0, b.length-suffix.length);
    }
    
    return b;
}
 
function getscriptpath(scriptname){
        // Check document for our script
        scriptobjects = document.getElementsByTagName('script');
        for (i=0; i<scriptobjects.length; i++) {
            if(basename(scriptobjects[i].src)==scriptname){
                // we found our script.. lets get the path
                return scriptobjects[i].src.substring(0, scriptobjects[i].src.lastIndexOf('/'));
            };
        }
        return "";
}

lreJS = new Object();
lreJS.hostName = getscriptpath("lreJS.js").split('global/javascript')[0]; 
if(lreJS.hostName == "")
{
  lreJS.hostName = "http://www.luxuryrealestate.com/";
}
lreJS.blankPage = '<html><body bgcolor="white"></body></html>';

function lre_loadPage(frm)
{
    if(typeof(frm) == "undefined")
    {
        frm = lremain;
    }

    if(window.location.hash == "")
    {
        frm.location = lreJS.hostName + removeLeadingSlash(lreConfig.searchPage);
    }
    else
    {
        frm.location = lreJS.hostName + 'reciprocity/show?' + window.location.hash.substring(1);
    }
}


function lre_dynamic_loadPage(pageToLoad, metadata)
{
    if(pageToLoad == '')
    {
        lremain.location = lreJS.hostName + 'reciprocity/index?bruid=' + lreConfig.firmKey + '&Keyword=' + metadata;
    }
    else
    {
        //lremain.location = lreJS.hostName + removeLeadingSlash(lreConfig.searchPage);
        lre_loadPage();
    }
}

function removeLeadingSlash(str)
{
    while(str.indexOf("/") == 0)
    {
        str = str.substring(1);
    }

    return str;
}
