var objWin;

//*****************************************************************************
function popupwindow(title, url, x, y, h, w, scrollbars, status, resize, menubar) {
  other = "left="+x+", top="+y+", screenx="+x+", screeny="+y+", height="+h+", width="+w+", scrollbars="+scrollbars+", status="+status+", resizable="+resize+", menubar="+menubar+", toolbar=yes, location=no, directories=no";
  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 = "left="+x+", top="+y+", screenx="+x+", screeny="+y+", height="+h+", width="+w+", resizable=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no";
  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 popmaxwindow(title, url) {
  if (getBrowser() && navigator.appVersion.substring(0,1) > 3) {
    w = window.screen.availWidth - 50;
    h = window.screen.availHeight - 150;
  } else {
    h = 480;
    w = 640;
  }

  other = "width="+w+", height="+h+", left=0, top=0, screenx=0, screeny=0, toolbar=yes, location=yes, status=yes, menubar=yes, scrollbars=yes, resizable=yes, directories=no";
  if (getBrowser()) {
    objWin = window.open(url,title,other);
    objWin.focus();
  } else {
    objWin = window.open(url,title,other);
  }
  //objWinTimer = window.setTimeout("closewindow()", 1200000);
}

//*****************************************************************************
var slideShowWindow = null;
var lastWidth, lastHeight = 0;

function ImagePop(url,w,h)
{
  var mess = '';
//  if(slideShowWindow != null)
//    if(lastWidth < w || lastHeight < h) {
//      slideShowWindow.close();
//      mess = '.';
//    }

  if(w > lastWidth)
    lastWidth = w;

  if(h > lastHeight)
    lastHeight = h;

  var newWidth = w + 60;
  var newHeight = h + 80;
  var reHeight = h + 110;

  WindowParameters = 'width='+ newWidth +', height='+ newHeight +', resizable=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, toolbar=0, left=0, top=0, screenx=0, screeny=0';

  slideShowWindow=window.open("","SlideShow", WindowParameters);
  slideShowWindow.document.write ("<html><head><title>PMZ.COM - Image</title></head>");
  slideShowWindow.document.write ("<body bgcolor='white'>");
  slideShowWindow.document.write ("<script type='text/javascript'>{window.resizeTo("+newWidth+","+reHeight+")}</script>");

  slideShowWindow.document.write ("<p align=center><b><font size='2' face='verdana'>Click&nbsp;image&nbsp;to&nbsp;close"+ mess +"</font></p>");
  slideShowWindow.document.write ("<p align=center><a href='JavaScript:window.opener.resetSize();this.close()'><img src="+ url +" width="+ w +" height="+ h +" border=0></a></p>");
  slideShowWindow.document.write ("</body></html>");
  slideShowWindow.document.close();

  slideShowWindow.focus();

  return false;
}

//*****************************************************************************
function resetSize() {
  lastWidth = 0;
  lastHeight = 0;
}

//*****************************************************************************
function closewindow() {
  objWin.close();
}

//*****************************************************************************
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 showFlyer(mln, mls, cma, ui) {
  url = "/propDetails/fullScreenMLS.asp?mln="+mln+"&mls="+mls+"&id="+cma;
  if (cma != '' && cma != 'cma') {
    url += "&lid="+cma;
  }
  if (ui == "1") {
    url += "&ui=1"
  }
  other = "left=0, top=0, screenx=0, screeny=0, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes, location=no, directories=no, status=no";
  if (getBrowser()) {
    objWin = window.open(url,'PMZproperty',other);
    objWin.focus();
  } else {
    objWin = window.open(url,mln,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 = 790;
    wheight = 460;
  }
  window.resizeTo(wwidth,wheight)
}

//*****************************************************************************
function showcommproperty(id)
{
  if (getBrowser() && navigator.appVersion.substring(0,1) > 3) {
    height = screen.height;
    width = screen.width;
    if (height > 768) {
      wheight = 800;
    } else {
      wheight = 460;
    }
    if (width < 800) {
      wwidth = 680;
    } else {
      wwidth = 680;
    }
  } else {
    wheight = 460;
    wwidth = 680;
  }
  url = "/flyerComm.asp?id="+id;
  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,'commproperty',other);
    objWin.focus();
  } else {
    objWin = window.open(url,'commproperty',other);
  }
  //objWinTimer = window.setTimeout("closewindow()", 1200000);
}

//*****************************************************************************
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];
    }
  }
}

//*****************************************************************************
var preloadFlag = false;
//function preloadImages() {
//  if (document.images) {
//		vlhdr_automotive_over = newImage("/header/vlhdr_automotive-over.gif");
//		vlhdr_jobs_over = newImage("/header/vlhdr_jobs-over.gif");
//		vlhdr_realestate_over = newImage("/header/vlhdr_realestate-over.gif");
//		vlhdr_health_over = newImage("/header/vlhdr_health-over.gif");
//		vlhdr_legal_over = newImage("/header/vlhdr_legal-over.gif");
//		vlhdr_loans_over = newImage("/header/vlhdr_loans-over.gif");
//		vlhdr_insurance_over = newImage("/header/vlhdr_insurance-over.gif");
//		vlhdr_homegarden_over = newImage("/header/vlhdr_homegarden-over.gif");
//		vlhdr_coupons_over = newImage("/header/vlhdr_coupons-over.gif");
//		vlhdr_freeclassifieds_over = newImage("/header/vlhdr_freeclassifieds-over.gif");
//    preloadFlag = true;
//  }
//}
