nav_ = new Image();
nav_.src = "images/nav__on.gif";

     NS4 = (document.layers);
     IE4 = (document.all);
    ver4 = (NS4 || IE4);
    IE5 = (IE4 && navigator.appVersion.indexOf("5.")!=-1);
   isMac = (navigator.appVersion.indexOf("Mac") != -1);
  isMenu = (NS4 || (IE4 && !isMac) || (IE5 && !isMac));
function popUp(){return};
function popDown(){return};

if (!ver4) event=null;

function img_over(imgName) 
{
	if (document.images) 
	{
		imgOver = eval(imgName + "_on.src");
		document [imgName].src = imgOver;
	}
}

function img_off(imgName) 
{
	if (document.images) 
	{
		imgOff = eval(imgName  + "_off.src");
		document [imgName].src = imgOff;
	}
}

function mortgagePopup()
{
	wWidth = 500;
	wHeight = 400;
	wResizeWidth = wWidth + 12;
	wResizeHeight = wHeight + 91;
	wLeft = (screen.width - wResizeWidth) / 2;
	wTop = ((screen.height - wResizeHeight) / 2 - 20);
	mortgageWindow = window.open("mortgage_pop.asp", "mortgage", "width="+wWidth+",height="+wHeight+",left="+wLeft+",top="+wTop+", toolbar=no, directories=no, location=no, status=no, menubar=yes, resizable=yes, scrollbars=yes");
	mortgageWindow.resizeTo(wResizeWidth,wResizeHeight);
	mortgageWindow.moveTo(wLeft,wTop);
	mortgageWindow.focus();
	if (parseInt(navigator.appVersion) >= 4)
		{ mortgageWindow.window.focus(); }
}

function addNew(table, field, label)
{
	wWidth = 350;
	wHeight = 120;
	wResizeWidth = wWidth + 12;
	wResizeHeight = wHeight + 91;
	wLeft = (screen.width - wResizeWidth) / 2;
	wTop = ((screen.height - wResizeHeight) / 2 - 20);
	addNewWindow = window.open("addnew.asp?table="+table+"&field="+field+"&label="+label, "addnew", "width="+wWidth+",height="+wHeight+",left="+wLeft+",top="+wTop+", toolbar=no, directories=no, location=no, status=no, menubar=yes, resizable=yes, scrollbars=yes");
	addNewWindow.resizeTo(wResizeWidth,wResizeHeight);
	addNewWindow.moveTo(wLeft,wTop);
	addNewWindow.focus();
	if (parseInt(navigator.appVersion) >= 4)
		{ addNewWindow.window.focus(); }
}

function showMapWindow(imgwidth, imgheight)
{
	wWidth = imgwidth;
	wHeight = imgheight + 60;
	wResizeWidth = imgwidth + 12;
	wResizeHeight = imgheight + 91;
	wLeft = (screen.width - wResizeWidth) / 2;
	wTop = ((screen.height - wResizeHeight) / 2 - 20);
	mapWindow = window.open("/images/counties.gif", "map", "width="+wWidth+",height="+wHeight+",left="+wLeft+",top="+wTop+", toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=yes, scrollbars=no");
	mapWindow.resizeTo(wResizeWidth,wResizeHeight);
	mapWindow.moveTo(wLeft,wTop);
	mapWindow.focus();
	if (parseInt(navigator.appVersion) >= 4)
		{ mapWindow.window.focus(); }
}


/*
	Requires "onClick="NewWindow(this.href,'title','400','300','no');return false;"" in the A HREF tag
	Example: <a href="doc.html" onClick="NewWindow(this.href,'title','400','300','no');return false;">LINK</a>
*/

function NewWindow(mypage, myname, w, h, scroll)
{
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=yes'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4)
	{ win.window.focus(); }
}

