

//-----------------------------------------------------------------
// Check the Contact Us Form
//-----------------------------------------------------------------

function checkContactForm(theForm) {
    var why = "";
   //document.write("add= " + theForm.Address.value);
    why += checkFirst(theForm.First.value);
    why += checkLast(theForm.Last.value);
    why += checkEmail(theForm.email.value);
    why += checkAddress(theForm.Address.value);
    why += checkCity(theForm.City.value);
    why += checkZip(theForm.Zip.value);
    why += checkPhone(theForm.area.value+theForm.prefix.value+theForm.last4.value);
    why += checkBestTime(theForm);
    //why += checkMailing(theForm);

	if (why != "") {
      alert(why);
      return false;
    }
	else
	  showpane('http://www.1shoppingcart.com/app/join.asp?merchantid=138594','WineTrips','400','730');

return true;
}

function checkSeminarForm(theForm) {
    var why = "";
    //document.write("name= " + theForm.First.value);
    why += checkFirst(theForm.First.value);
    why += checkLast(theForm.Last.value);
    why += checkEmail(theForm.email.value);
    why += checkTitle(theForm.title.value);
    why += checkPhone(theForm.area.value+theForm.prefix.value+theForm.last4.value);
    why += checkSize(theForm);
    why += checkGross(theForm);

	if (why != "") {
      alert(why);
      return false;
    }
return true;
}

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an 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;    
}

// phone number - strip out delimiters and check for 10 digits
function checkPhone(strng) {

var error = "";
if (strng.length < 10) {
   error = "You didn't enter a valid phone number.\n";
}

//var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
//    if (isNaN(parseInt(stripped))) {
//       error = "The phone number contains illegal characters.";
//    }
//    if (!(stripped.length == 10)) {
//	error = "You didn't enter a valid phone number.\n";
//    } 
return error;
}

function checkFirst (strng) {
 var error = "";
 if (strng == "") {
    error = "You didn't enter a First name.\n";
 }
return error;    
} 
function checkLast (strng) {
 var error = "";
 if (strng == "") {
    error = "You didn't enter a Last name.\n";
 }
return error;    
} 
function checkAddress (strng) {
 var error = "";
 if (strng == "") {
    error = "You didn't enter an address.\n";
 }
return error;    
} 
function checkCity (strng) {
 var error = "";
 if (strng == "") {
    error = "You didn't enter a city.\n";
 }
return error;    
} 
function checkZip (strng) {
 var error = "";
 if (strng == "") {
    error = "You didn't enter a Zip.\n";
 }
return error;    
} 
function checkBestTime (theForm) {
 var error = "";
  if ( ( theForm.BestTime[0].checked == false ) && ( theForm.BestTime[1].checked == false ) ) 
    error = "You must enter a Best Time to call.\n";

return error;    
} 
function checkMailing (theForm) {
 var error = "";
  if ( ( theForm.Mailing[0].checked == false ) && ( theForm.Mailing[1].checked == false ) ) 
    error = "You must choose a Mailing List option.\n";

return error;    
} 
function checkTitle (strng) {
 var error = "";
 if (strng == "") {
    error = "You didn't enter a Job Title.\n";
 }
return error;    
} 

function checkSize (theForm) {
 var error = "";
  if ( ( theForm.size[0].checked == false ) && ( theForm.size[1].checked == false ) && ( theForm.size[2].checked == false ) && ( theForm.size[3].checked == false )) 
    error = "You must enter Number of Employees.\n";

return error;    
} 
function checkGross (theForm) {
 var error = "";
  if ( ( theForm.gross[0].checked == false ) && ( theForm.gross[1].checked == false ) && ( theForm.gross[2].checked == false ) && ( theForm.gross[3].checked == false )) 
    error = "You must enter Gross Sales.\n";

return error;    
} 



