
<!--
// JavaScript Document

function checklogin()
{
// function checks for correct number of digits in password, must be 4 digits
	if (document.realestate.password.value.length < 4)
	{
		alert("Password must have 4 or more characters")
		document.realestate.password.focus();
		document.realestate.password.select();
		return false;
	}

// function checks for correct number of digits in password, must be 4 digits
	if (document.realestate.username.value.length < 4)
	{
		alert("User name must have 4 or more characters")
		document.realestate.username.focus();
		document.realestate.username.select();
		return false;
	}
	
	if (document.realestate.username.value == "username")
	{
		alert("Enter a user name")
		document.realestate.username.focus();
		document.realestate.username.select();
		return false;
	}
}

var newWindow;
function open_window()
// this function checks screen resolution and places pop up window in middle of browser window to search zip codes
{
	var winTop = (screen.height / 2 ) - 130;
	var winLeft = (screen.width / 2 ) - 170;
// make a url that contains the state variable 
	var windowurl = "search_zip/searchzip.cfm?newstate=AN"; 
	var windowFeatures = "width=340,height=260,";
	windowFeatures = windowFeatures + "left=" + winLeft + ",";
	windowFeatures = windowFeatures + "top=" + winTop;
//	newWindow = window.open("search_zip/searchzip.cfm","myWindow",windowFeatures);
	newWindow = window.open(windowurl,"myWindow",windowFeatures);
}

function open_whatisthis()
// this function checks screen resolution and places pop up window in middle of browser window for help re: saved listings
{
	var winTop = (screen.height / 2 ) - 200;
	var winLeft = (screen.width / 2 ) - 190;
	var windowFeatures = "width=380,height=400,";
	windowFeatures = windowFeatures + "left=" + winLeft + ",";
	windowFeatures = windowFeatures + "top=" + winTop + "," + "scrollbars=yes";
	newWindow = window.open("help/helpsaved.cfm","myWindow",windowFeatures);
}

function regExpIs_valid(text)
// function is called to check for invalid characters in zip code
{
	var myRegExp = /[^\d]/;
	// any number 0-9, see pg 301
	return ! (myRegExp.test(text));
}

function checkzip()
// function checks zip code
{
	if (regExpIs_valid(document.propsearch.zip.value) == true)
	{
		// characters in phone number ok, now check for 5 digits
				if (!(document.propsearch.zip.value.length == 5))
					{
						alert("Zip code must be 5 digits")
						document.propsearch.zip.focus();
						document.propsearch.zip.select();
						return false;
					}
					else
					{
					//everything is ok
					return true;
					}	
	}
	else
	{
	alert("Invalid characters in zip code")
	document.propsearch.zip.focus();
	document.propsearch.zip.select();
	return false;
	}
}		

function clearform(url)
// function clears session variables
{
window.location.replace(url);
}

function checkcity()
// function checks number of characters in city search box
{
	
	if (document.propsearch.city.value == "Any")
	{
		alert("Please enter a city name")
		document.propsearch.city.focus();
		document.propsearch.city.select();
		return false;
	}

	if (document.propsearch.city.value.length < 3)
	{
		alert("City name must have 3 or more characters")
		document.propsearch.city.focus();
		document.propsearch.city.select();
		return false;
	}
	if (document.propsearch.state.value == "AN")
	{
		alert("You must select a state");
		document.propsearch.state.focus();
		return false;
	}

}

function clearcity()
// this used to reset form variables in city search box
{
	document.propsearch.city.value = "";
	document.propsearch.propertytype.value = "RA";
	document.propsearch.radius.value = 5;
	document.propsearch.state.value = "AN";
}


function getCookieValue(cookieName)
// function gets cookie to see if user is a return visitor
{
	var cookieValue = document.cookie;
	//alert (document.cookie);
	var cookieStartsAt = cookieValue.indexOf(" " + cookieName + "=");
	if (cookieStartsAt == -1)
		{
			cookieStartsAt = cookieValue.indexOf(cookieName + "=");
		}
	if (cookieStartsAt == -1)
		{
			cookieValue = null;
		}
	else
		{
			cookieStartsAt = cookieValue.indexOf("=" , cookieStartsAt) + 1;
			var cookieEndsAt = cookieValue.indexOf(";", cookieStartsAt);
				if (cookieEndsAt == -1)
					{
						cookieEndsAt = cookieValue.length;
					}
					cookieValue = unescape(cookieValue.substring(cookieStartsAt, cookieEndsAt));
		}
		return cookieValue;
}


/*
function checkhotlistcookie()
{
// this script checks if cookie has been set for favorities list
var hotlist = getCookieValue("hotlist");
	
	if (hotlist == null)
		{
			// there is no hotlist listings set
			alert("You have no saved listings. Please search properties first, then select listings to save.");
			return false;
		}
	else
		{
			window.location.href = "listings/listings.cfm?srchby=fav";
			return true; 
		}
}
*/


//-->