function OpenDetailWindow(id, listtype) 
{	
	wWindowWidth = 810;
	wWindowHeight = 600;
	wWidth = wWindowWidth;
	wHeight = wWindowHeight + 60;
	wResizeWidth = wWindowWidth + 12;
	wResizeHeight = wWindowHeight + 91;
	wLeft = (screen.width - wResizeWidth) / 2;
	wTop = ((screen.height - wResizeHeight) / 2 - 20);
	picWindow = window.open("/propertydetailpage.asp?id="+id+"&type="+listtype, "detail", "width="+wWidth+",height="+wHeight+",left="+wLeft+",top="+wTop+", toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=yes, scrollbars=yes");
	picWindow.resizeTo(wResizeWidth,wResizeHeight); 
	picWindow.moveTo(wLeft,wTop);
	picWindow.focus();
}


function CenteredWindow(mypage, myname, h, w) 
{
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',status=no, menubar=no, scrollbars=no, resizable=no, directories=no, location=no, toolbar=no';
win = window.open(mypage, myname, winprops);
win.window.focus();
}

function setFocus()
{
	var checkEmail = document.login.email.value;

	if (! checkEmail)
		document.login.email.focus();		
	else
		document.login.pw.focus();
}

function showTable(tblid)
{
	var i = 1
	while (i<5)
	{
		var objTBL = document.getElementById("tbl" + i);
		if (i == tblid)
			objTBL.style.display="";
		else
			objTBL.style.display="none";
		i++;
	}
}

function showDetail(tblid)
{
var objTBL = document.getElementById("tbl" + tblid);
var objIMG = document.getElementById("img" + tblid);
if (objTBL.style.display=="")
	{objTBL.style.display="none";
	objIMG.innerHTML = "<a href='javascript:showDetail(" + tblid + ");'><img src='/images/plus.gif' border=0></a>";}
else
	{objTBL.style.display="";
	objIMG.innerHTML = "<a href='javascript:showDetail(" + tblid + ");'><img src='/images/minus.gif' border=0></a>";}
}

function showTableNew(tblid)
{
	var i = 1
	while (i<6)
	{
		var objTBL = document.getElementById("tbl" + i);
		if (i == tblid)
			objTBL.style.display="";
		else
			objTBL.style.display="none";
		i++;
	}
}

function previewsendlisting(theform)
{
	var mlsid = theform.id.value;
	var listtype = theform.listtype.value;
	
	wWidth = 800;
	wHeight = 600 + 60;
	wResizeWidth = 800 + 12;
	wResizeHeight = 600 + 91;
	wLeft = (screen.width - wResizeWidth) / 2;
	wTop = ((screen.height - wResizeHeight) / 2 - 20);
	printWindow = window.open("/sendlisting_build.asp?listtype=" + listtype + "&id="+mlsid, "print", "width="+wWidth+",height="+wHeight+",left="+wLeft+",top="+wTop+", toolbar=no, directories=no, location=no, status=no, menubar=yes, resizable=yes, scrollbars=yes");
	printWindow.resizeTo(wResizeWidth,wResizeHeight);
	printWindow.moveTo(wLeft,wTop);
	printWindow.focus();
	if (parseInt(navigator.appVersion) >= 4)
		{ printWindow.window.focus(); }
}


/* JAVASCRIPT CHECKS */


function checktowns(userID)
{
	if (userID == 1)
	{
		return true;
	}
	else
	{
		var checkMLSNum=document.search.mlsnum.value;
		checkMLSNum = checkMLSNum.replace(/^\s*|\s*$/g,"");
		if (! checkMLSNum)
		{
			var townCount = 0;
			for (var i = 0; i < document.search.town.length; i++)
			{
				if (document.search.town.options[i].selected == true)
					townCount += 1;
			}
			if (townCount == 0)
				{
				alert("At least one city/town must be selected.  Entire states cannot be selected.");
				document.search.town.focus();
				return false;
				}
			else
				{
				if (townCount > 15)
					{
					alert("Please limit the number of towns to search to 15 or less.");
					document.search.town.focus();
					return false;
					}
				else
					{return true;}
				}
		}
		else
		{
			return true;
		}
	}
}


