errorClr = "#ffff00";

noErrorClr = "#ffffff";



// Added By Robert Odil

function isCreditCard(st) {

  // Encoding only works on cards with less than 19 digits

  if (st.length > 19)

    return (false);



  sum = 0; mul = 1; l = st.length;

  for (i = 0; i < l; i++) {

    digit = st.substring(l-i-1,l-i);

    tproduct = parseInt(digit ,10)*mul;

    if (tproduct >= 10)

      sum += (tproduct % 10) + 1;

    else

      sum += tproduct;

    if (mul == 1)

      mul++;

    else

      mul--;

  }

  if ((sum % 10) == 0)

    return (true);

  else

    return (false);



}



function isDiscover(cc)

{

  first4digs = cc.substring(0,4);

  if ((cc.length == 16) && (first4digs == "6011"))

    return isCreditCard(cc);

  return false;



}



function isAmericanExpress(cc)

{

  firstdig = cc.substring(0,1);

  seconddig = cc.substring(1,2);

  if ((cc.length == 15) && (firstdig == 3) &&

      ((seconddig == 4) || (seconddig == 7)))

    return isCreditCard(cc);

  return false;



}



function isMasterCard(cc)

{

  firstdig = cc.substring(0,1);

  seconddig = cc.substring(1,2);

  if ((cc.length == 16) && (firstdig == 5) &&

      ((seconddig >= 1) && (seconddig <= 5)))

    return isCreditCard(cc);

  return false;



}



function isVisa(cc)

{

  if (((cc.length == 16) || (cc.length == 13)) &&

      (cc.substring(0,1) == 4))

    return isCreditCard(cc);

  return false;

}



function isAnyCard(cc)

{

  if (cc == '411111111111111')

  	return true;

  if (!isCreditCard(cc))

    return false;

  if (!isMasterCard(cc) && !isVisa(cc) && !isAmericanExpress(cc) && !isDiscover(cc)) {

    return false;

  }

  return true;



}



// End Addition



//John Addition

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;

}



//End John Addition





function checke(e){

	if(document.images){

		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;

		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;

		if (!e.match(re) && e.match(re_two)) {

			return (-1);		

		}

	}

}



function ucFirst(l,a){

	if(l){

		f = l.charAt(0);

		f = f.toUpperCase();

		l = f + "" + l.substr(1);

	}

	if(a == 3 && document.images){ // apply to all

		ALLCAPS = new Array();

		ALLCAPS = l.split(" ");

		if(ALLCAPS[0]){

			str = "";

			for(AC = 0; AC < ALLCAPS.length; AC++){

				ALLCAPS[AC] = ucFirst(ALLCAPS[AC]);

				str += ALLCAPS[AC] + " ";

			}

			l = str.substr(0,str.length - 1);

		}

		delete ALLCAPS;

	}

	return (l);

}



function checkZip(z){

	//if(document.images){  //Digits only

	//	z.value = z.value.replace(/\D+/, "");

	//}

	// international zips also.

	if(z.value.length < 1){

		alert("Whoops, please check your zip code."); // Only digits are allowed

		if(document.all || document.getElementById){

			z.style.background = errorClr;

		}

		z.focus();

		return (false);

	}

	return (z);

}



function noSpace(s){

	// no spaces in id

	if(s.value.match(/\s+/)){

		alert("Whoops, no spaces allowed in Event ID"); 

		if(document.all || document.getElementById){

			s.style.background = errorClr;

		}

		s.focus();

		return (false);

	}

	return true;

}



function matchFields(a,b){

	if(a.value != b.value){

		alert("Whoops, the two values you entered do not match");

		if(document.all || document.getElementById){

			a.style.background = errorClr;

		}

		a.value = "";

		b.value = "";

		a.focus();

		return (false);

	}

	return true;

}



function checkEventID(f){

	if(!eventidchecked) {

		alert("Whoops, you've got to verify your event id");

		if(document.all || document.getElementById){

			f.event_id.style.background = errorClr;

		}

		f.event_id.focus();

		return (false);

	}

	if(!eventidok) {

		alert("Whoops, you need a unique event id");

		if(document.all || document.getElementById){

			f.event_id.style.background = errorClr;

		}

		f.event_id.focus();

		return (false);

	}

	return true;

}



