

function openterms(){
var theurl="http://www.neorealestate.com/termsofservice.html"
winopen=window.open(theurl,"","width=850,height=720,resizable,")
}


function isNumber(str1)
{
	var str=""
	str=str1
	var strValidChars = "0123456789.-"
	for (var i = 0; i < str.length; i++)
	{
		var ch = str.charAt(i)
		if (strValidChars.indexOf(ch) == -1) 	
		{  		
			return false;
		}
	}
	return true;
}


function isValidDesc(str1)
{
var str=""
str=str1
// test for special chars like slashes, dashes etc.
var iChars = "@#^&*[]\\/{}|\"<>";

for (var i = 0; i < str.length; i++) 
{ 
if (iChars.indexOf(str.charAt(i)) != -1) 
	{
	 return false; 
	 } 
}
return true;
}


function isName(str1)
{
	 var strValidChars = "0123456789.-";
	var str=""
	str=str1
	if (str.length < 1)
	return false;
	for (var i = 0; i < str.length; i++)
	{
		var ch = str.charAt(i);
		 if (strValidChars.indexOf(ch) >= 1)

		{  		
			return false;
		}
	}
	return true;
}

 

function validEmail(email) 
{
	 var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	 var checkend=/\.[a-zA-Z]{2,3}$/;

	 if((email.search(exclude) != -1) || (email.search(checkend) == -1))	return false;
	 atPos = email.indexOf("@",0);
	 pPos1 = email.indexOf(".",0);
	 periodPos = email.indexOf(".",atPos);
	 pos1 = pPos1;
	 pos2 = 0;
	 while (pos2 > -1) 
	 {
	 	pos2 = email.indexOf(".",pos1+1);
		 if (pos2 == pos1+1)  return false;
	 	else  pos1 = pos2;
	 }
 	 if (atPos == -1)	return false;
	 if (atPos == 0)	return false;
	 if (pPos1 == 0)	return false;
	 if(email.indexOf("@",atPos+1) > -1)	return false;
	 if (periodPos == -1)	return false;
	 if (atPos+1 == periodPos)	return false;
	 if (periodPos+3 > email.length)	return false;
	 return true;
}

function Validate(FRM)
{
	
	var msg = ""
	if (document.enterform.listed.checked != 0)
	{
		if (document.enterform.AgentsName.value == "") 
		{	
			msg = "Please Provide Agents Name\n" + msg
			document.enterform.AgentsName.focus()
		}
		if (document.enterform.AgentsEmail.value == "") 
		{	
			msg = "Please Provide Agents Email\n" + msg
			document.enterform.AgentsEmail.focus()
		}
		if (document.enterform.AgentsPhone.value == "") 
		{	
			msg = "Please Provide Agents Phone\n" + msg
			document.enterform.AgentsPhone.focus()
		}
		if (document.enterform.AgentsFax.value == "") 
		{	
			msg = "Please Provide Agents Fax\n" + msg
			document.enterform.AgentsFax.focus()
		}
		if (document.enterform.AgentsCompany.value == "") 
		{	
			msg = "Please Provide Agents Company\n" + msg
			document.enterform.AgentsCompany.focus()
		}
	}
	
	if (document.enterform.acceptterms.checked == 0)
	{
		msg = "Please Review and Accept Terms of Service at Bottom of Page  \n" + msg
		document.enterform.acceptterms.focus()
	}
	
	if (document.enterform.PropDesc.value.length <= 25) 
	{	
		msg = "Enter a Valid Description greather than 25 characters\n" + msg
		document.enterform.PropDesc.focus()
	}
	else
	{
		if (!isValidDesc(document.enterform.PropDesc.value))
		{	
			msg = "Enter Letters & Punctuation for Description, no Special Chars or HTML \n" + msg
			document.enterform.PropDesc.focus()
		}
	}	
	



	if (document.enterform.sqftlot.value.length > 0)
	
	if (!isNumber(document.enterform.sqftlot.value))
	{
		msg = "Enter Lot Square Footage as a Whole Number or leave blank \n" + msg
		document.enterform.sqftlot.focus()
	}	


	if (document.enterform.sqftbldg.value.length > 0)
	
	if (!isNumber(document.enterform.sqftbldg.value))
	{
		msg = "Enter Building Square Footage as a Whole Number or leave blank \n" + msg
		document.enterform.sqftbldg.focus()
	}	

	
	if (document.enterform.PropPrice.value.length > 0)
	{
	if (!isNumber(document.enterform.PropPrice.value))
	{	
		
		msg = "Enter Valid Price as Whole Number \n" + msg
		document.enterform.PropPrice.focus()
 	}
	}
	else
		{
		msg="Enter a Price \n" + msg
		document.enterform.PropPrice.focus()
		}


	if (document.enterform.PropCountry.selectedIndex == 0)
	{
		msg = "Enter Country \n" + msg
		document.enterform.PropCountry.focus()
	}		
		


	if (document.enterform.PropZip.value.length<5)
		{
		msg = "Enter Valid 5 digit zip code \n" + msg
		document.enterform.PropZip.focus()
		}
	else
	{
		if (!isNumber(document.enterform.PropZip.value))
		{	
			msg = "Enter Digits Only for Zip Code \n" + msg
			document.enterform.PropZip.focus()
		}
	}	

	if (document.enterform.propstate.selectedIndex == 0)
	{
		msg = "Enter State \n" + msg
		document.enterform.propstate.focus()
	}

	

	
	if (document.enterform.PropCity.value == "") 
	{	
		msg = "Enter City\n" + msg
		document.enterform.PropCity.focus()
	}
	else
	{
		if (!isName(document.enterform.PropCity.value))
		{	
			msg = "Enter Letters only for City \n" + msg
			document.enterform.PropCity.focus()
		}
	}	



	if (document.enterform.PropAddress.value=="") 
	{	
		
		msg = "Enter Proper Address\n" + msg
		document.enterform.PropAddress.focus()
	}
	
	if (document.enterform.PropType.selectedIndex == 0)
	{
		msg = "Enter Property Type \n" + msg
		document.enterform.PropType.focus()
	}

	

	if (msg != "")
	{
		alert ("There Was a Problem With Your Form\n\n" + msg)
		return(false)
	}
	else
	{
		return(true)	
	}
}