function CheckMoreInfoData()
 {
      var checkName=document.moreinfo.fullname.value;
      var checkEmail=document.moreinfo.infoemail.value;
      var checkPhone=document.moreinfo.phone.value;
	  
      if (! checkName)
      {
        alert("Please enter your name to request more information.");
        document.moreinfo.fullname.focus();
        return false;
      }

      if (! checkEmail)
      {
        alert("Please enter your email address to request more information.");
        document.moreinfo.infoemail.focus();
        return false;
      }

      if (! checkPhone)
      {
        alert("Please enter your phone number to request more information.");
        document.moreinfo.phone.focus();
        return false;
      }

  return true;
}

function CheckRegisterData()
 {
      var checkName=document.register.fullname.value;
      var checkEmail=document.register.email.value;
      var checkPW=document.register.pw.value;
      var checkPWConfirm=document.register.confirm_pw.value;
	  
      if (! checkName)
      {
        alert("Please enter your name.");
        document.register.fullname.focus();
        return false;
      }

      if (! checkEmail)
      {
        alert("Please enter your email address.");
        document.register.email.focus();
        return false;
      }

      if (! checkPW)
      {
        alert("Please enter your password.");
        document.register.pw.focus();
        return false;
      }

      if (! checkPWConfirm)
      {
        alert("Please enter your password twice.");
        document.register.confirm_pw.focus();
        return false;
      }

      if (checkPWConfirm != checkPW)
      {
        alert("The two passwords do not match.  Please enter your password again");
        document.register.pw.value = "";
        document.register.confirm_pw.value = "";
        document.register.pw.focus();
        return false;
      }

  return true;
}

function CheckPWData()
 {
	  var checkCurrentPW=document.pwform.currentpw.value;
	  var checkNewPW=document.pwform.newpw.value;
	  var checkConfirmNewPW=document.pwform.confirmnewpw.value;

	  if (! checkCurrentPW)
	  {
		alert("Please enter your current password.");
		document.pwform.currentpw.focus();
		return false;
	  }

	  if (! checkNewPW)
	  {
		alert("Please enter your new password.");
		document.pwform.newpw.focus();
		return false;
	  }

	  if (! checkConfirmNewPW)
	  {
		alert("Please confirm your new password.");
		document.pwform.confirmnewpw.focus();
		return false;
	  }

	  if (checkNewPW != checkConfirmNewPW)
	  {
		alert("The two new passwords do not match.  Please enter your new password again");
		document.pwform.confirmnewpw.value = "";
		document.pwform.newpw.value = "";
		document.pwform.newpw.focus();
		return false;
	  }

  return true;
}

function CheckProfileData()
 {
	  var checkName=document.profile.fullname.value;
	  var checkEmail=document.profile.email.value;
	  var checkPW=document.profile.pw.value;
	  var checkPWConfirm=document.profile.confirm_pw.value;

	  if (! checkName)
	  {
		alert("Please enter your name.");
		document.profile.fullname.focus();
		return false;
	  }

	  if (! checkEmail)
	  {
		alert("Please enter your email address.");
		document.profile.email.focus();
		return false;
	  }

  return true;
}

function CheckCMAData()
 {
	  var checkName=document.cma.fullname.value;
	  var checkAddress=document.cma.address.value;
	  var checkCity=document.cma.city.value;
	  var checkState=document.cma.state.value;
	  var checkZip=document.cma.zip.value;
	  var checkPhone=document.cma.phone.value;

	  if (! checkName)
	  {
		alert("Please enter your name.");
		document.cma.fullname.focus();
		return false;
	  }

	  if (! checkAddress)
	  {
		alert("Please enter your address.");
		document.cma.address.focus();
		return false;
	  }

	  if (! checkCity)
	  {
		alert("Please enter your city.");
		document.cma.city.focus();
		return false;
	  }

	  if (! checkState)
	  {
		alert("Please enter your state.");
		document.cma.state.focus();
		return false;
	  }

	  if (! checkZip)
	  {
		alert("Please enter your zip code.");
		document.cma.zip.focus();
		return false;
	  }

	  if (! checkPhone)
	  {
		alert("Please enter your phone.");
		document.cma.phone.focus();
		return false;
	  }

  return true;
}

