function rollover(whichimg,overimg) {
	eval('document.images["' + whichimg + '"].src = ' + overimg + '.src');
}

function email_property(URL) {
	var myWindow = window.open(URL, "EmailProperty", "height=600,width=475,scrollbars=yes,menubar=no,toolbar=no,resizable=yes")
	myWindow.focus();
}

function open_tour(URL) {
	var myWindow = window.open(URL, "VirtualTour", "height=360,width=512,scrollbars=yes,menubar=no,toolbar=no,resizable=yes")
	myWindow.focus();
}

function open_browserUpgrade(URL) {
	var myWindow = window.open(URL, "BrowserUpgrade", "height=360,width=512,scrollbars=yes,menubar=no,toolbar=no,resizable=yes")
	myWindow.focus();
}

function open_financialcalculator(URL) {
	var myWindow = window.open(URL, "FinancialCalculator", "height=400,width=485,scrollbars=no,menubar=yes,toolbar=yes,status=yes,resizable=yes")
	myWindow.focus();
}

function open_financialcalculator_scrollbars(URL) {
	var myWindow = window.open(URL, "FinancialCalculator", "height=400,width=485,scrollbars=yes,menubar=yes,toolbar=yes,status=yes,resizable=yes")
	myWindow.focus();
}

function open_bannerAd(URL) {
	var myWindow = window.open(URL, "BannerAd", "height=450,width=650,scrollbars=auto,menubar=yes,toolbar=yes,status=yes,resizable=yes")
	myWindow.focus();
}

function open_mortgageApp(URL) {
	var myWindow = window.open(URL, "MortgageApplication", "height=450,width=650,scrollbars=yes,menubar=yes,toolbar=yes,status=yes,resizable=yes")
	myWindow.focus();
}

function open_mortgageApplication() {
	var URL = "/Consumer/FrameSet.aspx?redirectto=/Consumer/Content/Forms/MortgageApplication.aspx";
	var myWindow = window.open(URL, "MortgageApplication", "height=450,width=650,scrollbars=yes,menubar=yes,toolbar=yes,status=yes,resizable=yes")
	myWindow.focus();
}

function open_oldMortgageCalc() 
{
	var myWindow = window.open('http://www.homeservices.com/TRIOtools/MortgageCalculator/MortgageCalculator.asp', "oldMortgageCalculator", "height=438,width=500,scrollbars=no,menubar=no,toolbar=no,status=no,resizable=no")
	myWindow.focus();
}

function Popup_Window(sURL) {
	var myWindow = window.open(sURL,"windowPreview","resizable,toolbar,scrollbars,status,height=550,width=800");
	myWindow.focus();
}

function open_ListingSearchHelp(sURL) {
	var myWindow = window.open(sURL,"ListingSearchHelp","resizable,scrollbars,status,height=350,width=300")
	myWindow.focus();
}

function open_IntranetLink(sURL) {
	var myWindow = window.open(sURL,"Intranet","resizable,toolbar,menubar,scrollbars,status,height=550,width=600")
	myWindow.focus();
}

function openContactMe(URL) {
	var myWindow = window.open(URL, "ContactMe", "height=" + getWindowHeight(730) + ",width=600,scrollbars=yes,menubar=no,toolbar=no,status=yes,resizable=yes");
	myWindow.focus();
}

function openTheFixUp(URL) {
	// NOTE: this function is currently only being used by CBSHOME, see Left Nav "Home Improvement" - 9/12/02, BKF
	var myWindow = window.open(URL, "TheFixUp", "height=" + getWindowHeight(750) + ",width=630,scrollbars=no,menubar=no,toolbar=no,status=yes,resizable=yes")
	myWindow.focus();
}

function getWindowHeight(maxHeight) {
	var bufferHeight = 90;
	if (screen.height >= (maxHeight + bufferHeight)) {
		return maxHeight;
	} else {
		return (screen.height - bufferHeight);
	}
}

function Popup_Article(nContentID) {
	Popup_Window('/Irp/Content/ArticlePopup.asp?ContentID=' + nContentID)
}

function open_map(URL) {
	var myWindow = window.open(URL, "ListingMap", "height=580,width=630,scrollbars=yes,menubar=no,toolbar=no,resizable=yes")
	myWindow.focus();
}

function open_printableBrochure(URL) {
	var myWindow = window.open(URL, "PrintableBrochure", "height=580,width=630,scrollbars=yes,menubar=yes,toolbar=no,resizable=yes")
	myWindow.focus();
}