function illChars(a,b){

	if(a.value.match(/\W+/)){

		alert("Whoops, illegal character found in password"); 

		if(document.all || document.getElementById){

			a.style.background = errorClr;

		}

		a.value = "";

		b.value = "";

		a.focus();

		return (false);

	}

	return true;

}



// args = form object, array element, check e-mail if value

function checkField(f,w,e){

	// upper case first

	if(w[1] > 0){

		f[w[0]].value = ucFirst(f[w[0]].value, w[1]);

	}



	if ((f[w[0]]) && (f[w[0]].style)) {

       f[w[0]].style.background = noErrorClr;

    }



    //Added by John //dont allow only spaces as an answer

	if (!(f[w[0]])) {

		return true;

	}



	if (f[w[0]].value) {

        var re = new RegExp (' ', 'gi') ;

        if ((f[w[0]].value.replace(re, '')) == "") { 

			alert("Whoops, you missed field: " + w[4]);

			if(document.all || document.getElementById){

				f[w[0]].style.background = errorClr;

			}

			f[w[0]].focus();

			return (false);

        }

    }

    //End John Added



	// all fields must have value

	if(w[3] == "Number"){//John Addition

		if(!(IsNumeric(f[w[0]].value)) || (f[w[0]].value.length < w[2])) {

			alert("Whoops, " + w[4] + " must be numeric only");

			if(document.all || document.getElementById){

				f[w[0]].style.background = errorClr;

			}

			f[w[0]].focus();

			return (false);

		}

	//End addition

	} else if(w[3] == "Text"){

		if(f[w[0]].value.length < w[2]) {

			alert("Whoops, you missed field: " + w[4]);

			if(document.all || document.getElementById){

				f[w[0]].style.background = errorClr;

			}

			f[w[0]].focus();

			return (false);

		}





	} else if(w[3] == "Select"){

		if(f[w[0]].selectedIndex < 1){

			alert("Whoops, you missed field: " + w[4]);

			if(document.all || document.getElementById){

				f[w[0]].style.background = errorClr;

			}

			f[w[0]].focus();

			return (false);

		}

	} else if(w[3] == "Email"){

		if(e){

			if(!checke(f[w[0]].value) && f[w[0]].value.length > 0){

				alert("Whoops, please enter a valid e-mail address."); 

				if(document.all || document.getElementById){

					f[w[0]].style.background = errorClr;

				}

				f[w[0]].focus();

				return (false);

			}

		} else {

			if(!checke(f[w[0]].value)){

				alert("Whoops, please enter a valid e-mail address."); 

				if(document.all || document.getElementById){

					f[w[0]].style.background = errorClr;

				}

				f[w[0]].focus();

				return (false);

			}

		}

	} else if(w[3] == "Radio"){

		isRad = 0;

		for(r = 0; r < f[w[0]].length; r++){

			if(f[w[0]][r].checked){

				isRad++;

			}

		}

		if(!isRad){

			alert("Whoops, you missed field: " + w[4]);

			//if(document.all || document.getElementById){

				//f[w[0]][0].style.background = errorClr;

			//}

			f[w[0]][0].focus();

			return (false);

		}

	}

	return true;

}





//Additional Features

function check_Additional_Service(f){



    //           field name,  ucfirst, min length, type, label

    REQSmeAdd = new Array();

    REQSmeAdd[0]  = ["name",	 0, 1, "Text",   "Name"];



	for(R = 0; R < REQSmeAdd.length; R++){

		if(!checkField(f,REQSmeAdd[R])){

			return false;

		}

	}

	

	if (f.phone.value) {

		REQSmeAdd[1]  = ["phone", 0, 1, "Text",   "Phone"];

		REQSmeAdd[2]  = ["email", 0, 0, "Text",   "Email"];

		checkField(f,REQSmeAdd[2]);

		if(!checkField(f,REQSmeAdd[1])){

			return false;

		}

	} 



	if (f.email.value) {

		REQSmeAdd[1]  = ["email", 0, 1, "Email",   "Email"];

		REQSmeAdd[2]  = ["phone", 0, 0, "Text",   "Phone"];

		checkField(f,REQSmeAdd[2]);

		if(!checkField(f,REQSmeAdd[1])){

			return false;

		}

	} 



	if ((!f.email.value) && (!f.phone.value)) {

		alert("Please enter an email address or phone number.");

		return false;

	} 





    flag = false;

	for(R = 1; R <= f.number_items.value; R++){

		name = "checked"+R;

		if(f[name].checked){

			flag = true;

		}

	}



	if(!flag) {

		alert("Please check one of the options available.");

		return false;		

	} 





	

	//alert("It worked");

    //return false;

    return true;

}











