// Copyright © 2001 by Apple Computer, Inc., All Rights Reserved.


function checkWholeForm() {
	var thisForm = document.getElementById("gift");
    var why = "";
	why += checkName(thisForm.sender_name.value);
    why += checkEmail(thisForm.email.value);
	why += checkShipto(thisForm.shipto_name.value);
	why += checkAddress(thisForm.shipto_address1.value);
	why += checkCity(thisForm.shipto_city.value);
    why += checkState(thisForm.shipto_state.selectedIndex);
	why += checkZip(thisForm.shipto_zipcode.value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "Please enter your email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}   


// non-empty textbox

function checkName(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter your name.\n"
  }
return error;     
}

function checkShipto(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter the shipping name.\n"
  }
return error;     
}

function checkAddress(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter the shipping street address.\n"
  }
return error;     
}


function checkCity(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter the shipping city.\n"
  }
return error;     
}

function checkZip(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter the shipping zip code.\n"
  }
return error;     
}

// drop down

function checkState(choice) {
    var error = "";
    if (choice == 0) {
       error = "Please select the shipping state.\n";
    }    
return error;
}