
function submitLogin(){
var formValid = true;
var chkTerms = document.frm_login.chkTerms.checked
// determine if last name is entered
if (document.frm_login.last_name.value == ""){
alert("Last Name is required to login. Please enter your Last Name.");
document.frm_login.last_name.focus(); 
formValid=false;
}
// determine if member number is entered
if (document.frm_login.member_number.value <= "00000000" && formValid){
alert("Member Number is invaild. Please enter valid Member Number.");
document.frm_login.member_number.focus(); 
formValid=false;
}
// determine if member number is entered
if (chkTerms != true && formValid){
alert("You must read and agree to the Terms of Use before being allowed to login. Please check the appropriate box if you have already done so.");
document.frm_login.chkTerms.focus(); 
formValid=false;
}
if (formValid){
document.body.style.cursor="wait";
document.frm_login.submit();
}
}
function openTerms(theURL) 
{
var URL = new String();
URL= "" + theURL;
popupWin = window.open(URL,"windowTerms","location=no,scrollbars,toolbar=no,address=no,resizable=no,top=100,left=150,width=600,height=450");
} 
function openWindow(theURL) 
{
var URL = new String();
URL= "" + theURL;
popupWin = window.open(URL,"window","location,scrollbars,toolbar,resizable,top=100,left=150,width=710,height=400");
}
function openBB(theURL) 
{
var URL = new String();
URL= "" + theURL;
popupWin = window.open(URL,"windowBB","scrollbars=yes,status=no,menubar=no,toolbar=yes,resizable=yes,directories=no,locationbar=no,top=70,left=70,width=840,height=500");
}
function emailCheck(emailStr) {
/* The following pattern is used to check if the entered e-mail address
fits the user@domain format. It also is used to separate the username
from the domain. */
var emailPat=/^(.+)@(.+)$/;
/* The following string represents the pattern for matching all special
characters. We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
/* The following string represents the range of characters allowed in a 
username or domainname. It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]";
/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes). E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")";
/* The following pattern applies for domains that are IP addresses,
rather than symbolic names. E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
/* The following string represents an atom (basically a series of
non-special characters.) */
var atom=validChars + '+';
/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")";
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */
alert("Email address seems incorrect. (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
// See if "user" is valid 
if (user.match(userPat)==null) {
// user is not valid
alert("Email address seems incorrect. The username entered doesn't seem to be valid.");
return false;
}
/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
// this is an IP address
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Email address seems incorrect. Destination IP address is invalid!");
return false;
}
}
return true;
}
// Domain is symbolic name 
var domainArray=domain.match(domainPat);
if (domainArray==null) {
alert("Email address seems incorrect. The domain name doesn't seem to be valid.");
return false;
}
/* domain name seems valid, but now make sure that it ends in a
three-letter word (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country.
Get a count of how many atoms it consists of.*/
var atomPat=new RegExp(atom,"g");
var domArr=domain.match(atomPat);
var len=domArr.length;
if (domArr[domArr.length-1].length<2 || 
domArr[domArr.length-1].length>4) {
// the address must end in a two, three, or four letter word.
alert("Email address seems incorrect. The address must end in a two, three or four-letter domain.");
return false;
}
// Make sure there's a host name preceding the domain.
if (len<2) {
var errStr="Email address seems incorrect. This email address is missing a hostname!";
alert(errStr);
return false;
}
// Everything is valid
return true;
}
function validateAcqForm(objForm) { 
/* 
AUTHOR: TWH
DATE: 4/4/02
DESC: Contains all Acquisition Form field validation.
ACTION: Submits form if all fields are valid.
*/
var formValid = true;
var fieldNames = new Array("fname","lname","address1","city","zip","email");
var infoTypes = new Array("'First Name'","'Last Name'","'Address line1'","'City'","'Zip/Postal Code'","'E-mail'");
//var fieldNames2 = new Array("address2");
//var infoTypes2 = new Array("'Address line 2'");
var strProvinces = "AB,BC,MB,NB,NF,NT,NS,NU,ON,PE,QC,SK,YT"
for (ii = 0; ii < fieldNames.length; ++ii) {
if (ii < fieldNames.length) {
// validate required fields entered and not just a space entered.
if (objForm[fieldNames[ii]].value == "" || checkSpaceField(objForm[fieldNames[ii]].value) == 0) {
alert(infoTypes[ii] + " is required. Please type it in.");
formValid = false;
objForm[fieldNames[ii]].focus();
break; 
}
// check required fields for a tidle character. 
if (checkTilde(objForm[fieldNames[ii]].value)) {
alert(infoTypes[ii] + " cannot contain a Tilde (~) character. Tidle is not allowed in any field. Please make correction(s).");
formValid = false;
objForm[fieldNames[ii]].focus();
break; 
}
// check required fields for a comma character. 
if (checkComma(objForm[fieldNames[ii]].value)) {
alert(infoTypes[ii] + " cannot contain a Comma (,) character. A Comma is not allowed in any field. Please make correction(s).");
formValid = false;
objForm[fieldNames[ii]].focus();
break; 
}
// validate email address syntax.
if (objForm[fieldNames[ii]].name == "email") { 
if (emailCheck(objForm[fieldNames[ii]].value) == false) {
formValid = false;
objForm[fieldNames[ii]].focus();
break; 
}
}
}
else {
for (jj=1; jj<=lengths.length; ++jj) {
if (objForm[fieldNames[ii] + "_" + jj].value.length != lengths[jj-1]) {
alert("The " + infoTypes[ii] + " is not typed in correctly!");
formValid = false;
document.objForm[fieldNames[ii] + "_" + jj].focus();
break;
}
}
if (!formValid)
break;
}//end if/else
}//end for
//***********************************
/*
for (kk = 0; kk < fieldNames2.length; ++kk) {
if (kk < fieldNames2.length) {
// check required fields for a tidle character. 
if (checkTilde(objForm[fieldNames2[kk]].value)) {
alert(infoTypes2[kk] + " cannot contain a Tilde (~) character. Tidle is not allowed in any field. Please make correction(s).");
formValid = false;
objForm[fieldNames2[kk]].focus();
break; 
}
// check required fields for a comma character. 
if (checkComma(objForm[fieldNames2[kk]].value)) {
alert(infoTypes2[kk] + " cannot contain a Comma (,) character. A Comma is not allowed in any field. Please make correction(s).");
formValid = false;
objForm[fieldNames2[kk]].focus();
break; 
}
}
}//end for
*/
//**************************************
// begin specific field(s) validation 
// validate selection of state
if ((document.frm_signup.state.options[0].selected) && formValid) {
alert("State/Province must be selected.");
formValid = false;
document.frm_signup.state.focus();
}
// validate age selection.
// if ((age_selection == "") && formValid) {
//if (!(document.frm_signup.age[0].checked || document.frm_signup.age[1].checked) && formValid) {
//alert("Age range is required. Please make a selection.");
//formValid = false;
//document.frm_signup.age.focus();
//}
// validate zip fields.
if (formValid) { 
// if USA
if (document.frm_signup.country.value=="USA"){
if (document.frm_signup.zip.value.length==5){
numZip=/\d{5,}/;
}
else{
numZip=/\d{9,}/;
}
if (!numZip.test(document.frm_signup.zip.value)){
alert("USA Zip Code must contain only numbers. Enter as 5 digits or 9 digits with no dash.");
formValid=false;
document.frm_signup.zip.focus();
} 
else if (document.frm_signup.zip.value.length != 5 && document.frm_signup.zip.value.length != 9) {
alert("USA Zip Code must be entered as 5 digits or 9 digits with no dash.");
formValid = false;
document.frm_signup.zip.focus();
}
}// end USA
//if CANADA
if (document.frm_signup.country.value=="CANADA"){ 
if (formValid) {
numZip=/[a-zA-Z]{1,}/;
if (!numZip.test(document.frm_signup.zip.value)){
alert("Canadian Zip Code entered contains only numbers. Zip Code must be entered as 6 characters with no space or dash.");
formValid=false;
document.frm_signup.zip.focus();
} 
else if (document.frm_signup.zip.value.length < 6 || document.frm_signup.zip.value.length >= 7) {
alert("Canadian Zip Code must be entered as 6 characters with no space or dash.");
formValid = false;
document.frm_signup.zip.focus();
}
} 
}//end Canada 
}// end if form valid 
if (formValid){
document.body.style.cursor="wait";
return true;
}
return false
}// end validateForm function
function validateCountry() { 
if ((document.frm_signup.state.value=="AB") || (document.frm_signup.state.value=="BC") || (document.frm_signup.state.value=="MB") || (document.frm_signup.state.value=="NB") || (document.frm_signup.state.value=="NF") || (document.frm_signup.state.value=="NT") || (document.frm_signup.state.value=="NS") || (document.frm_signup.state.value=="NU") || (document.frm_signup.state.value=="ON") || (document.frm_signup.state.value=="PE") || (document.frm_signup.state.value=="QC") || (document.frm_signup.state.value=="SK") || (document.frm_signup.state.value=="YT")){
document.frm_signup.country.value="CANADA";
}
else if(document.frm_signup.state.value==""){
alert("State/Province must be selected.");
document.frm_signup.country.value=="";
}
else{
document.frm_signup.country.value="USA";
}
}// end validateCountry function
function checkTilde(input) 
{
// check to see if input contains a tidle (~)
for (var i = 0; i < input.length; i++) 
{
if ((input.charCodeAt(i) == 126)) 
{
return true;
} 
}
return false;
}
function checkSpaceField(input) {
/* 
AUTHOR: Rick Weyenberg, Cornerstone Consulting
DATE: 03/05/2001
DESC: Converts spaces to empty values to see if 
the value of the textfield is made up of spaces 
only
RETURNS: integer value of 0 if all spaces
integer value of > 0 if not all spaces
*/
var output = "";
for (var i = 0; i < input.length; i++) 
{
if ((input.charCodeAt(i) == 32)) 
{
output += "";
} 
else 
{
output += input.charAt(i);
}
}
return output.length;
}
function checkComma(input) {
/* 
AUTHOR: DMS - Cornerstone Consulting
DATE: 8/15/02
DESC: check to see if input contains a comma (,).
Comma is not allow due to it being our delimiter in data transfers.
RETURNS: true is comma found
false is no comma found
*/
// check to see if input contains a comma (,)
for (var i = 0; i < input.length; i++) 
{
if ((input.charCodeAt(i) == 44)) 
{
return true;
} 
}
return false;
}
function GiveawayForm(objFormB) { 
objFormB.submit();
}


//for email_collection.asp page 
function EmailForm(objFormB) {
 
 var formValid = true;
 
 // check required fields for a tidle character. 
 if (checkTilde(document.email_collection.email_address.value)) {
 alert("Email address cannot contain a Tilde (~) character. Please make correction(s).");
 formValid = false;
 document.email_collection.email_address.focus();
 //break; 
 }
 // check required fields for a comma character. 
 if (checkComma(document.email_collection.email_address.value)) {
 alert("Email address cannot contain a Comma (,) character. Please make correction(s).");
 formValid = false;
 document.email_collection.email_address.focus();
 //break; 
 }
 // validate email address syntax.
 //if (objForm[fieldNames[ii]].name == "email") { 
 if (emailCheck(document.email_collection.email_address.value) == false) {
 formValid = false;
 document.email_collection.email_address.focus();
 //break; 
 }
 //}
 
 if (formValid){ 
 document.body.style.cursor="wait";
 return true;
 }
 else{ 
 return false;
 }
 //return false
}// end emailform function