// payment promo add/edit



function check_PromoAddEdit(f){



    REQSpae = new Array();

    //           field name,      ucfirst, min length, type, label

    REQSpae[0]  = ["promo_name",             0, 1, "Text",   "Promo Name"];

    REQSpae[1]  = ["style",             	 0, 0, "Radio",   "Early Bird/Promotional Toggle"];

    REQSpae[2]  = ["promo_name",             0, 1, "Text",   "Promo Name"];//Place holder

    REQSpae[3]  = ["promo_name",             0, 1, "Text",   "Promo Name"];//Place holder





    if (f.style[0].checked == true) {

       REQSpae[2]  = ["daysbefore",        	 0, 1, "Number",   "Number of days to stop "];

       REQSpae[3]  = ["promocode",        	 0, 0, "Text",   "Promo Code"];//Just to clear highlight

    }

    if (f.style[1].checked == true) {

       REQSpae[2]  = ["promocode",        	 0, 3, "Text",   "Promo Code"];

       REQSpae[3]  = ["daysbefore",        	 0, 0, "Text",   "Number of days to stop "];//Just to clear highlight

    }

    REQSpae[4]  = ["amount",         		 0, 1, "Number",   "Discount Amount"];







	for(R = 0; R < REQSpae.length; R++){

		if(!checkField(f,REQSpae[R])){

			return false;

		}

	}

		

	//check based on radio selection



	

	// don't submit form

	//alert("All ok!");

	//return false;

	return true;

}











// member sign up reqs

REQSms = new Array(); 

count = 0;

//           field name,  ucfirst, min length, type, label

REQSms[count]  = ["mbr_firstname",    2, 1, "Text",   "First Name"]; count = count + 1;

REQSms[count]  = ["mbr_lastname",     2, 1, "Text",   "Last Name"]; count = count + 1;

//REQSms[count]  = ["mbr_companyname",  1, 0, "Text",   "Company Name"]; count = count + 1;

//REQSms[count]  = ["mbr_companytype",  1, 0, "Text",   "Type of Business"]; count = count + 1;

REQSms[count]  = ["mbr_address1",     3, 1, "Text",   "Address 1"]; count = count + 1;

//REQSms[count]  = ["mbr_address2",     3, 0, "Text",   "Address 2"]; count = count + 1;

REQSms[count]  = ["mbr_city",         3, 1, "Text",   "City"]; count = count + 1;

REQSms[count]  = ["mbr_state",        0, 1, "Select", "State"]; count = count + 1;

REQSms[count]  = ["mbr_zip",          0, 2, "Text",   "Zip Code"]; count = count + 1;

//REQSms[count]  = ["mbr_country",      0, 1, "Select", "Country"]; count = count + 1;

REQSms[count] = ["country_code",     0, 1, "Text",   "Country Code"]; count = count + 1;

REQSms[count] = ["area_code",        0, 1, "Text",   "Area Code"]; count = count + 1;

REQSms[count] = ["mbr_phone",        0, 3, "Text",   "Phone"]; count = count + 1;

REQSms[count] = ["mbr_email",        0, 5, "Email",  "E-mail Address"]; count = count + 1;

REQSms[count] = ["mbr_email_conf",   0, 5, "Email",  "E-mail Address Confirmation"]; count = count + 1;

if(inEdit){ 

	//REQSms[count] = ["mbr_pwd",          0, 0, "Text",   "Password"]; count = count + 1;

	REQSms[count] = ["mbr_pref_contact", 0, 1, "Radio",  "Contact me by"]; count = count + 1;

} else {

	REQSms[count] = ["mbr_pwd",          0, 3, "Text",   "Password"]; count = count + 1;

	REQSms[count] = ["mbr_pwd_conf",     0, 0, "Text",   "Password Confirmation"]; count = count + 1;

	REQSms[count] = ["mbr_pref_contact", 0, 0, "Radio",  "Contact me by"]; count = count + 1;

}



