﻿function tktSet(f) {
    var t0;
    var t;
    for (var i=0; i<f.elements.length;i++) {
        if ("text" == f.elements[i].type) {
            t0 = document.getElementById('tkt0').value;
            a=f.elements[i].value;
            if (a==''){a=0}
            b=f.elements[i+1].value;
            t = b + a + ',';
            document.getElementById('tkt0').value = t0 + t;
        }
    }
}

function tktCheck(field)
{

	var agt=navigator.userAgent.toLowerCase();
	var is_ie   = (agt.indexOf("msie") != -1);
	
	if (!is_ie){
		var temp = field.value.replace(/[^0-9]/g, "");	
		field.value = temp.substring(0,4);
		return true;
	}
	else {
		if (window.event.keyCode != 9 && window.event.keyCode != 16){
			var temp = field.value.replace(/[^0-9]/g, "");			
			field.value = temp.substring(0,4);
			return true;
		}
	}
}

function valSelect(f) {
    var good=false;
    for (var i=0; i<f.elements.length;i++) {
        if ("select-one" == f.elements[i].type) {
            if (f.elements[i].selectedIndex > 0) {
                good = true
            }
        }
    }
    if (good == false) {
        alert('Please make a ticket selection');
        return false;
        }
    else {
        return true;
    }
}

