<!--

//*** New function for getting zip4 from post office************************************************************************

function formsubmit(frmzip) {

var theURL;

theURL='http://www.usps.com/zip4/zip4_response.jsp?Selection=1&urbanization=&firm=&address='+frmzip.address.value+'&address1='+frmzip.address.value+'&address2=&city='+frmzip.city.value+'&state=IL&zipcode='+frmzip.zip.value

//alert(theURL);

window.open(theURL,'mywindow','width=600,height=400,toolbar=no,location=no,directories=yes,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes')



//frmzip.submit();

}

//*** Global Variables ************************************************************************
var newWindow;
var myform = document.actNow;   			
//

//*** Functions:  onerror *********************************************************************
function onerror(msg, URL, linenum){
	return true;
}


//*** Functions:  gotoPage ********************************************************************
function gotoPage(){
	var str;
	var state = document.actNow.state.value;
	if(state == 'IL'){
		 str = "to Illinois";
		 document.actNow.stateVal.value = str;
		 document.actNow.action = 'sendmail_il.asp';
		 }
	else{
		 str = "to other states";
		 document.actNow.stateVal.value = str;
		 document.actNow.action = 'sendmail_other.asp';
	}
}

//*** Functions:  emailCheck ******************************************************************
function emailCheck(email) {
	invalidChars = " /:,;"
	if (email == "") {
		return true
	}
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) != -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) != -1) {
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return false
	}
	if (periodPos+3 > email.length)	{
		return false
	}
	return true
}

//*** Functions:  stripBlank ******************************************************************
//*** Purpose:  Strips blanks/CRLF CHR(32) from string.  Acts like a Left and Right Trim VB Function
function stripBlank(inputVal) {
	// Perform a LTRIM
	var inputStr = inputVal.toString()
	var foundnonblank = "no";
	var newString = "";
	for (var i = 0; i < inputStr.length; i++) {
		var thisChar = inputStr.charAt(i)
		if ((inputStr.charCodeAt(i) == 10 || inputStr.charCodeAt(i) == 13 || inputStr.charCodeAt(i) == 32) && foundnonblank == "no") {
			thisChar = ''; 
		}
		else {
			foundnonblank = "yes";
		
		}
		newString = newString + thisChar;
	}
	// Perform a RTRIM
	var inputStr = newString;
	var foundnonblank = "no";
	var newString = "";
	for (var i = inputStr.length - 1; i >= 0; i--) {
		var thisChar = inputStr.charAt(i)
		if ((inputStr.charCodeAt(i) == 10 || inputStr.charCodeAt(i) == 13 || inputStr.charCodeAt(i) == 32) && foundnonblank == "no") {
			thisChar = ''; 
		}
		else {
			foundnonblank = "yes";
		}
		newString = thisChar + newString;
	}
	return newString
}
	
//*** Functions:  isNumberString **************************************************************
function isNumberString (InString)  {
	if(InString.length==0) return (false);
	var RefString="1234567890";
	for (Count=0; Count < InString.length; Count++)  {
		TempChar= InString.substring (Count, Count+1);
		if (RefString.indexOf (TempChar, 0)==-1)  
		return (false);
	}
	return (true);
}

//*** Functions:  addressCheck ***************************************************************
function addressCheck () {
	if (document.actNow.address.value == "")
	{
		alert ("Please complete address");
		document.actNow.address.focus();
		document.actNow.address.select();
		return false;
	}
	return true;
}

//*** Functions:  zipCheck ********************************************************************
function zipCheck () {
	var zip = document.actNow.zip.value;
	if (zip == "")
	{
		alert ("Please enter a 5 digit ZipCode");
		document.actNow.zip.focus();
		document.actNow.zip.select();
		return false;
	}
	if (zip.length != 5)
	{
		alert ("Please enter a 5 digit ZipCode");
		document.actNow.zip.focus();
		document.actNow.zip.select();
		return false;
	}
	var TestVar;
	TestVar = isNumberString (zip)
	if (TestVar != 1){
		alert ("Please enter a 5 digit ZipCode"); 
		document.actNow.zip.focus();
		document.actNow.zip.select();
		return false;
	} 
	return true;
}
	 