function open_preferredParters(URL) {
	var myWindow = window.open(URL, "PreferredParters", "height=" + getWindowHeight(800) + ",width=615,scrollbars=yes,menubar=yes,toolbar=yes,status=yes,resizable=yes")
	myWindow.focus();
}

function open_showingtime(URL) {
	var myWindow = window.open(URL, "ShowingTime", "height=" + getWindowHeight(730) + ",width=620,scrollbars=yes,menubar=no,toolbar=no,status=yes,resizable=yes")
	myWindow.focus();
}

function open_neighborhood(URL) {
	var myWindow = window.open(URL, "Neighborhood", "height=400,width=640,scrollbars=no,menubar=no,toolbar=no,status=yes,resizable=yes")
	myWindow.focus();
}
					
function open_homedocs() {
	var myWindow = window.open("https://www.homedocs.com/index.htm", "HomeDocs", "height=440,width=600,scrollbars=yes,menubar=yes,toolbar=yes,status=yes,resizable=yes")
	myWindow.focus();
}

function open_referencelibrary(URL) {
	var myWindow = window.open(URL, "ReferenceLibrary", "height=" + getWindowHeight(680) + ",width=640,scrollbars=yes,menubar=yes,toolbar=yes,status=yes,resizable=yes")
	myWindow.focus();
}

function open_ExternalSearch(URL) {
	var myWindow = window.open(URL, "TRIOExternalSearch", "height=440,width=600,scrollbars=yes,menubar=yes,toolbar=yes,status=yes,resizable=yes");
	myWindow.focus();
}

function openValueSureRequest(URL) {
	var myWindow = window.open(URL, "ValueSure", "height=640,width=777,scrollbars=yes,menubar=yes,toolbar=no,status=yes,resizable=yes");
	myWindow.focus();
}

function fieldLengthLimit(field, maxlimit) {
    maxlimit = maxlimit - 1;
    if (field.value.length > maxlimit) {    // if too long...trim it!
        field.value = field.value.substring(0, maxlimit);
    }
}

function validateEmailAddress(address) {
	if (address != '' && address.search) {
      if (address.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) return true;
      else return false;
	}
   // allow empty strings to return true - screen these with either a 'required' test or a 'length' test
   else return true;
}

function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function currentlySearchingMenu(target) {
	if (target != "separator") {
		if (target.indexOf("popup") > 0) {
			var myWindow = window.open(target, "TRIOExternalSearch", "height=440,width=600,scrollbars=yes,menubar=yes,toolbar=yes,status=yes,resizable=yes");
			myWindow.focus();
		} else {
			location.href = target;
		}
	}
}
var oPopup;
function showHelp(oSpan, oTTip, vWidth, vHeight)
{
	oPopup = window.createPopup();
    var left = document.body.scrollLeft;
	var top =  20 + document.body.scrollTop;
    oPopup.document.body.innerHTML = oTTip.innerHTML; 
    oPopup.show(left, top, vWidth, vHeight, oSpan);
}
/* 03/18/2003 - Vince horst
	TODO: Bomb checkBrowser() and use the stuff in BrowserDetect.js instead.
	
	I've created a new JS file that does more complete browser detection. It's called BrowserDetect.js.
	For the time being, we cannot delete the checkBrowser(); below, because as of V6 the Map Based
	Listing search uses it to do stuff. We have zero time to change it over, so we'll leave it for now.
*/

function checkBrowser() {
  var n = navigator;
  var ua = ' ' + n.userAgent.toLowerCase();
  var pl = n.platform.toLowerCase(); // not supported in NS3.0
  var an = n.appName.toLowerCase();

  // browser version
  this.version = n.appVersion;
  this.nn = ua.indexOf('mozilla') > 0;
  if(ua.indexOf('compatible') > 0) {
    this.nn = false;
  }

  this.ie = ua.indexOf('msie') > 0;
  this.aol = ua.indexOf('aol') > 0;

  this.major = parseInt( this.version );
  this.minor = parseFloat( this.version );
  
  // platform
  this.mac = ua.indexOf('mac') > 0;
  this.win = ua.indexOf('win') > 0;

  // workarounds
  // - IE5/Mac reports itself as version 4.0
  if(this.ie && this.mac) {
    if(ua.indexOf("msie 5")) {
      this.major = 5;
      var actual_index = ua.indexOf("msie 5");
      var actual_major = ua.substring(actual_index + 5, actual_index + 8);
      this.minor = parseFloat(actual_major);
    }
  }

  return this;
}
function G_openWindow(url,title,w,h)
{
	window.open(url, title, "width=" + w + ", height=" + h + ", menubar=no, toolbar=no, status=no, resizable=yes, scrollbars=yes") 
}