function valText(f) {
    var good=false;
    for (var i=0; i<f.elements.length;i++) {
        if ("text" == f.elements[i].type) {
            if (f.elements[i].value > 0) {
                good = true
            }
        }
    }
    if (good == false) {
        alert('Please make a ticket selection');
        return false;
        }
    else {
        tktSet(f);
        return true;
    }
}

	function formatPhoneUS(field,objEvent)
	{
		var agt=navigator.userAgent.toLowerCase();
		var is_ie   = (agt.indexOf("msie") != -1);
		var iKeyCode, strKey;

		if (is_ie) {
		iKeyCode = objEvent.keyCode;
		} else {
		iKeyCode = objEvent.which;
		}
			if (iKeyCode == 36 || iKeyCode == 17 || iKeyCode == 18 || iKeyCode == 93) {
				field.value = field.value.substring(0,field.value.length-1);
			}

		if (!is_ie){
			if (iKeyCode != 9 && iKeyCode != 16 && iKeyCode != 8 && iKeyCode != 37){
				var temp = field.value.replace(/[^0-9]/g, "");
				var cursor = temp.length;

				temp = temp.replace(/^(\d{0,3})(\d{0,3})(\d{0,4})(\d*)/, "($1)$2-$3 x $4");

				if (cursor < 11)
						temp = temp.replace(/\s*x\s*$/, "");
				if (cursor < 7)
						temp = temp.replace(/\-\s*$/, "");
				if (cursor < 3)
						temp = temp.replace(/\)\s*$/, "");
				if (! cursor)
						temp = "";
				if (temp.length > 13)
						temp = temp.substring(0,13);
				if (temp == '(000)000-0000' || temp == '(111)111-1111' || temp == '(222)222-2222' || temp == '(333)333-3333' || temp == '(444)444-4444' || temp == '(555)555-5555' || temp == '(666)666-6666' || temp == '(777)777-7777' || temp == '(888)888-8888' || temp == '(999)999-9999'){
				alert(temp + ' is not a valid telephone number');
				temp = '';
			}
			field.value = temp;
			return true;
		}
		}
		else {
			if (iKeyCode != 9 && iKeyCode != 16 && iKeyCode != 8 && iKeyCode != 37){
				var temp = field.value.replace(/[^0-9]/g, "");
				var cursor = temp.length;

				temp = temp.replace(/^(\d{0,3})(\d{0,3})(\d{0,4})(\d*)/, "($1)$2-$3 x $4");

				if (cursor < 11)
						temp = temp.replace(/\s*x\s*$/, "");
				if (cursor < 7)
						temp = temp.replace(/\-\s*$/, "");
				if (cursor < 3)
						temp = temp.replace(/\)\s*$/, "");
				if (! cursor)
						temp = "";
				if (temp.length > 13)
						temp = temp.substring(0,13);

				if (temp == '(000)000-0000' || temp == '(111)111-1111' || temp == '(222)222-2222' || temp == '(333)333-3333' || temp == '(444)444-4444' || temp == '(555)555-5555' || temp == '(666)666-6666' || temp == '(777)777-7777' || temp == '(888)888-8888' || temp == '(999)999-9999'){
				alert(temp + ' is not a valid telephone number');
				temp = '';
				}
				field.value = temp;
				return true;
			}
		}
	}

		function formatZipUS(field,objEvent)
		{
			var agt=navigator.userAgent.toLowerCase();
			var is_ie   = (agt.indexOf("msie") != -1);
			var iKeyCode, strKey;

			if (is_ie) {
			iKeyCode = objEvent.keyCode;
			} else {
			iKeyCode = objEvent.which;
			}

			if (iKeyCode == 36 || iKeyCode == 17 || iKeyCode == 18 || iKeyCode == 93) {
				field.value = field.value.substring(0,field.value.length-1);
			}
			
			if (is_ie){
				if (objEvent != 9 && objEvent != 16){
					var temp = field.value.replace(/[^0-9]/g, "");
					var cursor = temp.length;

					temp = temp.replace(/^(\d{0,5})(\d*)/, "$1-$2");

					if (cursor < 6)
							temp = temp.replace(/\-\s*$/, "");
					if (! cursor)
							temp = "";

					if (temp.length > 5)
							temp = temp.substring(0,5);

					field.value = temp;
					return true;
				}
			}
			else {
				var temp = field.value.replace(/[^0-9]/g, "");
				var cursor = temp.length;

				temp = temp.replace(/^(\d{0,5})(\d*)/, "$1-$2");

				if (cursor < 6)
						temp = temp.replace(/\-\s*$/, "");
				if (! cursor)
						temp = "";

				if (temp.length > 5)
						temp = temp.substring(0,5);

				field.value = temp;
				return true;
			}
		}
		function isEmail(string) {
			if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
				return false;
			else
				return true;
		}
			function stateCheck(field)
			{
			
				var agt=navigator.userAgent.toLowerCase();
				var is_ie   = (agt.indexOf("msie") != -1);
				
				if (!is_ie){
					var temp = field.value.replace(/[^A-Za-z]/g, "");	
					    var x = temp.toUpperCase();
					field.value = x.substring(0,2);
					return true;
				}
				else {
					if (window.event.keyCode != 9 && window.event.keyCode != 16){
						var temp = field.value.replace(/[^A-Za-z]/g, "");			
					    var x = temp.toUpperCase();
						field.value = x.substring(0,2);
						return true;
					}
				}
			}
			function noNumber(field)
			{
			
				var agt=navigator.userAgent.toLowerCase();
				var is_ie   = (agt.indexOf("msie") != -1);
				
				if (!is_ie){
					var temp = field.value.replace(/[^A-Z a-z]/g, "");	
					field.value = temp;
					return true;
				}
				else {
					if (window.event.keyCode != 9 && window.event.keyCode != 16){
						var temp = field.value.replace(/[^A-Z a-z]/g, "");			
						field.value = temp;
						return true;
					}
				}
			}

			function ccCheck(field)
			{
			
				var agt=navigator.userAgent.toLowerCase();
				var is_ie   = (agt.indexOf("msie") != -1);
				
				if (!is_ie){
					var temp = field.value.replace(/[^0-9]/g, "");	
					field.value = temp.substring(0,16);
					return true;
				}
				else {
					if (window.event.keyCode != 9 && window.event.keyCode != 16){
						var temp = field.value.replace(/[^0-9]/g, "");			
						field.value = temp.substring(0,16);
						return true;
					}
				}
			}

			function expiryCheck(field)
			{
			
				var agt=navigator.userAgent.toLowerCase();
				var is_ie   = (agt.indexOf("msie") != -1);
				
				if (!is_ie){
					var temp = field.value.replace(/[^0-9]/g, "");	
					field.value = temp.substring(0,4);
					return true;
				}
				else {
					if (window.event.keyCode != 9 && window.event.keyCode != 16){
						var temp = field.value.replace(/[^0-9]/g, "");			
						field.value = temp.substring(0,4);
						return true;
					}
				}
			}

			function cvvCheck(field)
			{
			
				var agt=navigator.userAgent.toLowerCase();
				var is_ie   = (agt.indexOf("msie") != -1);
				
				if (!is_ie){
					var temp = field.value.replace(/[^0-9]/g, "");	
					field.value = temp.substring(0,4);
					return true;
				}
				else {
					if (window.event.keyCode != 9 && window.event.keyCode != 16){
						var temp = field.value.replace(/[^0-9]/g, "");			
						field.value = temp.substring(0,4);
						return true;
					}
				}
			}

			function moneyCheck(field)
			{
			
				var agt=navigator.userAgent.toLowerCase();
				var is_ie   = (agt.indexOf("msie") != -1);
				
				if (!is_ie){
					var temp = field.value.replace(/[^0-9]/g, "");	
					field.value = temp;
					return true;
				}
				else {
					if (window.event.keyCode != 9 && window.event.keyCode != 16){
						var temp = field.value.replace(/[^0-9]/g, "");			
						field.value = temp;
						return true;
					}
				}
			}