function CheckSavedSearch()
 {
	  var checkName=document.search.searchname.value;

	  if (! checkName)
	  {
		alert("Please enter a name for the saved search.");
		document.search.searchname.focus();
		return false;
	  }

  return true;
}

function CheckForgotPWData()
 {
      var checkEmail=document.frm.email.value;

      if (! checkEmail)
      {
        alert("Please enter your email address.");
        document.frm.email.focus();
        return false;
      }

  return true;
}

function CheckEmailRemoveData()
 {
	  var checkEmail=document.remove.email.value;

	  if (! checkEmail)
	  {
		alert("Please enter your email address to be removed.");
		document.remove.email.focus();
		return false;
	  }

  return true;
}

function CheckSendListing()
 {
	  var checkEmail=document.sendlisting.listingRecip.value;

	  if (! checkEmail)
	  {
		alert("Please enter your email address to send to.");
		document.sendlisting.listingRecip.focus();
		return false;
	  }

  return true;
}

function CheckHeaderLoginData()
 {
      var checkEmail=document.headerlogin.email.value;
      var checkPW=document.headerlogin.pw.value;

      if (! checkEmail)
      {
        alert("Please enter your email address to login.");
        document.headerlogin.email.focus();
        return false;
      }

      if (! checkPW)
      {
        alert("Please enter your password to login.");
        document.headerlogin.pw.focus();
        return false;
      }

  return true;
}

function CheckAccountLoginData()
 {
      var checkEmail=document.login.email.value;
      var checkPW=document.login.pw.value;

      if (! checkEmail)
      {
        alert("Please enter your email address to login.");
        document.login.email.focus();
        return false;
      }

      if (! checkPW)
      {
        alert("Please enter your password to login.");
        document.login.pw.focus();
        return false;
      }

  return true;
}

/* JAVASCRIPT CONFIRMS */

function confirmSendAll()
{
	testRecip = document.sendlisting.testRecip.value;
	if (testRecip == "")
	{
		msg = "Send message to all selected board (Seacoast/Strafford/Both) agents?";
		if (confirm(msg))
			return true;
		return false;
	}
}

function confirmResetSource()
{
	msg = "Are you sure you want to reset the count for this source?";
	if (confirm(msg))
		return true;
	return false;
}

function confirmDelete()
{
	msg = "Are you sure you want to delete this record?";
	if (confirm(msg))
		return true;
	return false;
}

function confirmDeleteThis(thisType)
{
	msg = "Are you sure you want to delete this " + thisType + "?";
	if (confirm(msg))
		return true;
	return false;
}

function confirmDeleteProspect()
{
	msg = "Are you sure you want to delete this prospect?";
	if (confirm(msg))
		return true;
	return false;
}

function confirmDeleteUser()
{
	msg = "Are you sure you want to delete this user?";
	if (confirm(msg))
		return true;
	return false;
}

function confirmDeleteListing()
{
	msg = "Are you sure you want to delete this saved listing?";
	if (confirm(msg))
		return true;
	return false;
}

function confirmDeleteSearch()
{
	msg = "Are you sure you want to delete this saved search?";
	if (confirm(msg))
		return true;
	return false;
}

function confirmDeleteFL()
{
	msg = "Are you sure you want to delete this featured listing?";
	if (confirm(msg))
		return true;
	return false;
}

function setSort(sortValue)
{
	self.location.href="searchresults.asp?listtype=<%=listtype%>&sort=" + sortValue;
}

/* JAVASCRIPT MENU LOADING */

