// *****************************************************************************
// ***** functions.js - common JavaScript routines for LPM
// *****************************************************************************
var objWin;

// *****************************************************************************
function closewindow() {
  objWin.close();
}

// *****************************************************************************
function popwindow(title, url, x, y, h, w) {
  other = "width="+w+",height="+h+",left="+x+",top="+y+",screenx="+x+",screeny="+y+",toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes";
  if (getBrowser()) {
    objWin = window.open(url,title,other);
    objWin.focus();
  } else {
    objWin = window.open(url,title,other);
  }
  //objWinTimer = window.setTimeout("closewindow()", 1200000);
}

// *****************************************************************************
function popminiwindow(title, url, x, y, h, w) {
  other = "width="+w+",height="+h+",left="+x+",top="+y+",screenx="+x+",screeny="+y+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes";
  if (getBrowser()) {
    objWin = window.open(url,title,other);
    objWin.focus();
  } else {
    objWin = window.open(url,title,other);
  }
}

// *****************************************************************************
function popmaxwindow(title, url) {
  if (getBrowser() && navigator.appVersion.substring(0,1) > 3) {
    h = window.screen.availWidth;
    w = window.screen.availHeight;
  } else {
    h = 480;
    w = 640;
  }

  other = "width="+w+",height="+h+",left=0,top=0,screenx=0,screeny=0,toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes";
  if (getBrowser()) {
    objWin = window.open(url,title,other);
    objWin.focus();
  } else {
    objWin = window.open(url,title,other);
  }
  //objWinTimer = window.setTimeout("closewindow()", 1200000);
}

//*****************************************************************************
function popscrollwindow(title, url, x, y, h, w) {
  other = "left="+x+", top="+y+", screenx="+x+", screeny="+y+", scrollbars=yes, resizable=yes, toolbar=no, location=no, directories=no, status=no, menubar=no";

  // If no sizing is specified, the new window will open with the default browser sizing
  if (h != null && w != null) {
    other += ", width="+w+", height="+h;
  }
  if (getBrowser()) {
    objWin = window.open(url,title,other);
    objWin.focus();
  } else {
    objWin = window.open(url,title,other);
  }
  //objWinTimer = window.setTimeout("closewindow()", 1200000);
}

// *****************************************************************************
function getBrowser()
{
  browser= navigator.appName;
  version = navigator.appVersion;
  accept = version.substring(0, 1);
  if ( (browser == "Netscape") && ( accept >= 3 ) ) return 1;
  if ( (browser == "Microsoft Internet Explorer") && ( accept >= 4) ) return 1;
  return 0;
}

// *****************************************************************************
function getObjectById(theId) {
  var elm = null;
  if (document.getElementById) {
    // browser implements part of W3C DOM HTML Gecko, Internet Explorer 5+, Opera 5+
    elm = document.getElementById(theId);
  } else if (document.all) {
    // Internet Explorer 4 or Opera with IE user agent
    elm = document.all[theId];
  } else if (document.layers) {
    // Navigator 4
    elm = document.layers[theId];
  }

  return elm;
}

// *****************************************************************************
function hideLayer(layerName){
  var objLayer = null;
  objLayer = getObjectById(layerName);

  objLayer.style.visibility="hidden";
}

// *****************************************************************************
function showLayer(layerName){
  var objLayer = null;
  objLayer = getObjectById(layerName);

  objLayer.style.visibility="visible";
}

//*****************************************************************************
function showFlyer(rentID, searchID)
{
  if (getBrowser() && navigator.appVersion.substring(0,1) > 3) {
    height = screen.height;
    width = screen.width;
    if (height > 768) {
      wheight = 750;
    } else {
      wheight = 460;
    }
    if (width < 800) {
      wwidth = 610;
    } else {
      wwidth = 640;
    }
  } else {
    wheight = 460;
    wwidth = 640;
  }
  url = "/rentalFlyer.asp?rent_id="+rentID+"&search_id="+searchID;
  other = "width="+wwidth+",height="+wheight+",left=0,top=0,screenx=0,screeny=0,toolbar=yes,location=no,directories=no,status=no,menubar=Yes,scrollbars=yes,resizable=yes";
  if (getBrowser())
  {
    objWin = window.open(url,'property',other);
    objWin.focus();
  } else {
    objWin = window.open(url,rentID,other);
  }
}

//*****************************************************************************
function sizeFlyer(newWidth, newHeight)
{
  if (getBrowser() && navigator.appVersion.substring(0,1) > 3) {
    width = screen.width;
    height = screen.height;
    if (width > (newWidth+50)) {
      wwidth = newWidth;
    } else {
      wwidth = (width-50);
    }
    if (height > (newHeight+50)) {
      wheight = newHeight;
    } else {
      wheight = (height-50);
    }
  } else {
    wwidth = 640;
    wheight = 460;
  }
  window.resizeTo(wwidth,wheight)
}

//*****************************************************************************
function newImage(arg) {
  if (document.images) {
    rslt = new Image();
    rslt.src = arg;
    return rslt;
  }
}

//*****************************************************************************
function changeImages() {
  if (document.images && (preloadFlag == true)) {
    for (var i=0; i<changeImages.arguments.length; i+=2) {
      document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
    }
  }
}

// *****************************************************************************

