function AddTitleBackgrounds() {
	var inputArr = new Array();
	inputArr = document.getElementsByTagName("input");
	for (i=0; i<inputArr.length; i++) {
		if (inputArr[i].type == "text" && inputArr[i].title != "") {
			if (inputArr[i].value == "" || inputArr[i].value == inputArr[i].title) {
				inputArr[i].style.color = "#cccccc";
				inputArr[i].value = inputArr[i].title;
			}
			inputArr[i].onfocus = function() {
				if (this.value == this.title) {
					this.value = "";
					this.style.color = "#000000";
				}
			}
			inputArr[i].onblur = function() {
				if (this.value == "") {
					this.style.color = "#cccccc";
					this.value = this.title;
				}
			}
		}
	}
}

function clearTitles() {
	var inputArr = new Array();
	inputArr = document.getElementsByTagName("input");
	for (i=0; i<inputArr.length; i++) {
		if (inputArr[i].value == inputArr[i].title) {
			inputArr[i].value = "";
		}
	}
	return true;
}

function tglDiv(id, show) {
	document.getElementById(id).style.display = show ? 'block' : 'none';
}

function fetchAddress(ln, backcall) {
	if (ln.length >= 6 && ln.length <= 8) {
		httpRequester.open("getNoCache", "services/propertyFromLN.cfm?LN=" + ln, true);
		httpRequester.onreadystatechange = backcall;
		httpRequester.send(null);
	}
}

function ShowingProperty() {
	if ( httpRequester.readyState == 4 ) {
		var docx = xmlLoad(httpRequester.responseText);
		try {
			document.registerForm.szShowingPropertyAddress1.value = getTagValue(docx, 'address');
			document.registerForm.szShowingPropertyCity.value = getTagValue(docx, 'city');
			selectDropDownOption(document.registerForm.szShowingPropertyState, getTagValue(docx, 'state'));
			document.registerForm.szShowingPropertyZipCode.value = getTagValue(docx, 'zip');
		} catch(e) {
			//alert(httpRequester.responseText);
		}
	}
}

function MakeOffer() {
	if ( httpRequester.readyState == 4 ) {
		var docx = xmlLoad(httpRequester.responseText);
		try {
			document.registerForm.szMakeOfferAddress1.value = getTagValue(docx, 'address');
			document.registerForm.szMakeOfferCity.value = getTagValue(docx, 'city');
			selectDropDownOption(document.registerForm.szMakeOfferState, getTagValue(docx, 'state'));
			document.registerForm.szMakeOfferZipCode.value = getTagValue(docx, 'zip');
		} catch(e) {
			//alert(httpRequester.responseText);
		}
	}
}

function getTagValue(docx, tag) {
	var retval = "";
	if (docx.getElementsByTagName(tag)[0].firstChild)
		retval = docx.getElementsByTagName(tag)[0].firstChild.nodeValue;
	return retval;
}

function selectDropDownOption(dd, val) {
	for (var i=0; i<dd.options.length; i++) {
		if (dd.options[i].value == val) {
			dd.options[i].selected = true;
		}
	}
}