function showbtn(id) {
            var id1='pending';
            if (document.getElementById) { // DOM3 = IE5, NS6
                        if (document.getElementById(id).style.display == "none"){
                                    document.getElementById(id).style.display = 'block';
                                    document.getElementById(id1).style.display = 'none';
                        } else {
                                    document.getElementById(id).style.display = 'none';
                                    document.getElementById(id1).style.display = 'block';
                        }
            } else {
                        if (document.layers) {
                                    if (document.id.display == "none"){
                                                document.id.display = 'block';
                                                document.id1.display = 'none';
                                    } else {
                                                document.id.display = 'none';
                                                document.id1.display = 'block';
                                    }
                        } else {
                                    if (document.all.id.style.visibility == "none"){
                                                document.all.id.style.display = 'block';
                                                document.all.id1.style.display = 'none';
                                    } else {
                                                document.all.id1.style.display = 'none';
                                                document.all.id1.style.display = 'block';
                                    }
                        }
            }
}

function validateCCbilling(what) {
      if (what.payTypeCC.checked){
                if (what.strBillName.value.length < 1){
				alert('Please enter the cardholder name.');
				what.strBillName.focus();
				return false
			}
    			   else if (isValidCreditCardNumber(what.strBillCC.value,what) == false){
				    alert('Credit Card number is invalid.  Please check and reenter.');
				    what.strBillCC.focus();
				    return false;
			    }
			    else if (what.strBillExpiry.value.length < 4){
				    alert('Please enter the expiration date in the format MMYY.');
				    what.strBillExpiry.focus();
				    return false
			    }
			    else if (what.strBillCVV.value.length < 3){
				    alert('Please enter the CVV number from the back of the card.');
				    what.strBillCVV.focus();
				    return false
			        }
			    else if (what.strBillAddy.value.length < 3){
				    alert('Please enter the billing address.');
				    what.strBillAddy.focus();
				    return false
			    }
			    else if (what.strBillCity.value.length < 2){
				    alert('Please enter the billing city.');
				    what.strBillCity.focus();
				    return false
			    }
    else if (what.strBillState.selectedIndex ==0 && what.strBillCountry.selectedIndex ==220){
				alert('Please select a state');
				what.strBillState.focus();
				return false
			}
    else if (what.strBillState.selectedIndex ==0 && what.strBillCountry.selectedIndex ==39){
				alert('Please select a province');
				what.strBillState.focus();
				return false
			}
    else if (what.strBillZip.value.length < 1 && what.strBillCountry.selectedIndex ==220){
				alert('Please enter a zip code.');
				what.strBillZip.focus();
				return false
			}
    else if (what.strBillZip.value.length < 1 && what.strBillCountry.selectedIndex ==39){
				alert('Please enter a postal code.');
				what.strBillZip.focus();
				return false
			}
			else if (isEmail(what.strBillEmail.value)){
				alert('Please enter an email address to receive your receipt.');
				what.strBillEmail.focus();
				return false
			}
            else return true }
      else if (what.payTypeCK.checked){
            if (isEmail(what.strBillEmail.value)){
				alert('Please enter an email address to receive your confirmation.');
				what.strBillEmail.focus();
				return false
			}
            else return true
      }
      else return true
}

function okTerms(cb,what,pp) {
    var qq = (what.elements[pp + 'acceptIt'].value) * 1;
    if (cb.checked){
        what.elements[pp + 'acceptIt'].value = qq - 1;
    }
    else {
        what.elements[pp + 'acceptIt'].value = qq + 1;
    }
}

