function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  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 validNumber(theform) {
var i;
var formElements = theform.elements;
for (i=0; i<formElements.length; i++) {
	if (formElements[i].type == "text") {
		if (!IsNumeric(formElements[i].value)) {
			formElements[i].value = "0";
			}
		}
	}
}	
function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;   
 }
function validUser(theform){
var fname 	= theform.fname;
var lname	= theform.lname;
var address	= theform.address;
var city	= theform.city;
var zip		= theform.zip;
var state	= theform.state;
var country	= theform.country;
var dphone	= theform.dphone;
var email	= theform.email;
var pass	= theform.pass;
var pass2	= theform.pass2;

if(fname.value == ""){ alert("Please enter your first name"); fname.focus(); return false;}
if(lname.value == ""){ alert("Please enter your last name"); lname.focus(); return false;}
if(address.value == ""){ alert("Please enter an address"); address.focus(); return false;}
if(city.value == ""){ alert("Please enter a city and state"); city.focus(); return false;}
if(zip.value == ""){ alert("Please enter a zip or postal code"); zip.focus(); return false;}
if(state.value == ""){ alert("Please Select a state or province"); state.focus(); return false;}
if(country.value == ""){ alert("Please select a country"); country.focus(); return false;}
if(dphone.value == ""){ alert("Please enter a daytime phone number"); dphone.focus(); return false;}
if(email.value == ""){ alert("Please enter a an email address"); email.focus(); return false;}
if (!isEmailAddr(email.value))
  {
    alert("Please enter a complete email address: yourname@yourdomain.com");
    email.focus();
    return false;
 }
if(pass.value == ""){ alert("Please enter a password"); pass.focus(); return false;}
if(pass.value != pass2.value){ alert("Your passwords do not match."); pass2.focus(); return false;}
}
function validCheckOut(theform){
var b_fname 	= theform.b_fname;
var b_lname		= theform.b_lname;
var b_address	= theform.b_address1;
var b_city		= theform.b_city;
var b_zip		= theform.b_zip;
var b_state		= theform.b_state;
var b_country	= theform.b_country;
var b_dphone	= theform.b_dphone;
var b_email		= theform.b_email;
var s_fname 	= theform.s_fname;
var s_lname		= theform.s_lname;
var s_address	= theform.s_address1;
var s_city		= theform.s_city;
var s_zip		= theform.s_zip;
var s_state		= theform.s_state;
var s_country	= theform.s_country;
var s_dphone	= theform.s_dphone;
var s_email		= theform.s_email;
var cc			= theform.cc;
var cc_no		= theform.cc_no;
var exp_month	= theform.exp_month;
var exp_year	= theform.exp_year;

if(b_fname.value == ""){ alert("Please enter your first name"); b_fname.focus(); return false;}
if(b_lname.value == ""){ alert("Please enter your last name"); b_lname.focus(); return false;}
if(b_address.value == ""){ alert("Please enter an address"); b_address.focus(); return false;}
if(b_city.value == ""){ alert("Please enter a city and state"); b_city.focus(); return false;}
if(b_zip.value == ""){ alert("Please enter a zip or postal code"); b_zip.focus(); return false;}
if(b_state.value == ""){ alert("Please Select a state or province"); b_state.focus(); return false;}
if(b_country.value == ""){ alert("Please select a country"); b_country.focus(); return false;}
if(b_dphone.value == ""){ alert("Please enter a daytime phone number"); b_dphone.focus(); return false;}
if(b_email.value == ""){ alert("Please enter a an email address"); b_email.focus(); return false;}
if (!isEmailAddr(b_email.value))
  {
    alert("Please enter a complete email address: yourname@yourdomain.com");
    b_email.focus();
    return false;
 }

if(s_fname.value == ""){ alert("Please enter your first name"); s_fname.focus(); return false;}
if(s_lname.value == ""){ alert("Please enter your last name"); s_lname.focus(); return false;}
if(s_address.value == ""){ alert("Please enter an address"); s_address.focus(); return false;}
if(s_city.value == ""){ alert("Please enter a city and state"); s_city.focus(); return false;}
if(s_zip.value == ""){ alert("Please enter a zip or postal code"); s_zip.focus(); return false;}
if(s_state.value == ""){ alert("Please Select a state or province"); s_state.focus(); return false;}
if(s_country.value == ""){ alert("Please select a country"); s_country.focus(); return false;}
if(s_dphone.value == ""){ alert("Please enter a daytime phone number"); s_dphone.focus(); return false;}
if(s_email.value == ""){ alert("Please enter a an email address"); s_email.focus(); return false;}
if (!isEmailAddr(s_email.value))
  {
    alert("Please enter a complete email address: yourname@yourdomain.com");
    s_email.focus();
    return false;
 }
if(cc.value == ""){ alert("Please select a Credit Card"); cc.focus(); return false;}
if(cc_no.value == ""){ alert("Please enter a credit card number"); cc_no.focus(); return false;}
if(exp_month.value == ""){ alert("Please enter an expiration date"); exp_month.focus(); return false;}
if(exp_year.value == ""){ alert("Please enter an expiration date"); exp_year.focus(); return false;}
}
function validMailer(theform){
var email 	= theform.email;
if(email.value == ""){ alert("Please enter a an email address"); email.focus(); return false;}
if (!isEmailAddr(email.value))
  {
    alert("Please enter a complete email address: yourname@yourdomain.com");
    email.focus();
    return false;
 }
}
