function basename (path, suffix) {
    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)
{
    var brURL = window.location.href;
    brURL = brURL.replace(window.location.protocol + "//" + window.location.host + window.location.pathname, "");
    
    if(typeof(frm) == "undefined")
    {
        frm = lremain;
    }

    else if(brURL.substring(1,6) == 'page=')
    {
      frm.location = lreJS.hostName + window.location.search.substring(7);
    }
    //email a friend url for non resizing br's
    else if(window.location.hash != '')
    {
        //frm.location = lreJS.hostName + window.location.search.substring(7);
        frm.location = lreJS.hostName + 'reciprocity/show?' + window.location.hash.substring(1);
    }
    else
    {

        frm.location = lreJS.hostName + removeLeadingSlash(lreConfig.searchPage);
    }

    //set this variable because it will be used in resizeIframeHeight()
    myiframe = document.getElementsByName(frm.name)[0];
}

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

    return str;
}

function resizeIframeHeight(nHeight) {
  myiframe.setAttribute('style', "height: " + (parseInt(nHeight) + 10) + 'px;' );
}