function check_ms(f){

	for(R = 0; R < REQSms.length; R++){

		if(!checkField(f,REQSms[R])){

			return false;

		}

	}

	if(!checkZip(f.mbr_zip)){

		return false;

	}

	

	// check confirmation fields

	if(!matchFields(f.mbr_email,f.mbr_email_conf)){

		return false;

	}

	if(!matchFields(f.mbr_pwd,f.mbr_pwd_conf)){

		return false;

	}

	// no illegal chars in passwords

	if(!illChars(f.mbr_pwd,f.mbr_pwd_conf)){

		return false;

	}

	

	// don't submit form

	//alert("All ok!");

	//return false;

	return true;

}







// step 1 reqs

function check_Step1(f){

REQS1 = new Array();

//           field name,  ucfirst, min length, type, label

i=0;

REQS1[i]  = ["event_name",             3, 1, "Text",   "Event Name"]; i++;
REQS1[i]  = ["event_id",               0, 1, "Text",   "Event ID"]; i++;

if (f.use_admin.checked == false) {

	REQS1[i]  = ["event_CP_fname",         3, 1, "Text",   "Contact First Name"]; i++;
	REQS1[i]  = ["event_CP_lname",         3, 1, "Text",   "Contact Last Name"]; i++;
	//REQS1[i]  = ["event_CP_addr1",         3, 1, "Text",   "Contact Address 1"]; i++;
	//REQS1[i]  = ["event_CP_city",          3, 1, "Text",   "Contact City"]; i++;
	//REQS1[i]  = ["event_CP_state",         0, 1, "Select", "Contact State"]; i++;
	//REQS1[i]  = ["event_CP_zip",           0, 2, "Text",   "Contact Zip"]; i++;
	//REQS1[i]  = ["event_CP_phone_a_code", 0, 1, "Text",   "Contact Phone Area Code"]; i++;
	//REQS1[i] = ["event_CP_phone",         0, 3, "Text",   "Contact Phone"]; i++;
	REQS1[i] = ["event_CP_email",         0, 5, "Email",  "Contact E-mail"]; i++;
	REQS1[i] = ["event_CP_email_compare", 0, 5, "Email",  "Contact E-mail comparison"]; i++;

	// check confirmation fields
    if (typeof(f.event_CP_email) != "undefined") {
	  if(!matchFields(f.event_CP_email,f.event_CP_email_compare)){
		return false;
	  }
    }
}


REQS1[i] = ["event_Admin_fname", 0, 2, "Text",  "Admin Contact First Name"]; i++;
REQS1[i] = ["event_Admin_lname", 0, 2, "Text",  "Admin Contact Last Name"]; i++;
REQS1[i] = ["event_Admin_addr1", 0, 2, "Text",  "Admin Contact Address"]; i++;
REQS1[i] = ["event_Admin_city", 0, 2, "Text",  "Admin Contact City"]; i++;

if (f.event_Admin_state.value == '') {
   REQS1[i] = ["if_other_contact_state_admin", 0, 2, "Text",  "Other Admin Contact State"]; i++;
}

REQS1[i] = ["event_Admin_zip", 0, 2, "Text",  "Admin Contact Zip"]; i++;
REQS1[i] = ["event_Admin_country", 0, 1, "Text",  "Admin Contact Country"]; i++;
REQS1[i] = ["event_Admin_phone_a_code", 0, 2, "Text",  "Admin Contact Phone Area Code"]; i++;
REQS1[i] = ["event_Admin_phone", 0, 2, "Text",  "Admin Contact Phone"]; i++;
REQS1[i] = ["event_Admin_email", 0, 2, "Email",  "Admin Contact E-mail"]; i++;
REQS1[i] = ["event_Admin_email_compare", 0, 2, "Email",  "Admin Contact E-mail comparison"]; i++;


if (!inEdit) {
   REQS1[i] = ["event_CP_pwd",           0, 3, "Text",   "Admin Password"]; i++;
   REQS1[i] = ["event_CP_pwd_confirm",   0, 3, "Text",   "Admin Password Comparison"]; i++;
}



	for(R = 0; R < REQS1.length; R++){
      if (typeof(f[REQS1[R][0]]) != "undefined") {
  	     if(!checkField(f,REQS1[R])){
	 	     return false;
	     }
      }
    }

	// check confirmation fields
    if (typeof(f.event_Admin_email) != "undefined") {
	  if(!matchFields(f.event_Admin_email,f.event_Admin_email_compare)){
		return false;
	  }
    }

	
    if (typeof(f[REQS1[1][0]]) != "undefined") {
  	  if(!checkEventID(f)){
		return false;
      }
    }

	
    if (typeof(f[REQS1[1][0]]) != "undefined") {
	  if(!noSpace(f.event_id)){
	 	return false;
 	  }
    }
	

	//if(!checkZip(f.event_CP_zip)){

	//	return false;

	//}

	




    if (!inEdit) {
      if (typeof(f[REQS1[6][0]]) != "undefined") {
    	  if(!matchFields(f.event_CP_pwd,f.event_CP_pwd_confirm)){
  	    	return false;
          } 
	  }

	  // no illegal chars in passwords
      if (typeof(f[REQS1[6][0]]) != "undefined") {
 	    if(!illChars(f.event_CP_pwd,f.event_CP_pwd_confirm)){
	  	  return false;
	    }
      }
    }

	

	// don't submit form
	//alert("All ok!");
	//return false;
	return true;
}



