function open_window(url) {
	mywin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=381,height=435');
}

function isEmailAddr(theemail) {
	var result = false
	var theStr = new String(theemail)
	var index = theStr.indexOf("@");
	if (index > 0) {
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
	}
	return result;
}		

function validateSendPage() {
	var invalid = " ";
	
	if (document.mailthis.from.value=="") {
		alert("Please enter your name in the From field.");
		document.mailthis.from.focus();
		return false;
	}
	if (document.mailthis.to.value=="") {
		alert("Please enter the name of the person you are sending this link to.");
		document.mailthis.to.focus();
		return false;
	}
	if (document.mailthis.email.value=="") {
		alert("Please enter an email address.");
		document.mailthis.email.focus();
		return false;
	}
	if (document.mailthis.email.value.indexOf(invalid) > -1) { 
		alert("Spaces are not allowed in valid email addresses.  Please remove the spaces and try again.");
		document.mailthis.email.focus();
		return false;
	}
	if (!isEmailAddr(document.mailthis.email.value)) {
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		document.mailthis.email.focus();
		return false;
	}
	if (document.mailthis.email.value.length < 3) {
		alert("Please enter at least 3 characters in the \"email\" field.");
		document.mailthis.email.focus();
		return false;
	}
}

function checkFrm() {
	if ((document.listings.passcode.value=="") | (document.listings.passcode.value=="passcode")) {
		alert("Please enter your passcode.");
		document.listings.passcode.focus();
		return false;
	}
}

function checkglobal() {
	var invalid = " ";
	
	if ((document.global.fname.value=="") | (document.global.fname.value=="First Name")) {
		alert("Please enter a first name.");
		document.global.fname.focus();
		return false;
	}
	if ((document.global.lname.value=="") | (document.global.lname.value=="Last Name")) {
		alert("Please enter a last name.");
		document.global.lname.focus();
		return false;
	}
	if ((document.global.phone.value=="") | (document.global.phone.value=="Phone Number")) {
		alert("Please enter a phone number.");
		document.global.phone.focus();
		return false;
	}
	if (document.global.email.value.indexOf(invalid) > -1) { 
		alert("Spaces are not allowed in valid email addresses.  Please remove the spaces and try again.");
		document.global.email.focus();
		return false;
	}
	if ((document.global.email.value=="") | (document.global.email.value=="Email")) {
		alert("Please enter an email address.");
		document.global.email.focus();
		return false;
	}
	if (!isEmailAddr(document.global.email.value)) {
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		document.global.email.focus();
		return false;
	}
	if (document.global.email.value.length < 3) {
		alert("Please enter at least 3 characters in the \"email\" field.");
		document.global.email.focus();
		return false;
	}
	if ((document.global.max_rent.value=="") | (document.global.max_rent.value=="Maximum Rent")) {
		alert("Please enter the maximum amount of rent you would consider paying.");
		document.global.max_rent.focus();
		return false;
	}
	
	if (isNaN(document.global.max_rent.value)) {
		alert("Please enter whole numbers only.  Dashes (-), Dots (.), Dollar Signs ($), Commas (,) and spaces are not allowed.")
		document.global.max_rent.focus();
		return false;
	}
	//var ValidChars = "0123456789";
	//var IsNumber=true;
	//var Char;
	//alert("Got Here");
	//for (i = 0; i < document.global.max_rent.length && IsNumber == true; i++) { 
	//	Char = document.global.max_rent.charAt(i); 
	//	if (ValidChars.indexOf(Char) == -1) {
	//		IsNumber=false;
	//		alert("Please enter whole numbers only.  Dashes (-), Dots (.), Dollar Signs ($), Commas (,) and spaces are not allowed.")
	//		document.global.max_rent.focus();
	//		return false;
	//	}
	//}
	
	if (document.global.bedrooms.options[0].selected) {
		alert('Please select the number of bedrooms you would prefer.');
		document.global.bedrooms.focus();
		return false;
	}
	if (document.global.month.options[0].selected) {
		alert('Please select the month you are anticipating moving in.');
		document.global.month.focus();
		return false;
	}
	if (document.global.day.options[0].selected) {
		alert('Please select the day you are anticipating moving in.');
		document.global.day.focus();
		return false;
	}
}
