var forsaleon = new Image;
var forsaleoff = new Image;
var forleaseon = new Image;
var forleaseoff = new Image;
var contacton = new Image;
var contactoff = new Image;
var tenanton = new Image;
var tenantoff = new Image;

forsaleon.src = "/img/forsale_on.gif";
forsaleoff.src = "/img/forsale_off.gif";
forleaseon.src = "/img/forlease_on.gif";
forleaseoff.src = "/img/forlease_off.gif";
contacton.src = "/img/contact_on.gif";
contactoff.src = "/img/contact_off.gif";
tenanton.src = "/img/tenant_on.gif";
tenantoff.src = "/img/tenant_off.gif";

function hiLite(status, pic) {
	document[pic].src = eval(pic + status + ".src");
}

function loginLoad() {
	document.frmLogin.txtUser.focus();
}

function validateLogin() {
	if (document.frmLogin.txtUser.value == "")
	{
		alert('Please enter your user name in the box provided.');
		document.frmLogin.txtUser.focus();
		return false;
	}
	if (document.frmLogin.txtPass.value == "")
	{
		alert('Please enter your password in the box provided.');
		document.frmLogin.txtPass.focus();
		return false;
	}
	return true;
}

function addProperty(where) {
	strURL = "/admin/add_prop.asp?loc=" + where;
	window.location.href = strURL;
}

function editProperty(which) {
	strURL = "/admin/edit_prop.asp?propid=" + which;
	window.location.href = strURL;
}

function deleteProperty(which, where) {
	if (confirm('Are you sure you want to delete this property? You will not be able to undo this operation.'))
	{
		document.frmProperty.action.value = "delete";
		document.frmProperty.propid.value = which;
		document.frmProperty.sortorder.value = where;
		document.frmProperty.submit();
	}
}

function discardChanges() {
	if (confirm('Are you sure you want to undo any changes you have made? All information will be lost.'))
	{
		window.location.reload();
	}
}

function validateEditProperty() {
	var notecount = 0;
	if (document.frmEditProperty.txtPropName.value == "")
	{
		alert('Please enter a property name in the box provided.');
		document.frmEditProperty.txtPropName.focus();
		return false;
	}
	if (document.frmEditProperty.txtPropAddress.value == "")
	{
		alert('Please enter the property address in the box provided.');
		document.frmEditProperty.txtPropAddress.focus();
		return false;
	}
	if (document.frmEditProperty.txtPropCity.value == "")
	{
		alert('Please enter a city in the box provided.');
		document.frmEditProperty.txtPropCity.focus();
		return false;
	}
	if (document.frmEditProperty.txtPropState.value == "")
	{
		alert('Please enter a state in the box provided.');
		document.frmEditProperty.txtPropState.focus();
		return false;
	}
	if (document.frmEditProperty.txtPropZip.value == "")
	{
		alert('Please enter a zip code in the box provided.');
		document.frmEditProperty.txtPropZip.focus();
		return false;
	}
	if (document.frmEditProperty.txtPropNote1.value != "")
	{
		notecount = notecount + 1;
	}
	if (document.frmEditProperty.txtPropNote2.value != "")
	{
		notecount = notecount + 1;
	}
	if (document.frmEditProperty.txtPropNote3.value != "")
	{
		notecount = notecount + 1;
	}
	if (notecount == 0)
	{
		alert('You must enter information in at least one of the Note fields.');
		document.frmEditProperty.txtPropNote1.focus();
		return false;
	}
	if (document.frmEditProperty.txtPropRank.value == "")
	{
		document.frmEditProperty.txtPropRank.value = 0;
	}
	document.frmEditProperty.submit();
}

function validateAddProperty() {
	var notecount = 0;
	if (document.frmAddProperty.txtPropName.value == "")
	{
		alert('Please enter a property name in the box provided.');
		document.frmAddProperty.txtPropName.focus();
		return false;
	}
	if (document.frmAddProperty.txtPropAddress.value == "")
	{
		alert('Please enter the property address in the box provided.');
		document.frmAddProperty.txtPropAddress.focus();
		return false;
	}
	if (document.frmAddProperty.txtPropCity.value == "")
	{
		alert('Please enter a city in the box provided.');
		document.frmAddProperty.txtPropCity.focus();
		return false;
	}
	if (document.frmAddProperty.txtPropState.value == "")
	{
		alert('Please enter a state in the box provided.');
		document.frmAddProperty.txtPropState.focus();
		return false;
	}
	if (document.frmAddProperty.txtPropZip.value == "")
	{
		alert('Please enter a zip code in the box provided.');
		document.frmAddProperty.txtPropZip.focus();
		return false;
	}
	if (document.frmAddProperty.txtPropNote1.value != "")
	{
		notecount = notecount + 1;
	}
	if (document.frmAddProperty.txtPropNote2.value != "")
	{
		notecount = notecount + 1;
	}
	if (document.frmAddProperty.txtPropNote3.value != "")
	{
		notecount = notecount + 1;
	}
	if (notecount == 0)
	{
		alert('You must enter information in at least one of the Note fields.');
		document.frmAddProperty.txtPropNote1.focus();
		return false;
	}
	if (document.frmAddProperty.txtPropRank.value == "")
	{
		document.frmAddProperty.txtPropRank.value = 0;
	}
	document.frmAddProperty.submit();
}


function validateJoin() {
	if (document.frmJoin.txtFirst.value == "")
	{
		alert('Please enter your first name in the box provided.');
		document.frmJoin.txtFirst.focus();
		return false;
	}
	if (document.frmJoin.txtLast.value == "")
	{
		alert('Please enter your last name in the box provided.');
		document.frmJoin.txtLast.focus();
		return false;
	}
	if (document.frmJoin.txtAddress.value == "")
	{
		alert('Please enter your address in the box provided.');
		document.frmJoin.txtAddress.focus();
		return false;
	}
	if (document.frmJoin.txtCity.value == "")
	{
		alert('Please enter your city in the box provided.');
		document.frmJoin.txtCity.focus();
		return false;
	}
	if (document.frmJoin.txtState.value == "")
	{
		alert('Please enter your state in the box provided.');
		document.frmJoin.txtState.focus();
		return false;
	}
	if (document.frmJoin.txtZip.value == "")
	{
		alert('Please enter your zip code in the box provided.');
		document.frmJoin.txtZip.focus();
		return false;
	}
	return true;
}