// step 2 reqs

function check_Step2(f){
	REQS2 = new Array();
	//           field name,  ucfirst, min length, type, label
	REQS2[0]  = ["event_month_start",      0, 1, "Select", "Event Start Month"];
	REQS2[1]  = ["event_day_start",        0, 1, "Select", "Event Start Day"];
	REQS2[2]  = ["event_year_start",       0, 1, "Select", "Event Start Year"];
	REQS2[3]  = ["event_month_end",        0, 1, "Select", "Event End Month"];
	REQS2[4]  = ["event_day_end",          0, 1, "Select", "Event End Day"];
	REQS2[5]  = ["event_year_end",         0, 1, "Select", "Event End Year"];
	REQS2[6]  = ["event_hour_start",       0, 1, "Select", "Event Start Hour"];
	REQS2[7]  = ["event_minute_start",     0, 1, "Select", "Event Start Minute"];
	REQS2[8]  = ["event_hour_end",         0, 1, "Select", "Event End Hour"];
	REQS2[9] = ["event_minute_end",       0, 1, "Select", "Event End Minute"];
	REQS2[10] = ["venue_name",             3, 1, "Text",   "Venue Name"];
	REQS2[11] = ["venue_addr1",            3, 1, "Text",   "Venue Address 1"];
	REQS2[12] = ["venue_city",             3, 1, "Text",   "Venue City"];
    if (typeof(f.if_other_venue_state) != "undefined") {
	  if (f.if_other_venue_state.value != "") {
		REQS2[13] = ["if_other_venue_state",   0, 1, "Text", "Venue State"];
	  } else {
		REQS2[13] = ["venue_state",            0, 1, "Select", "Venue State"];
      }
    } else {
		REQS2[13] = ["",            0, 1, "Select", "Venue State"];
    }
	REQS2[14] = ["venue_zip",              0, 2, "Text",   "Venue Zip"];
	REQS2[15] = ["venue_phone_a_code",     0, 1, "Text",   "Venue Phone Area Code"];
	REQS2[16] = ["venue_phone",            0, 3, "Text",   "Venue Phone"];
	//REQS2[17] = ["send_email_addr",        0, 5, "Email",  "RSVP Notification Email"];
	//REQS2[18] = ["confirm_email_addr",     0, 5, "Email",  "RSVP Notification Email comparison"];




	// check for leap years

	YEAR = new Date();

	YEAR = YEAR.getYear();

	

	DATES = new Array(); // + 1 for all because of first option

	if(YEAR % 4 == 0){

		DATES[0] = [2 , 29];

	} else {

		DATES[0] = [2 , 28];

	}

	DATES[1] = [4 , 30];

	DATES[2] = [6 , 30];

	DATES[3] = [9 , 30];

	DATES[4] = [11, 30];

    if (typeof(f.event_month_start) != "undefined") {
	for(D = 0; D < DATES.length; D++){

		if(f.event_month_start.selectedIndex == DATES[D][0]){

			if(f.event_day_start.selectedIndex > DATES[D][1]){

				alert("Whoops, you have entered an invalid start date");

				if(document.all || document.getElementById){

					f.event_day_start.style.background = errorClr;

				}

				f.event_day_start.focus();

				return (false);

			}

		}

		if(f.event_month_end.selectedIndex == DATES[D][0]){

			if(f.event_day_end.selectedIndex > DATES[D][1]){

				alert("Whoops, you have entered an invalid end date");

				if(document.all || document.getElementById){

					f.event_day_end.style.background = errorClr;

				}

				f.event_day_end.focus();

				return (false);

			}

		}

	}
    }
	

	for(R = 0; R < REQS2.length; R++){
      if (typeof(f[REQS2[R][0]]) != "undefined") {
		if(!checkField(f,REQS2[R],1)){

			return false;

		}
      }
	}


    if (typeof(f.event_id) != "undefined") {
	  if(!noSpace(f.event_id)){
		return false;
 	  }
    }


    if (typeof(f.venue_zip) != "undefined") {
	  if(!checkZip(f.venue_zip)){
		return false;
  	  }  
    }



	// check event start end date
    if (typeof(f.event_ampm_start) != "undefined") {
  	  shour = f.event_ampm_start.selectedIndex == 1 ? 
	  f.event_hour_start.selectedIndex + 12 : f.event_hour_start.selectedIndex;
	  if(f.event_hour_start.selectedIndex == 12){
		shour -=12
	  }
	  ehour = f.event_ampm_end.selectedIndex == 1 ? 

	  f.event_hour_end.selectedIndex + 12 : f.event_hour_end.selectedIndex;

	  if(f.event_hour_end.selectedIndex == 12){
		ehour -=12
	  }
    }

    if (typeof(f.event_month_start) != "undefined") {

      if (typeof(f.event_ampm_start) != "undefined") {
  	    sdate = Date.UTC(f.event_year_start.options[f.event_year_start.selectedIndex].value, f.event_month_start.selectedIndex - 1, f.event_day_start.selectedIndex, shour, f.event_minute_start.selectedIndex - 1, 0);
	    edate = Date.UTC(f.event_year_end.options[f.event_year_end.selectedIndex].value, f.event_month_end.selectedIndex - 1, f.event_day_end.selectedIndex, ehour, f.event_minute_end.selectedIndex - 1, 0);
	  } else {
  	    sdate = Date.UTC(f.event_year_start.options[f.event_year_start.selectedIndex].value, f.event_month_start.selectedIndex - 1, f.event_day_start.selectedIndex, 0, 0, 0);
	    edate = Date.UTC(f.event_year_end.options[f.event_year_end.selectedIndex].value, f.event_month_end.selectedIndex - 1, f.event_day_end.selectedIndex, 0, 0, 0);
	  } 

      if(sdate > edate){
		alert("Whoops, Event's Start Time/Date comes after Event's End Time/Date"); 
		if(document.all || document.getElementById){
			f.event_month_start.style.background = errorClr;
			f.event_month_end.style.background = errorClr;
		}
		f.event_month_start.focus();
		return (false);
	  }
	}
	
	// max guests
    if (typeof(f.max_reggies) != "undefined") {
  	  if(f.max_guests[1].checked){
		f.max_reggies.value = f.max_reggies.value.replace(/\D+/, "");
		if(f.max_reggies.value < 1){
			alert("Whoops, Please enter maximum number of guests or set to 'None' to disable notification"); 
			f.max_reggies.focus();
			return (false);
		}
	  }

	
      // reg notif
      if (typeof(f.notify_CP) != "undefined") {
  	    if(f.notify_CP[1].checked){
		  if(!checke(f.send_email_addr.value)){
			  alert("Whoops, please enter a valid e-mail address."); 
			  if(document.all || document.getElementById){
				f.send_email_addr.style.background = errorClr;
			  }
			  f.send_email_addr.focus();
			  return (false);
		  }
	 	  if(!matchFields(f.send_email_addr,f.confirm_email_addr)){
			return false;
  		  }
	    }
	  }
    }

	// don't submit form
	//alert("All ok!");
	//return false;
	return true;
}





