function openwin()
{
	var zips = document.getElementById('azips');
	levy = ( screen.width - 600 ) / 2;
	horni = ( screen.height - 400 ) / 2;
	window.open('http://values.server294.com/zip-code-check.php?codes='+escape(zips.value), '', 'height=220, width=180, top='+horni+', left='+levy);
}

function isValidEmail(checkStr)
{
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
	var EmailValid = filter.test(checkStr);
	return (EmailValid);
}

function isValidZip(zip)
{
	var filter = /^[0-9]{5}$/;
	var zipValid = filter.test(zip);
	return zipValid;
}

function CheckForm()
{
	var fname = document.getElementById('first_name')
	var lname = document.getElementById('last_name');
	var hphone = document.getElementById('home_phone');
	var mail = document.getElementById('email');
	var address = document.getElementById('address');
	var city = document.getElementById('city');
	var zip = document.getElementById('zip');

	if ( fname.value == "" )
	{
		alert("Fill your First Name");
		fname.focus();
		return (false);
		exit();
	}

	if ( lname.value == "" )
	{
		alert("Enter your Last Name");
		lname.focus();
		return (false);
	}
	
	if ( hphone.value == "" )
	{
		alert("Enter your  Phone.");
		hphone.focus();
		return (false);
	}
	
	if ( mail.value == "" )
	{
		alert("Enter your Email.");
		mail.focus();
		return (false);
	}
	
	if (!isValidEmail(mail.value))
	{
    	alert("This is not valid email address! " + mail.value + " Fill email address again.");
	    mail.focus();
    	return (false);
	}

	if ( address.value == "" )
	{
		alert("Enter Property Address.");
		address.focus();
		return (false);
	}

	if ( city.value == "")
	{
		alert("Enter Property City.");
		city.focus();
		return (false);
	}

	if ( zip.value == "" )
	{
		alert("Enter Property ZIP.");
		zip.focus();
		return (false);
	}
	
	if ( !isValidZip(zip.value) )
	{
    	alert("This is not valid ZIP code: " + zip.value + " Fill ZIP code again. It must contain 5 digits.");
	    zip.focus();
    	return (false);
	}
	

	if ( zip.value.length != 5 )
	{
		alert("ZIP code have to be with 5 digits.");
		zip.focus();
		return (false);
	}
	return (true);
}

function CheckAgentForm()
{
	var fname = document.getElementById("first_name");
	var lname = document.getElementById("last_name");
	var mail = document.getElementById("email");
	var pwd = document.getElementById("password");
	var vpwd = document.getElementById("vpassword");
	var zip = document.getElementById("zip");
	var cphone = document.getElementById("cell_phone");
	var fax = document.getElementById("fax");
	var company = document.getElementById("company");
	var yrs = document.getElementById("years");
	var buy = document.getElementById("buyer");
	var sel = document.getElementById("seller");
	var street = document.getElementById("address");
	var city = document.getElementById("city");
	var state = document.getElementById("state");
	var azips = document.getElementById("azips");

	if ( fname.value == "" )
	{
		alert("Fill your First Name");
		fname.focus();
		return (false);
	}

	if ( lname.value == "" )
	{
		alert("Enter your Last Name");
		lname.focus();
		return (false);
	}

	if ( street.value == "" )
	{
		alert("Fill your street address");
		street.focus();
		return (false);
	}

	if ( city.value == "" )
	{
		alert("Enter your City");
		city.focus();
		return (false);
	}
	
	if ( state.value == "" )
	{
		alert("Enter your State");
		state.focus();
		return (false);
	}

	if ( zip.value == "" )
	{
		alert("Enter ZIP code.");
		zip.focus();
		return (false);
	}

	if ( !isValidZip(zip.value) )
	{
    	alert("This is not valid ZIP code: " + zip.value + " Fill ZIP code again. It must contain 5 digits.");
	    zip.focus();
    	return (false);
	}

	if ( cphone.value == "" )
	{
		alert("Enter your Cellular.");
		cphone.focus();
		return (false);
	}

	if ( fax.value == "" )
	{
		alert("Enter your Fax.");
		fax.focus();
		return (false);
	}

	if ( mail.value == "" )
	{
		alert("Enter your Email.");
		mail.focus();
		return (false);
	}

	if (!isValidEmail(mail.value))
	{
    	alert("This is not valid email address! " + mail.value + " Fill email address again.");
	    mail.focus();
    	return (false);
	}

	if ( company.value == "" )
	{
		alert("Enter your Company.");
		company.focus();
		return (false);
	}

	if ( yrs.value == "" )
	{
		alert("Enter how man years in the business.");
		yrs.focus();
		return (false);
	}

	if ( sel.value == "" )
	{
		alert("Enter your seller transaction per year.");
		sel.focus();
		return (false);
	}

	if ( buy.value == "" )
	{
		alert("Enter your buyer transaction per year.");
		buy.focus();
		return (false);
	}

	if ( pwd.value == "" )
	{
		alert("Enter your Password.");
		pwd.focus();
		return (false);
	}

	if ( pwd.value != vpwd.value )
	{
		alert("Passwords does not match. Fill it again.");
		vpwd.focus();
		return (false);
	}

	if ( azips.value == "" )
	{
		alert("Enter at least one zip code.");
		azips.focus();
		return (false);
	}

return (true);
}