function copyAddy(cb,what,pp) {
    if (cb.checked){
        what.elements[pp + 'strBillAddy'].value = what.elements[pp + 'strDAddy'].value;
        what.elements[pp + 'strBillCity'].value = what.elements[pp + 'strDCity'].value;
        what.elements[pp + 'strBillCountry'].selectedIndex = what.elements[pp + 'strDCountry'].selectedIndex;
        what.elements[pp + 'strBillState'].selectedIndex = what.elements[pp + 'strDState'].selectedIndex;
        what.elements[pp + 'strBillZip'].value = what.elements[pp + 'strDZip'].value;
    }
    else {
        what.elements[pp + 'strBillAddy'].value = '';
        what.elements[pp + 'strBillCity'].value = '';
        what.elements[pp + 'strBillCountry'].selectedIndex = 220;
        what.elements[pp + 'strBillState'].selectedIndex = 0;
        what.elements[pp + 'strBillZip'].value = '';
    }
}

function validateEvent(what,pp,min) {
   var amtclean = what.elements[pp + 'strDAmount'].value;
   what.elements[pp + 'strDAmount'].value = amtclean.replace(/[^0-9\.]/g, "");
    if (what.terms) {
        if (what.elements[pp + 'acceptIt'].value != 0){
			    alert('You must read and accept the terms before registering.');
			    return false
        }
    }
    if (what.elements[pp + 'strDName'].value.length < 1){
				alert('Please enter the your name.');
				what.elements[pp + 'strDName'].focus();
				return false
			}
    if (what.elements[pp + 'strDPName']){
        if (what.elements[pp + 'strDPName'].value.length < 1){
				alert('Please enter the your parent/guardian name.');
				what.elements[pp + 'strDPName'].focus();
				return false
		}
			}
    if (what.elements[pp + 'strDAddy'].value.length < 1){
				alert('Please enter the your address.');
				what.elements[pp + 'strDAddy'].focus();
				return false
			}
    else if (what.elements[pp + 'strDCity'].value.length < 1){
				alert('Please enter the your city.');
				what.elements[pp + 'strDCity'].focus();
				return false
			}
    else if (what.elements[pp + 'strDState'].selectedIndex == 0 && what.elements[pp + 'strDCountry'].selectedIndex == 220){
				alert('Please select your state.');
				what.elements[pp + 'strDState'].focus();
				return false
			}
    else if (what.elements[pp + 'strDState'].selectedIndex == 0 && what.elements[pp + 'strDCountry'].selectedIndex == 39){
				alert('Please select your province.');
				what.elements[pp + 'strDState'].focus();
				return false
			}
    else if (what.elements[pp + 'strDZip'].value.length < 1 && what.elements[pp + 'strDCountry'].selectedIndex == 220){
				alert('Please enter the your zip code.');
				what.elements[pp + 'strDZip'].focus();
				return false
			}
    else if (what.elements[pp + 'strDZip'].value.length < 1 && what.elements[pp + 'strDCountry'].selectedIndex == 39){
				alert('Please enter the your postal code.');
				what.elements[pp + 'strDZip'].focus();
				return false
			}
    else if (isEmail(what.elements[pp + 'strDEmail'].value)){
				alert('Please enter the your email.');
				what.elements[pp + 'strDEmail'].focus();
				return false
			}
    else if (what.elements[pp + 'strDAmount'].value < min){
				alert('Registration requires you select a program and submit a minimum payment of $' + min + '.');
				what.elements[pp + 'strDAmount'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillName'].value.length < 1){
				alert('Please enter the name as it appears on the credit card.');
				what.elements[pp + 'strBillName'].focus();
				return false
			}
    else if (!isValidCreditCardNumber(what.elements[pp + 'strBillCC'].value)){
				alert('Please enter a valid credit card number.');
				what.elements[pp + 'strBillCC'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillExpiry'].value.length < 4){
				alert('Please enter the expiration date as MMYY.');
				what.elements[pp + 'strBillExpiry'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillCVV'].value.length < 3){
				alert('Please enter the 3 or 4 digit verification code on the back of your card.');
				what.elements[pp + 'strBillCVV'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillAddy'].value.length < 1){
				alert('Please enter the your billing address.');
				what.elements[pp + 'strBillAddy'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillCity'].value.length < 1){
				alert('Please enter the your billing city.');
				what.elements[pp + 'strBillCity'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillState'].selectedIndex == 0 && what.elements[pp + 'strBillCountry'].selectedIndex == 220){
				alert('Please select your billing state.');
				what.elements[pp + 'strBillState'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillState'].selectedIndex == 0 && what.elements[pp + 'strBillCountry'].selectedIndex == 39){
				alert('Please select your billing province.');
				what.elements[pp + 'strBillState'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillZip'].value.length < 1 && what.elements[pp + 'strBillCountry'].selectedIndex == 220){
				alert('Please enter the your billing zip code.');
				what.elements[pp + 'strBillZip'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillZip'].value.length < 1 && what.elements[pp + 'strBillCountry'].selectedIndex == 39){
				alert('Please enter the your billing postal code.');
				what.elements[pp + 'strBillZip'].focus();
				return false
			}
}

function validatePay(what,pp,min) {
   var amtclean = what.elements[pp + 'strDAmount'].value;
   what.elements[pp + 'strDAmount'].value = amtclean.replace(/[^0-9\.]/g, "");
    if (what.terms) {
        if (what.acceptIt.value < 1){
			    alert('You must read and accept the terms before registering.');
			    return false
        }
    }
    if (what.elements[pp + 'strDName'].value.length < 1){
				alert('Please enter the your name.');
				what.elements[pp + 'strDName'].focus();
				return false
			}
    if (what.elements[pp + 'strDPName']){
        if (what.elements[pp + 'strDPName'].value.length < 1){
				alert('Please enter the your parent/guardian name.');
				what.elements[pp + 'strDPName'].focus();
				return false
		}
			}
    if (what.elements[pp + 'strDAddy'].value.length < 1){
				alert('Please enter the your address.');
				what.elements[pp + 'strDAddy'].focus();
				return false
			}
    else if (what.elements[pp + 'strDCity'].value.length < 1){
				alert('Please enter the your city.');
				what.elements[pp + 'strDCity'].focus();
				return false
			}
    else if (what.elements[pp + 'strDState'].selectedIndex == 0 && what.elements[pp + 'strDCountry'].selectedIndex == 220){
				alert('Please select your state.');
				what.elements[pp + 'strDState'].focus();
				return false
			}
    else if (what.elements[pp + 'strDState'].selectedIndex == 0 && what.elements[pp + 'strDCountry'].selectedIndex == 39){
				alert('Please select your province.');
				what.elements[pp + 'strDState'].focus();
				return false
			}
    else if (what.elements[pp + 'strDZip'].value.length < 1 && what.elements[pp + 'strDCountry'].selectedIndex == 220){
				alert('Please enter the your zip code.');
				what.elements[pp + 'strDZip'].focus();
				return false
			}
    else if (what.elements[pp + 'strDZip'].value.length < 1 && what.elements[pp + 'strDCountry'].selectedIndex == 39){
				alert('Please enter the your postal code.');
				what.elements[pp + 'strDZip'].focus();
				return false
			}
    else if (isEmail(what.elements[pp + 'strDEmail'].value)){
				alert('Please enter the your email.');
				what.elements[pp + 'strDEmail'].focus();
				return false
			}
    else if (what.elements[pp + 'strDAmount'].value < min){
				alert('Please enter the amount you want charged to the credit card.');
				what.elements[pp + 'strDAmount'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillName'].value.length < 1){
				alert('Please enter the name as it appears on the credit card.');
				what.elements[pp + 'strBillName'].focus();
				return false
			}
    else if (!isValidCreditCardNumber(what.elements[pp + 'strBillCC'].value)){
				alert('Please enter a valid credit card number.');
				what.elements[pp + 'strBillCC'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillExpiry'].value.length < 4){
				alert('Please enter the expiration date as MMYY.');
				what.elements[pp + 'strBillExpiry'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillCVV'].value.length < 3){
				alert('Please enter the 3 or 4 digit verification code on the back of your card.');
				what.elements[pp + 'strBillCVV'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillAddy'].value.length < 1){
				alert('Please enter the your billing address.');
				what.elements[pp + 'strBillAddy'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillCity'].value.length < 1){
				alert('Please enter the your billing city.');
				what.elements[pp + 'strBillCity'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillState'].selectedIndex == 0 && what.elements[pp + 'strBillCountry'].selectedIndex == 220){
				alert('Please select your billing state.');
				what.elements[pp + 'strBillState'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillState'].selectedIndex == 0 && what.elements[pp + 'strBillCountry'].selectedIndex == 39){
				alert('Please select your billing province.');
				what.elements[pp + 'strBillState'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillZip'].value.length < 1 && what.elements[pp + 'strBillCountry'].selectedIndex == 220){
				alert('Please enter the your billing zip code.');
				what.elements[pp + 'strBillZip'].focus();
				return false
			}
    else if (what.elements[pp + 'strBillZip'].value.length < 1 && what.elements[pp + 'strBillCountry'].selectedIndex == 39){
				alert('Please enter the your billing postal code.');
				what.elements[pp + 'strBillZip'].focus();
				return false
			}
}

function validateMFA(what) {
    if (what.mfa_strName.value.length < 1){
				alert('Please enter the applicant name.');
				what.mfa_strName.focus();
				return false
			}
    else if (what.mfa_strPhone.value.length < 1){
				alert('Please enter a phone number.');
				what.mfa_strPhone.focus();
				return false
			}
    else if (what.mfa_strAddy.value.length < 1){
				alert('Please enter a mailing address.');
				what.mfa_strAddy.focus();
				return false
			}
    else if (what.mfa_strCity.value.length < 1){
				alert('Please enter a city.');
				what.mfa_strCity.focus();
				return false
			}
    else if (what.mfa_strState.value.length < 1){
				alert('Please enter a state or country');
				what.mfa_strState.focus();
				return false
			}
    else if (what.mfa_strZip.value.length < 1){
				alert('Please enter a zip or postal code. (NA if not applicable)');
				what.mfa_strZip.focus();
				return false
			}
			else if (isEmail(what.mfa_strEmail.value)){
				alert('Please enter a contact email address.');
				what.mfa_strEmail.focus();
				return false
			}
    var a;
    for (var i=0; i<what.elements.length;i++) {
        if ("file" == what.elements[i].type) {
            a=what.elements[i].value;
            if (a!=''){
                a = a.substring(a.length-4,a.length);
                if(a!='.jpg' && a!='jpeg' && a!='.txt' && a!='.pdf' && a!='.doc' && a!='.rtf'){
                    alert('Uploaded files must have an allowed extension. Allowed extensions are: .jpg, .jpeg, .pdf, .doc, .rtf, and .txt');
                    what.elements[i].focus();
                    what.elements[i].style.background = '#FFFF99';
                    return false
                }
                
            }
        }
    }

             return true
}

function validate(what) {
            showbtn('mpbutton');
			if (what.tktName.value.length < 1){
				alert('Please enter the name to hold the tickets under.');
				showbtn('mpbutton');
				what.tktName.focus();
				return false
			}
			else if (what.promoCode.value.length == 0){
			    if (what.ccName.value.length < 1){
				    alert('Please enter the name as it appears on the credit card.');
				    showbtn('mpbutton');
				    what.ccName.focus();
				    return false
			    }
			    else if (what.ccNbr.value.length < 1){
				    alert('Please enter a valid credit card number.');
				    showbtn('mpbutton');
				    what.ccNbr.focus();
				    return false
			    }
			    else if (what.ccExp.value.length < 4){
				    alert('Please enter the expiration date in the format MMYY.');
				    showbtn('mpbutton');
				    what.ccExp.focus();
				    return false
			    }
			    else if (what.ccCVV.value.length < 3){
				    alert('Please enter the CVV number from the back of the card.');
				    showbtn('mpbutton');
				    what.ccCVV.focus();
				    return false
			        }
			    else if (isValidCreditCardNumber(what.ccNbr.value,what) == false){
				    alert('Credit Card number is invalid.  Please check and reenter.');
				    showbtn('mpbutton');
				    what.ccNbr.select();
				    return false;
			    }
			    else if (what.billAddr1.value.length < 3){
				    alert('Please enter the billing address.');
				    showbtn('mpbutton');
				    what.billAddr1.focus();
				    return false
			    }
			    else if (what.billCity.value.length < 2){
				    alert('Please enter the billing city.');
				    showbtn('mpbutton');
				    what.billCity.focus();
				    return false
			    }
			    else if (what.billState.value.length < 2){
				    alert('Please enter the billing state.');
				    showbtn('mpbutton');
				    what.billState.focus();
				    return false
			    }
			    else if (what.billZip.value.length < 5){
				    alert('Please enter the billing zipcode.');
				    showbtn('mpbutton');
				    what.billZip.focus();
				    return false
			    }
			}
			if (what.phone.value.length < 13){
				alert('Please enter a contact phone number.');
				showbtn('mpbutton');
				what.phone.focus();
				return false
			}
			if (isEmail(what.email.value)){
				alert('Please enter a contact email address.');
				showbtn('mpbutton');
				what.email.focus();
				return false
			}
            else return true
}

function f(what) {
    what.style.background = '#FFFF99';
}
function b(what) {
    what.style.background = '#FFFFFF';
}

			function isValidCreditCardNumber(cardNumber)
			{
				var isValid = false;
				//alert("isValid = " + isValid);
				var cardType;
				var ccCheckRegExp = /[^\d ]/;
				isValid = !ccCheckRegExp.test(cardNumber);
				//alert("isValid = " + isValid);
				var cardPrefix = cardNumber.substring(0, 4);
				//alert("cardPrefix = " + cardPrefix);
				
				if (isValid)
				{
					var cardNumbersOnly = cardNumber.replace(/ /g,"");
					var cardNumberLength = cardNumbersOnly.length;
					var numberProduct;
					var numberProductDigitIndex;
					var checkSumTotal = 0;

					for (digitCounter = cardNumberLength - 1; 
					digitCounter >= 0; 
					digitCounter--)
					{
					checkSumTotal += parseInt (cardNumbersOnly.charAt(digitCounter));
					digitCounter--;
					numberProduct = String((cardNumbersOnly.charAt(digitCounter) * 2));
					for (var productDigitCounter = 0;
						productDigitCounter < numberProduct.length; 
						productDigitCounter++)
					{
						checkSumTotal += 
						parseInt(numberProduct.charAt(productDigitCounter));
					}
					}

					isValid = (checkSumTotal % 10 == 0);
				}
				
				//alert("cardPrefix = " + cardPrefix.substring(0,2) == 37);
				//alert("isValid = " + isValid);
				
				if (isValid){				
					if (cardPrefix == '6011'){
						cardType = "DISCOVER";
						//what.CCType.value = cardType;
						//alert("cardType = " + cardType);
						isValid = true;
					}
					else if (cardPrefix.substring(0,2) == 51 || cardPrefix.substring(0,2) == 52 || cardPrefix.substring(0,2) == 53 || cardPrefix.substring(0,2) == 54 || cardPrefix.substring(0,2) == 55){
						cardType = "MASTER";
						//what.CCType.value = cardType;
						//alert("cardType = " + cardType);
						isValid = true;
					}
					else if (cardPrefix.substring(0,1) == "4"){
						cardType = "VISA";
						//what.CCType.value = cardType;
						//alert("cardType = " + cardType);
						isValid = true;
					}
					else if (cardPrefix.substring(0,2) == 34 || cardPrefix.substring(0,2) == 37){
						cardType = "AMEX";
						//what.CCType.value = cardType;
						//alert("cardType = " + cardType);
						isValid = true;
					}
					else{
						//what.CCType.value = "Michelle"
						//alert("INVALID!");
						isValid = false;
					}
				}
				

				if (isValid)
				{
					var cardNumbersOnly = cardNumber.replace(/ /g,"");
					var cardNumberLength = cardNumbersOnly.length;
					var lengthIsValid = false;
					var prefixIsValid = false;
					var prefixRegExp;

					switch(cardType)
					{
					case "MASTER":
						lengthIsValid = (cardNumberLength == 16);
						prefixRegExp = /^5[1-5]/;
						break;

					case "VISA":
						lengthIsValid = (cardNumberLength == 16 || cardNumberLength == 13);
						prefixRegExp = /^4/;
						break;

					case "AMEX":
						lengthIsValid = (cardNumberLength == 15);
						prefixRegExp = /^3(4|7)/;
						break;
						
					case "DISCOVER":
						lengthIsValid = (cardNumberLength == 16);
						prefixRegExp = /^6011/;
						break;
					}

					prefixIsValid = prefixRegExp.test(cardNumbersOnly);
					isValid = prefixIsValid && lengthIsValid;
				}

				return isValid;
			}

function eventTtl(what,amount,where) {
    var amt = Number(amount);
    var ttl = Number(where.value.replace(/[^0-9\.]/g, ""));
    var newTtl;
    amt=amt*1;
    ttl=ttl*1;
    if (what.checked){newTtl = ttl +amt} else {newTtl = ttl - amt}
    if (newTtl < 0){newTtl = 0}
    where.value = newTtl;
}