function init() {
	if (mtDropDown.isSupported()) 
	{
		mtDropDown.initialize();
	}
}

	function clearValuesChange()
	{
		//document.search.streetname.value = "";
		document.search.minprice.selectedIndex = 0;
		document.search.maxprice.selectedIndex = 0;
		document.search.bedrooms.selectedIndex = 0;
		document.search.baths.selectedIndex = 0;
		document.search.lot_size_acres.selectedIndex = 0;
		document.search.glaag.selectedIndex = 0;
		//document.search.waterfront.checked = false;
		document.search.waterbody.value = "";
	}

	function resetValues()
	{
		document.search.listtype.selectedIndex = 0;
		//document.search.streetname.value = "";
		document.search.minprice.selectedIndex = 0;
		document.search.maxprice.selectedIndex = 0;
		document.search.bedrooms.selectedIndex = 0;
		document.search.baths.selectedIndex = 0;
		document.search.lot_size_acres.selectedIndex = 0;
		document.search.glaag.selectedIndex = 0;
		//document.search.waterfront.checked = false;
		document.search.waterbody.value = "";
		i=0;
		while(i<document.search.town.length) 
		{
		document.search.town.options[i].selected = false;
		i++;
		}
	}

	function setDisplay(listtype)
	{
		switch(listtype)
		{
		/* residential */
		case "1":
			document.search.listtype.selectedIndex = 0;
			document.getElementById("restyperow").style.display = '';
			document.getElementById("bedrow").style.display = '';
			document.getElementById("bathrow").style.display = '';
			document.getElementById("lotrow").style.display = '';
			document.getElementById("sqftrow").style.display = '';
			document.getElementById("unitsrow").style.display = 'none';
			document.getElementById("waterfrontrow").style.display = '';
			//document.getElementById("seasonalrow").style.display = '';
			document.getElementById("waterbodyrow").style.display = '';
			clearValuesChange();
			break;

		/* land */
		case "2":
			document.search.listtype.selectedIndex = 1;
			document.getElementById("restyperow").style.display = 'none';
			document.getElementById("bedrow").style.display = 'none';
			document.getElementById("bathrow").style.display = 'none';
			document.getElementById("lotrow").style.display = '';
			document.getElementById("sqftrow").style.display = 'none';
			document.getElementById("unitsrow").style.display = 'none';
			document.getElementById("waterfrontrow").style.display = '';
			//document.getElementById("seasonalrow").style.display = 'none';
			document.getElementById("waterbodyrow").style.display = '';
			clearValuesChange();
			break;

		/* commercial */
		case "3":
			document.search.listtype.selectedIndex = 3;
			document.getElementById("restyperow").style.display = 'none';
			document.getElementById("bedrow").style.display = 'none';
			document.getElementById("bathrow").style.display = 'none';
			document.getElementById("lotrow").style.display = '';
			document.getElementById("sqftrow").style.display = 'none';
			document.getElementById("unitsrow").style.display = 'none';
			document.getElementById("waterfrontrow").style.display = 'none';
			//document.getElementById("seasonalrow").style.display = '';
			document.getElementById("waterbodyrow").style.display = 'none';
			//document.getElementById("waterbodytyperow").style.display = 'none';
			clearValuesChange();
			break;

		/* multifamily */
		case "4":
			document.search.listtype.selectedIndex = 2;
			document.getElementById("restyperow").style.display = 'none';
			document.getElementById("bedrow").style.display = 'none';
			document.getElementById("bathrow").style.display = 'none';
			document.getElementById("lotrow").style.display = '';
			document.getElementById("sqftrow").style.display = 'none';
			document.getElementById("unitsrow").style.display = '';
			document.getElementById("waterfrontrow").style.display = 'none';
			//document.getElementById("seasonalrow").style.display = '';
			document.getElementById("waterbodyrow").style.display = 'none';
			clearValuesChange();
			break;

		}

	}