// step 3 reqs

REQS3 = new Array();

//           field name,  ucfirst, min length, type, label

REQS3[0]  = ["payment_cardtype",      0, 1,  "Select", "Credit Card Type"];

REQS3[1]  = ["payment_cardnum",       0, 5, "Text",   "Credit Card Number"];

REQS3[2]  = ["payment_cardexp-mon",   0, 1,  "Select", "Expiration Month"];

REQS3[3]  = ["payment_cardexp-yr",    0, 1,  "Select", "Expiration Year"];

REQS3[4]  = ["payment_cardname",      3, 3,  "Text",   "Name of Credit Card"];

REQS3[5]  = ["cvv",      0, 3,  "Text",   "Credit Card CSV Code"];  //name was:payment_csv_code



function check_Step3(f){

//	if (cinfo) {

//		return true;

//	}



	if (!(f.payment_cardnum)) {//if fields dont exist, all are true to escape

		return true;

	}



	// remove spaces

	if(document.images){

		f.payment_cardnum.value = f.payment_cardnum.value.replace(/\s+/, "");

	}

	// check for invalid chars

	if(document.images && f.payment_cardnum.value.match(/\D+/)){

		alert("Whoops, invalid character found in Credit Card Number");

		if(document.all || document.getElementById){

			f.payment_cardnum.style.background = errorClr;

		}

		f.payment_cardnum.focus();

		return (false);

	}

	

	// check valid card

	if(f.payment_cardnum.value != '12345')

	if(!isAnyCard(f.payment_cardnum.value)){

	// check length

	//if(f.payment_cardnum.value.length > 16){

		alert("Whoops, Credit Card Number is not valid");

		if(document.all || document.getElementById){

			f.payment_cardnum.style.background = errorClr;

		}

		f.payment_cardnum.focus();

		return (false);

	}

	

	for(R = 0; R < REQS3.length; R++){

		if(!checkField(f,REQS3[R])){

			return false;

		}

	}

	

	// check expiration

	dObj = new Date();

	YEAR = dObj.getYear();

	MON  = dObj.getMonth();

	

	if(f[REQS3[3][0]].options[f[REQS3[3][0]].selectedIndex].value <= YEAR && f[REQS3[2][0]].options[f[REQS3[2][0]].selectedIndex].value < MON){

		alert("Whoops, your card has expired");

		if(document.all || document.getElementById){

			f[REQS3[2][0]].style.background = errorClr;

		}

		f[REQS3[2][0]].focus();

		return (false);

	}

	

	// don't submit form

	//alert("All ok!");

	//return false;

	return true;

}