//*** Functions:  zipPlus4Check ***************************************************************
function zipPlus4Check () {
	var zipcode = document.actNow.zip_4.value;
	if (zipcode == "")
	{
		alert ("Please enter a 4 digit Zip+4");
		//document.actNow.zipplus4.focus();
		//document.actNow.zipplus4.select();
		return false;
	}
	if (zipcode.length !=4 )
	{
		alert ("Please enter a 4 digit Zip+4");
		document.actNow.zipplus4.focus();
		document.actNow.zipplus4.select();
		return false;
	}
	var TestVar;
	TestVar = isNumberString (zipcode)
	if (TestVar != 1){
		alert ("Please enter a 4 digit Zip+4"); 
		document.actNow.zipplus4.focus();
		document.actNow.zipplus4.select();
		return false;
	} 
	return true;
}
	 


//*** Functions:  zipPlus4 *******************************************************************



function zipPlus4()	{
	
	var myForm=document.actNow


	 
	// Perform Right and Left Trim on all Textboxes
	


	for (i = 0 ; i < document.actNow.elements.length; i++){

	

		if (document.actNow.elements[i].type == "text") {
			document.actNow.elements[i].value = stripBlank(document.actNow.elements[i].value);
		
		
		
		}

		
	}

	
	


	bCheck = addressCheck(); if (!bCheck) return;
	bCheck = zipCheck(); if (!bCheck) return;
	
	if (!newWindow || newWindow.closed) { 
		//alert("window is closed");
	} 
	else 
	{
		//alert("window is open");
		newWindow.close();
	}
	
	newWindow = window.open("","","width=600,height=400,scrollbars=yes,resizable=yes")
	

	//if (!newWindow.opener) newWindow.opener = window
	

	
		

	// assemble content for the new window
	var newContent = "<HTML><HEAD><TITLE>Locate ZIP+4</TITLE>"
	newContent += "</HEAD>"
	newContent += "<BODY>"
	newContent += "<form name='USPSForm' method='post' action='http://www.usps.com/zip4/zip4_response.jsp'>"
	newContent += "<INPUT id=FormsEditField6 type='hidden' name=Firm>"
	newContent += "<INPUT id=FormsEditField7 type='hidden' name=Urbanization>"
	newContent += "<INPUT id=address1 type='hidden' name='address1'>"
	newContent += "<INPUT id=city type='hidden' name=city>"
	newContent += "<INPUT id=state type='hidden' name=state>"
	newContent += "<INPUT id=zipcode type='hidden' name='zipcode'>"																								
	newContent += "</form>"
	newContent += "<" + "script language='Javascript'>"
	newContent += "{"
	newContent += "alert('Please wait while your \\'Zip+4\\' is obtained.\\n\\nOnce the \\'Zip+4\\' is obtained:\\n1.) Close the \\'Zip+4 Code Lookup\\' screen.\\n2.) Enter the \\'Zip+4\\' in the appropriate field.');"
	newContent += "document.forms['USPSForm'].elements['zipcode'].value = '" + document.actNow.zip.value + "';"
	newContent += "document.forms['USPSForm'].elements['address1'].value = '" + document.actNow.address.value + "';"
	newContent += "document.USPSForm.submit();"
	newContent += "}"
	newContent += "</" + "script>"
	newContent += "</BODY>"
	newContent += "</HTML>"

	
	// write HTML to new window document
	newWindow.document.write(newContent);
	// close layout stream
	newWindow.document.close();
	// submit the form in the new window
	newWindow.focus()
 	return;
 }	 
	




function formCheck() {

	




//check that first name field length not zero

if (document.actNow.elements['firstname'].value.length <=0) {
alert("Please Enter Your First Name")
return false;

}

//check that last name field length not zero

if (document.actNow.elements['lastname'].value.length <=0) {
alert("Please Enter Your Last Name")
return false;

} 


//check for address 1 field
if (!addressCheck()) {
return false; 
}

//check for city field
if (document.actNow.elements['city'].value.length <=0) {
alert("Please Enter Your City")
return false;

}

//check for city field
if (document.actNow.elements['state'].value.length <=0) {
alert("Please Enter Your State")
return false;

}

//check for zip field
if (!zipCheck()) {

return false;

}


//check for zip plus four field

if (!zipPlus4Check()) {

 return false;
}

//check for email

if (!emailCheck(document.actNow.elements['email'].value)) {

alert("Please Enter a Valid Email Address");

return false;

}




}


//-->

