<HTML>
<HEAD>
<TITLE>JScripterman Order Form</TITLE>
<SCRIPT LANGUAGE="javascript">
var status="pass";
function validate(){
		checkrequired(); {
                               if (status=="failed"){
			return false;}}
		checkASCII();{
			if (status=="failed"){
			return false;}}
		phonestrip();
                        alert ("Congratulations! Your transaction has been passed to our imaginary database!");
                        return true;}
function phonestrip() {
	var text=document.address.phone.value;
	var cleanphone = "";
	dirtyphone=text.toString( );
                for(var i = 0; i < dirtyphone.length; i++)
                        {var oneChar = dirtyphone.charAt(i);
                        if ((oneChar<="9") && (oneChar>="0" ) ){
		cleanphone +=oneChar;
		}
                        }
		document.address.phone.value = cleanphone;
                        return true; }

function checkrequired(){
	if (document.address.fname.value == ""){
		alert("Please enter your first name.");
		document.address.fname.focus();
		status="failed";
		return false;
		}
	else if (document.address.lname.value==""){
		alert("Please enter your last name.");
		document.address.lname.focus();
		status= "failed";
		return false;}
	else if (document.address.country.value==""){
		alert("Please enter your country name.");
		document.address.country.focus();
		status="failed";
		return false;}
	else if (document.address.address1.value==""){
		alert("Please enter your street address.");
		document.address.address1.focus();
		status="failed";
		return false;}
	else if (document.address.city.value==""){
		alert("Please enter your city name.");
		document.address.city.focus();
		status="failed";
		return false;}
	else if (document.address.state.value==""){
		alert("Please enter your state, province, or region name.");
		document.address.state.focus();
		status="failed";
		return false;}
	else if (document.address.zipcode.value==""){
		alert("Please enter your zip or postal code.");
		document.address.zipcode.focus();
		status="failed";
		return false;}
	
	status = "pass";
	return true;}


function checkASCII()
{var text=document.address.fname.value;
  var correct_msg = " has some characters that are foreign to us. Please reenter it using English characters 
from A to Z or call our support desk."
	   if (islowASCII(text) == false){
		alert("Your first name" + correct_msg);
		document.address.fname.focus();
		document.address.fname.select();
		status="failed";
		return false;}

	  text=document.address.lname.value;
	   if (islowASCII(text) == false){
		alert("Your last name" + correct_msg);
		document.address.lname.focus();
		document.address.lname.select();
		status="failed";
		return false;}

	text=document.address.country.value;
	   if (islowASCII(text) == false){
		alert("Your country name" + correct_msg);
		document.address.country.focus();
		document.address.country.select();
		status="failed";
		return false;}

	text=document.address.address1.value;
	   if (islowASCII(text) == false){
		alert("Your address" + correct_msg);
		document.address.address1.focus();
		document.address.address1.select();
		status="failed";
		return false;}

	text=document.address.address2.value;
	   if (islowASCII(text) == false){
		alert("Your address" + correct_msg);
		document.address.address2.focus();
		document.address.address2.select();
		status="failed";
		return false;}

	text=document.address.address3.value;
	   if (islowASCII(text) == false){
		alert("Your address" + correct_msg);
		document.address.address3.focus();
		document.address.address3.select();
		status="failed";
		return false;}

	text=document.address.city.value;
	   if (islowASCII(text) == false){
		alert("Your city name" + correct_msg);
		document.address.city.focus();
		document.address.city.select();
		status="failed";
		return false;}

	text=document.address.state.value;
	   if (islowASCII(text) == false){
		alert("Your region name" + correct_msg);
		document.address.state.focus();
		document.address.state.select();
		status="failed";
		return false;}

	text=document.address.zipcode.value;
	   if (islowASCII(text) == false){
		alert("Your zipcode" + correct_msg);
		document.address.zipcode.focus();
		document.address.zipcode.select();
		status="failed";
		return false;}

	text=document.address.phone.value;
	   if (islowASCII(text) == false){
		alert("Your telephone number" + correct_msg);
		document.address.phone.focus();
		document.address.phone.select();
		status="failed";
		return false;}

	status = "pass";
	return true; }


function islowASCII(text){testtext=text.toString( );
                for(var i = 0; i < testtext.length; i++)
                        {var oneChar = testtext.charAt(i);
                        if (oneChar>"~"){return false}
                        }
                        return true; }

</SCRIPT>
</HEAD>
<BODY BACKGROUND="stamps.jpg">
<P>
<b>You've ordered one jacket and one pair of pants.</B></P>
<P><b><i>JScripterman delivers around the world, so just tell us where you are.</i></b></P>
</P>
<H2>Please enter your delivery address below:</H2>
<TABLE cellspacing =8 cellpadding=0>
<TR><TD  colspan = "2"  NOWRAP>
<FORM NAME="address">
<b>First&nbsp;Name:</b>&nbsp;&nbsp;<INPUT NAME="fname" SIZE=25
MAXLENGTH=25>&nbsp;&nbsp;&nbsp;
<b>Last&nbsp;Name:</b>&nbsp;&nbsp;<INPUT NAME="lname" SIZE=25
MAXLENGTH=25></TD></TR>
<TR NOWRAP><TD colspan = "2"> 
<b>Country:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT NAME="country"
SIZE=20 MAXLENGTH=30></TD></TR>
<TR NOWRAP><TD align=right><b>Street&nbsp;Address 1:</b></TD><TD>
<INPUT NAME="address1" SIZE=30 MAXLENGTH=30></TD></TR>
<TR NOWRAP><TD align=right><b>Street&nbsp;Address 2:</b></TD><TD>
<INPUT NAME="address2" SIZE=30 MAXLENGTH=30></TD></TR>
<TR NOWRAP><TD align=right><b>Street&nbsp;Address 3:</b></TD><TD>
<INPUT NAME="address3" SIZE=30 MAXLENGTH=30></TD></TR>
<TR NOWRAP><TD align=right><b>City:</b></TD><TD><INPUT NAME="city" SIZE=20
MAXLENGTH=20></TD></TR>
<TR NOWRAP><TD align=right><b>State/Province/Region:</b></TD><TD>
<INPUT NAME="state" SIZE=20 MAXLENGTH=20></TD></TR>
<TR NOWRAP><TD align=right><b>Zip/Postal&nbsp;Code:</b></TD><TD>
<INPUT NAME="zipcode" SIZE=9 MAXLENGTH=9></TD></TR>
<TR NOWRAP><TD align=right><b>Telephone&nbsp;Number:</b></TD><TD>
<INPUT NAME="phone" SIZE=29 MAXLENGTH=19></TD></TR>
</TABLE>

<P ><CENTER><INPUT TYPE=button VALUE="Commit Order"  
onClick=validate()>&nbsp;&nbsp;<INPUT TYPE=button VALUE="Return to Shop" 
onClick=window.location="shop.htm"></CENTER>
</FORM>
</BODY>
</HTML>