// member master event

REQSme = new Array();

//           field name,  ucfirst, min length, type, label

REQSme[0]  = ["guest_name",           2, 1, "Text",   "First and Last Name"];

REQSme[1]  = ["guest__addr1",         2, 1, "Text",   "Address 1"];

REQSme[2]  = ["guest__addr2",         3, 0, "Text",   "Address 2"];

REQSme[3]  = ["guest__city",          3, 1, "Text",   "City"];

REQSme[4]  = ["guest__state",         3, 1, "Select", "State"];

REQSme[5]  = ["guest__zip",           3, 2, "Text",   "Zip"];

REQSme[6]  = ["guest__country",       3, 1, "Select", "Country"];

REQSme[7]  = ["guest__phone",         0, 5, "Text",   "Phone"];

REQSme[8]  = ["guest__email",         0, 5, "Email",   "E-mail"];

REQSme[9]  = ["guest__email_compare", 0, 5, "Email",   "E-mail comparison"];



function check_me(f){

	for(R = 0; R < REQSme.length; R++){

		if(!checkField(f,REQSme[R])){

			return false;

		}

	}

	if(!checkZip(f.guest__zip)){

		return false;

	}



	// check confirmation fields

	if(!matchFields(f.guest__email,f.guest__email_compare)){

		return false;

	}

	return true;

}



REQSmeReg = new Array();

//           field name,  ucfirst, min length, type, label

REQSmeReg[0]  = ["guest_fname",          2, 1, "Text",   "First Name"];

REQSmeReg[1]  = ["guest_lname",          2, 1, "Text",   "Last Name"];

REQSmeReg[2]  = ["guest_email",          0, 5, "Email",  "E-mail"];

REQSmeReg[3]  = ["guest_email_compare",  0, 5, "Email",  "E-mail comparison"];



function check_meReg(f){

	for(R = 0; R < REQSmeReg.length; R++){

		if(!checkField(f,REQSmeReg[R])){

			return false;

		}

	}

	// check confirmation fields

	if(!matchFields(f.guest_email,f.guest_email_compare)){

		return false;

	}

	return true;

}







