function toggleAmount(which){
	if (which == 'enable'){
		d.getElementById('amount_custom').disabled = false;
		d.getElementById('custom_radio').checked = true;
		d.getElementById('amount_custom').focus();
	} else d.getElementById('amount_custom').disabled = true;
}

function toggleCountry(which, cArray){
	cArray = cArray.split(', ');
	if (which == ''){
		for (i = 0; i < cArray.length; i++){
			d.getElementById('country_' + cArray[i]).style.display = 'none';
		}
	} else {
		d.getElementById('country_' + which).style.display = 'block';
		for (i = 0; i < cArray.length; i++){
			if (cArray[i] != which) d.getElementById('country_' + cArray[i]).style.display = 'none';
		}
	}
}

function popCVC(which){
	if (which == 'show'){
		if (typeof(window.innerWidth) == 'number') {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} else if (d.documentElement && (d.documentElement.clientWidth || d.documentElement.clientHeight)) {
			//IE 6+ in 'standards compliant mode'
			myWidth = d.documentElement.clientWidth;
			myHeight = d.documentElement.clientHeight;
		} else if (d.body && (d.body.clientWidth || d.body.clientHeight)) {
			//IE 4 compatible
			myWidth = d.body.clientWidth;
			myHeight = d.body.clientHeight;
		}

		leftSpace = (myWidth/2)-(413/2);
		topSpace = (myHeight/2)-(399/2)+500;
		d.getElementById('cvc').style.display = 'block';
		d.getElementById('cvc').style.left = leftSpace;
		d.getElementById('cvc').style.top = topSpace;
	} else d.getElementById('cvc').style.display = 'none';
}

function toggleTribute(which){
	if (which == '') d.getElementById('tribute').style.display = 'none';
	else d.getElementById('tribute').style.display = 'block';
}

function toggleTributeMail(which){
	if (which == true) d.getElementById('tribute_mail').style.display = 'block';
	else d.getElementById('tribute_mail').style.display = 'none';
}

function process(){
	//Reset Defaults
	error = 0;
	query = '';
	d.getElementById('error_amount').innerHTML = '';
	d.getElementById('error_fname').innerHTML = '*';
	d.getElementById('error_lname').innerHTML = '*';
	d.getElementById('error_address_1USA').innerHTML = '*';
	d.getElementById('error_cityUSA').innerHTML = '*';
	d.getElementById('error_statesUSA').innerHTML = '*';
	d.getElementById('error_postcodeUSA').innerHTML = '*';
	d.getElementById('error_address_1CAN').innerHTML = '*';
	d.getElementById('error_cityCAN').innerHTML = '*';
	d.getElementById('error_statesCAN').innerHTML = '*';
	d.getElementById('error_postcodeCAN').innerHTML = '*';
	d.getElementById('error_country').innerHTML = '*';
	d.getElementById('error_phone').innerHTML = '* (numbers only)';
	d.getElementById('error_email').innerHTML = '*';
	d.getElementById('error_ccname').innerHTML = '*';
	d.getElementById('error_ccnumber').innerHTML = '* (numbers only)';
	d.getElementById('error_cardtype').innerHTML = '*';
	d.getElementById('error_expdate').innerHTML = '*';
	d.getElementById('error_ccidentifier1').innerHTML = '* <a href="#" onclick="popCVC(\'show\'); return false;">What is this?</a>';
	d.getElementById('error_tribute_name').innerHTML = '*';
	d.getElementById('error_tributemail_name').innerHTML = '*';
	d.getElementById('error_tributemail_address').innerHTML = '*';
	d.getElementById('error_tributemail_city').innerHTML = '*';
	d.getElementById('error_tributemail_state').innerHTML = '*';
	d.getElementById('error_tributemail_zip').innerHTML = '*';
	d.getElementById('error_tributemail_country').innerHTML = '*';
	d.getElementById('error_tributemail_phone').innerHTML = '(numbers only)';
	d.getElementById('error_tributemail_email').innerHTML = '';

	//Tribute
	formTributeType = d.form.tribute_type[d.form.tribute_type.selectedIndex].value;
	if (formTributeType != ''){

		if (query != '') query += '&';
		query += 'tribute_type=' + formTributeType;

		formTributeName = d.getElementById('tribute_name').value;
		if (formTributeName == ''){
			d.getElementById('error_tribute_name').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Name cannont be blank.</span>';
			highestError = 'tribute_name';
			error++;
		} else query += '&tribute_name=' + formTributeName;

		formTributeDesc = d.getElementById('tribute_desc').value;
		if (formTributeDesc != '') query += '&tribute_desc=' + formTributeDesc;

		formMailCheck = d.form.mail_check.checked;
		if (formMailCheck == true){

			formMailName = d.getElementById('tributemail_name').value;
			if (formMailName == ''){
				d.getElementById('error_tributemail_name').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Name cannont be blank.</span>';
				highestError = 'tributemail_name';
				error++;
			} else query += '&tributemail_name=' + formMailName;

			formMailAddress = d.getElementById('tributemail_address').value;
			if (formMailAddress == ''){
				d.getElementById('error_tributemail_address').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Address cannont be blank.</span>';
				highestError = 'tributemail_address';
				error++;
			} else query += '&tributemail_address=' + formMailAddress;

			formMailCity = d.getElementById('tributemail_city').value;
			if (formMailCity == ''){
				d.getElementById('error_tributemail_city').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">City cannont be blank.</span>';
				highestError = 'tributemail_city';
				error++;
			} else query += '&tributemail_city=' + formMailCity;

			formMailState = d.getElementById('tributemail_state').value;
			if (formMailState == ''){
				d.getElementById('error_tributemail_state').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">State cannont be blank.</span>';
				highestError = 'tributemail_state';
				error++;
			} else query += '&tributemail_state=' + formMailState;

			formMailZip = d.getElementById('tributemail_zip').value;
			if (formMailZip == ''){
				d.getElementById('error_tributemail_zip').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Postal Code cannont be blank.</span>';
				highestError = 'tributemail_zip';
				error++;
			} else query += '&tributemail_zip=' + formMailZip;

			formMailCountry = d.getElementById('tributemail_country').value;
			if (formMailCountry == ''){
				d.getElementById('error_tributemail_country').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Country cannont be blank.</span>';
				highestError = 'tributemail_country';
				error++;
			} else query += '&tributemail_country=' + formMailCountry;

			formMailPhone = d.getElementById('tributemail_phone').value;
			if (formMailPhone != '') query += '&tributemail_phone=' + formMailPhone;

			formMailEmail = d.getElementById('tributemail_email').value;
			if (formMailEmail != '') query += '&tributemail_email=' + formMailEmail;

		}

	}

	//CVC
	formCVC = d.getElementById('ccidentifier1').value;
	if (formCVC == ''){
		d.getElementById('error_ccidentifier1').innerHTML = '* <a href="#" onclick="popCVC(\'show\'); return false;">What is this?</a> <span style="color:#ff0000;font-weight:bold;">Enter CVC.</span>';
		highestError = 'ccidentifier1';
		error++;
	} else if (formCVC.match(/[^0-9]/)){ //has characters other than numbers
		d.getElementById('error_ccidentifier1').innerHTML = '* <a href="#" onclick="popCVC(\'show\'); return false;">What is this?</a> <span style="color:#ff0000;font-weight:bold;">CVC can only contain numbers.</span>';
		highestError = 'ccidentifier1';
		error++;
	} else {
		if (query != '') query += '&';
		query += 'ccidentifier1=' + formCVC;
	}

	//Expiration Date
	formMonth = d.getElementById('month').value;
	formYear = d.getElementById('year').value;
	if (formMonth == '' && formYear == ''){
		d.getElementById('error_expdate').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Enter Expiration Date.</span>';
		highestError = 'expdate';
		error++;
	} else if (formMonth == ''){
		d.getElementById('error_expdate').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Enter Expiration Month.</span>';
		highestError = 'expdate';
		error++;
	} else if (formYear == ''){
		d.getElementById('error_expdate').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Enter Expiration Year.</span>';
		highestError = 'expdate';
		error++;
	} else if (formMonth.match(/[^0-9]/) && formYear.match(/[^0-9]/)){ //has characters other than numbers
		d.getElementById('error_expdate').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Expiration Date can only contain numbers.</span>';
		highestError = 'expdate';
		error++;
	} else if (formMonth.match(/[^0-9]/)){ //has characters other than numbers
		d.getElementById('error_expdate').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Month can only contain numbers.</span>';
		highestError = 'expdate';
		error++;
	} else if (formYear.match(/[^0-9]/)){ //has characters other than numbers
		d.getElementById('error_expdate').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Year can only contain numbers.</span>';
		highestError = 'expdate';
		error++;
	} else if (formMonth.length != 2 && formYear.length != 4){ //longer than 2 chars & 4 chars
		d.getElementById('error_expdate').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Month should only contain 2 digits; Year should only contain 4 digits.</span>';
		highestError = 'expdate';
		error++;
	} else if (formMonth.length != 2){ //longer than 2 chars
		d.getElementById('error_expdate').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Month should only contain 2 digits.</span>';
		highestError = 'expdate';
		error++;
	} else if (formYear.length !== 4){ //longer than 4 chars
		d.getElementById('error_expdate').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Year should only contain 4 digits.</span>';
		highestError = 'expdate';
		error++;
	} else query += '&month=' + formMonth + '&year=' + formYear;

	//Card Number & Card Type
	formCCnumber = d.getElementById('ccnumber').value;
	formCCtype = d.form.cardtype[d.form.cardtype.selectedIndex].value;
	if (formCCtype == '' || formCCnumber == ''){
		if (formCCtype == ''){
			d.getElementById('error_cardtype').innerHTML = '* (numbers only) <span style="color:#ff0000;font-weight:bold;">Enter Card Type.</span>';
			highestError = 'cardtype';
			error++;
		}

		if (formCCnumber == ''){
			d.getElementById('error_ccnumber').innerHTML = '* (numbers only) <span style="color:#ff0000;font-weight:bold;">Enter Card Number.</span>';
			highestError = 'ccnumber';
			error++;
		}
	} else if (formCCnumber.match(/[^0-9]/)){ //has characters other than numbers
		d.getElementById('error_ccnumber').innerHTML = '* (numbers only) <span style="color:#ff0000;font-weight:bold;">The card number can only contain numbers.</span>';
		highestError = 'ccnumber';
		error++;
	} else if (!checkCreditCard(formCCnumber, formCCtype)){
		d.getElementById('error_ccnumber').innerHTML = '* (numbers only) <span style="color:#ff0000;font-weight:bold;">Card Number is incorrect.</span>';
		highestError = 'ccnumber';
		error++;
	} else query += '&ccnumber=' + formCCnumber + '&cardtype=' + formCCtype;

	//Cardholder's Name
	formCCname = d.getElementById('ccname').value;
	if (formCCname == ''){
		d.getElementById('error_ccname').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Name cannont be blank.</span>';
		highestError = 'ccname';
		error++;
	} else query += '&ccname=' + formCCname;

	//Email Address
	exts = ['ac','ad','ae','aero','af','ag','ai','al','am','an','ao','aq','ar','arpa','as','asia','at','au','aw','ax','az','ba','bb','bd','be','bf','bg','bh','bi','biz','bj','bl','bm','bn','bo','br','bs','bt','bv','bw','by','bz','ca','cat','cc','cd','cf','cg','ch','ci','ck','cl','cm','cn','co','com','coop','cr','cs','cu','cv','cx','cy','cz','de','dj','dk','dm','do','dz','ec','edu','ee','eg','eh','er','es','et','eu','fi','fj','fk','fm','fo','fr','ga','gb','gd','ge','gf','gg','gh','gi','gl','gm','gn','gov','gp','gq','gr','gs','gt','gu','gw','gy','hk','hm','hn','hr','ht','hu','id','ie','il','im','in','info','int','io','iq','ir','is','it','je','jm','jo','jobs','jp','ke','kg','kh','ki','km','kn','kp','kr','kw','ky','kz','la','lb','lc','li','lk','lr','ls','lt','lu','lv','ly','ma','mc','md','me','mf','mg','mh','mil','mk','ml','mm','mn','mo','mobi','mp','mq','mr','ms','mt','mu','museum','mv','mw','mx','my','mz','na','name','nato','nc','ne','net','nf','ng','ni','nl','no','np','nr','nu','nz','om','org','pa','pe','pf','pg','ph','pk','pl','pm','pn','pr','pro','ps','pt','pw','py','qa','re','ro','rs','ru','rw','sa','sb','sc','sd','se','sg','sh','si','sj','sk','sl','sm','sn','so','sr','st','su','sv','sy','sz','tc','td','tel','tf','tg','th','tj','tk','tm','tn','to','tp','tr','travel','tt','tv','tw','tz','ua','ug','uk','um','us','uy','uz','va','vc','ve','vg','vi','vn','vu','wf','ws','ye','yt','yu','za','zm','zr','zw'];
	formEmail = d.getElementById('email').value;
	splitAt = formEmail.split('@');
	domain = splitAt[splitAt.length - 1];
	splitDomainPeriod = splitAt[splitAt.length - 1].split('.');
	if (formEmail == ''){ //email address is blank
		d.getElementById('error_email').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Please enter an email address.</span>';
		highestError = 'email';
		error++;
	} else if (formEmail.length < 8 || formEmail.length > 256){ //email address total characters is less than 8 characters or greater than 256 characters
		d.getElementById('error_email').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Your email address is not valid.</span>';
		highestError = 'email';
		error++;
	} else if (splitAt.length != 2){ //more than one @ symbols or no @ symbol
		d.getElementById('error_email').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Your email address is not valid.</span>';
		highestError = 'email';
		error++;
	} else if (splitAt[0].match(/^\"/) && splitAt[0].match(/\"$/)){ //local-part is a quoted-string
		d.getElementById('error_email').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">We do not allow e-mail addresses with quoted-strings for the local-part portion of the address.</span>';
		highestError = 'email';
		error++;
	} else if (splitAt[0].length < 1 || splitAt[0].length > 64){ //local-part is less than 1 character or greater than 64 characters
		d.getElementById('error_email').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Your email address is not valid.</span>';
		highestError = 'email';
		error++;
	} else if (splitAt[0].match(/\.{2}/)){ //local-part contains consecutive periods
		d.getElementById('error_email').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Your email address is not valid.</span>';
		highestError = 'email';
		error++;
	} else if (splitAt[0].match(/^\./) || splitAt[0].match(/\.$/)){ //local-part starts or ends with a period
		d.getElementById('error_email').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Your email address is not valid.</span>';
		highestError = 'email';
		error++;
	} else if (splitAt[0].match(/[^a-z,0-9,\!,\#,\$,\%,\&,\',\*,\+,\-,\/,\=,\?,\^,\_,\`,\{,\|,\},\~,\.]/i)){ //local-part contains characters other than a-z A-Z 0-9 ! # $ % & ' * + - / = ? ^ _ ` { | } ~ .
		d.getElementById('error_email').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Your email address is not valid.</span>';
		highestError = 'email';
		error++;
	} else if (domain.match(/^\[/) && domain.match(/\]$/)){ //domain is ip address literal
		ip = splitAt[splitAt.length - 1].replace(/[\[|\]]/g, '');
		if (ip.indexOf('.') != -1) splitIpPeriod = ip.split('.');

		if (ip.indexOf('.') == -1){ //ip address has no periods
			d.getElementById('error_email').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Your email address is not valid.</span>';
			highestError = 'email';
			error++;
		} else if (ip.match(/\./g).length !== 3){ //ip address doesnt have 3 periods
			d.getElementById('error_email').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Your email address is not valid.</span>';
			highestError = 'email';
			error++;
		} else if (ip.match(/[^0-9\.]/)){ //ip address contains characters other than numbers or periods
			d.getElementById('error_email').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Your email address is not valid.</span>';
			highestError = 'email';
			error++;
		} else if(splitIpPeriod[0].length < 1 || splitIpPeriod[0].length > 3 || splitIpPeriod[1].length < 1 || splitIpPeriod[1].length > 3 || splitIpPeriod[2].length < 1 || splitIpPeriod[2].length > 3 || splitIpPeriod[3].length < 1 || splitIpPeriod[3].length > 3){ //an ip block is less than 1 character or greater than 3 characters
			d.getElementById('error_email').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Your email address is not valid.</span>';
			highestError = 'email';
			error++;
		} else query += '&email=' + formEmail;
	} else if (splitAt[splitAt.length - 1] < 6 || splitAt[splitAt.length - 1] > 255){ //domain is less than 6 characters or greater than 255 characters
		d.getElementById('error_email').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Your email address is not valid.</span>';
		highestError = 'email';
		error++;
	} else if (!inArray(splitDomainPeriod[splitDomainPeriod.length - 1], exts)){ //domain extension not in array
		d.getElementById('error_email').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Your email address is not valid.</span>';
		highestError = 'email';
		error++;
	} else query += '&email=' + formEmail;

	//Phone Number
	formPhone = d.getElementById('phone').value;
	if (formPhone == ''){ //blank value
		d.getElementById('error_phone').innerHTML = '* (numbers only) <span style="color:#ff0000;font-weight:bold;">The phone number is blank.</span>';
		highestError = 'phone';
		error++;
	} else if (formPhone.match(/[^0-9]/)){ //has characters other than numbers
		d.getElementById('error_phone').innerHTML = '* (numbers only) <span style="color:#ff0000;font-weight:bold;">The phone number can only contain numbers.</span>';
		highestError = 'phone';
		error++;
	} else if (formPhone.length != 10){ //length is incorrect
		d.getElementById('error_phone').innerHTML = '* (numbers only) <span style="color:#ff0000;font-weight:bold;">The phone number should contain 10 digits.</span>';
		highestError = 'phone';
		error++;
	} else {
		query += '&phone=' + formPhone;
	}

	//Country
	formCountry = d.form.country_toggle[d.form.country_toggle.selectedIndex].value;
	if (formCountry == ''){
		d.getElementById('error_country').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Please choose your country.</span>';
		highestError = 'country_toggle';
		error++;
	} else {
		query += '&country=' + formCountry;
		if (formCountry == 'CA'){ //Canada
			//Address 1
			formAddress1 = d.getElementById('address_1CAN').value;
			if (formAddress1 == ''){
				d.getElementById('error_address_1CAN').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Please enter your address.</span>';
				highestError = 'address_1CAN';
				error++;
			} else query += '&address1=' + escape(formAddress1);

			//Address 2
			formAddress2 = d.getElementById('address_2CAN').value;
			if (formAddress1 != '') query += '&address2=' + escape(formAddress2);

			//City
			formCity = d.getElementById('cityCAN').value;
			if (formCity == ''){
				d.getElementById('error_cityCAN').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Please enter your city.</span>';
				highestError = 'cityCAN';
				error++;
			} else query += '&city=' + formCity;

			//States
			formState = d.form.statesCAN[d.form.statesCAN.selectedIndex].value;
			if (formState == ''){
				d.getElementById('error_statesCAN').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Please choose your province or territory.</span>';
				highestError = 'statesCAN';
				error++;
			} else query += '&state=' + formState;

			//Postcode
			formPostcode = d.getElementById('postcodeCAN').value;
			if (formPostcode == ''){
				d.getElementById('error_postcodeCAN').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Please enter your postal code.</span>';
				highestError = 'postcodeCAN';
				error++;
			} else query += '&postcode=' + formPostcode;
		} else { //United States
			//Address 1
			formAddress1 = d.getElementById('address_1USA').value;
			if (formAddress1 == ''){
				d.getElementById('error_address_1USA').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Please enter your address.</span>';
				highestError = 'address_1USA';
				error++;
			} else query += '&address1=' + escape(formAddress1);

			//Address 2
			formAddress2 = d.getElementById('address_2USA').value;
			if (formAddress2 != '') query += '&address2=' + escape(formAddress2);

			//City
			formCity = d.getElementById('cityUSA').value;
			if (formCity == ''){
				d.getElementById('error_cityUSA').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Please enter your city.</span>';
				highestError = 'cityUSA';
				error++;
			} else query += '&city=' + formCity;

			//States
			formState = d.form.statesUSA[d.form.statesUSA.selectedIndex].value;
			if (formState == ''){
				d.getElementById('error_statesUSA').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Please choose your state.</span>';
				highestError = 'statesUSA';
				error++;
			} else query += '&state=' + formState;

			//Postcode
			formPostcode = d.getElementById('postcodeUSA').value;
			if (formPostcode == ''){
				d.getElementById('error_postcodeUSA').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Please enter your postal code.</span>';
				highestError = 'postcodeUSA';
				error++;
			} else query += '&postcode=' + formPostcode;
		}
	}

	//Last Name
	formLname = d.getElementById('lname').value;
	if (formLname == ''){
		d.getElementById('error_lname').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">Last name cannont be blank.</span>';
		highestError = 'lname';
		error++;
	} else query += '&lname=' + formLname;

	//First Name
	formFname = d.getElementById('fname').value;
	if (formFname == ''){
		d.getElementById('error_fname').innerHTML = '* <span style="color:#ff0000;font-weight:bold;">First name cannont be blank.</span>';
		highestError = 'fname';
		error++;
	} else query += '&fname=' + formFname;

	//Amount
	formAmount = d.form.amount;
	formAmountCustom = d.getElementById('amount_custom').value;

	for (i = 0; i < formAmount.length; i++){
		if (formAmount[i].checked){
			if (formAmount[i].value == 'amount_custom'){
				if (formAmountCustom == ''){
					d.getElementById('error_amount').innerHTML = '<span style="color:#ff0000;font-weight:bold;">Please enter an amount to donate.</span>';
					highestError = 'amount';
					error++;
				} else if (formAmountCustom.match(/[^0-9.]/)){
					d.getElementById('error_amount').innerHTML = '<span style="color:#ff0000;font-weight:bold;">Amount can only contact numbers</span>';
					highestError = 'amount';
					error++;
				} else if (formAmountCustom < 10){
					d.getElementById('error_amount').innerHTML = '<span style="color:#ff0000;font-weight:bold;">Amount must be at least $10.00</span>';
					highestError = 'amount';
					error++;
				} else query += '&fulltotal=' + formAmountCustom;
			} else query += '&fulltotal=' + formAmount[i].value;
		}
	}

	//Support
	selObj = d.getElementById('support');
	selIndex = selObj.selectedIndex;
	formSupport = selObj.options[selIndex].text;
	query += '&support=' + formSupport;

	//Corporate
	formCorporate = d.form.iscompany.checked;
	if (formCorporate == true) query += '&corporate=true';

	//Anonymous
	formAnonymous = d.form.isanonymous.checked;
	if (formAnonymous == true) query += '&anonymous=true';

	//GiftMatch
	formGiftMatch = d.getElementById('giftmatch').value;
	if (formGiftMatch != '') query += '&giftmatch=' + formGiftMatch;

	//Referral
	selObj = d.getElementById('referral');
	selIndex = selObj.selectedIndex;
	formReferral = selObj.options[selIndex].text;
	if (formReferral != '') query += '&referral=' + formReferral;

	//Title
	selObj = d.getElementById('title');
	selIndex = selObj.selectedIndex;
	formTitle = selObj.options[selIndex].text;
	if (formTitle != '') query += '&title=' + formTitle;

	//Error or Submit
	if (error == 0) window.location = 'index_process.php?' + query;
	//if (error == 0) alert('index_process.php?' + query);
	else window.location.hash = highestError;
}

/*============================================================================*/

/*

This routine checks the credit card number. The following checks are made:

1. A number has been provided
2. The number is a right length for the card
3. The number has an appropriate prefix for the card
4. The number has a valid modulus 10 number check digit if required

If the validation fails an error is reported.

The structure of credit card formats was gleaned from a variety of sources on
the web, although the best is probably on Wikepedia ("Credit card number"):

  http://en.wikipedia.org/wiki/Credit_card_number

Parameters:
            cardnumber           number on the card
            cardname             name of card as defined in the card list below

Author:     John Gardner
Date:       1st November 2003
Updated:    26th Feb. 2005      Additional cards added by request
Updated:    27th Nov. 2006      Additional cards added from Wikipedia
Updated:    18th Jan. 2008      Additional cards added from Wikipedia
Updated:    26th Nov. 2008      Maestro cards extended
Updated:    19th Jun. 2009      Laser cards extended from Wikipedia

*/

/*
   If a credit card number is invalid, an error reason is loaded into the
   global ccErrorNo variable. This can be be used to index into the global error
   string array to report the reason to the user if required:

   e.g. if (!checkCreditCard (number, name) alert (ccErrors(ccErrorNo);
*/

var ccErrorNo = 0;
var ccErrors = new Array ()

ccErrors [0] = "Unknown card type";
ccErrors [1] = "No card number provided";
ccErrors [2] = "Credit card number is in invalid format";
ccErrors [3] = "Credit card number is invalid";
ccErrors [4] = "Credit card number has an inappropriate number of digits";

function checkCreditCard (cardnumber, cardname) {
  // Array to hold the permitted card characteristics
  var cards = new Array();

  // Define the cards we support. You may add addtional card types.

  //  Name:      As in the selection box of the form - must be same as user's
  //  Length:    List of possible valid lengths of the card number for the card
  //  prefixes:  List of possible prefixes for the card
  //  checkdigit Boolean to say whether there is a check digit

  cards [0] = {name: "visa",
               length: "13,16",
               prefixes: "4",
               checkdigit: true};
  cards [1] = {name: "mc",
               length: "16",
               prefixes: "51,52,53,54,55",
               checkdigit: true};
  cards [2] = {name: "dinersclub",
               length: "14,16",
               prefixes: "305, 36, 38, 54,55",
               checkdigit: true};
  cards [3] = {name: "carteblanche",
               length: "14",
               prefixes: "300,301,302,303,304,305",
               checkdigit: true};
  cards [4] = {name: "amex",
               length: "15",
               prefixes: "34,37",
               checkdigit: true};
  cards [5] = {name: "discover",
               length: "16",
               prefixes: "6011,622,64,65",
               checkdigit: true};
  cards [6] = {name: "jcb",
               length: "16",
               prefixes: "35",
               checkdigit: true};
  cards [7] = {name: "enroute",
               length: "15",
               prefixes: "2014,2149",
               checkdigit: true};
  cards [8] = {name: "solo",
               length: "16,18,19",
               prefixes: "6334, 6767",
               checkdigit: true};
  cards [9] = {name: "switch",
               length: "16,18,19",
               prefixes: "4903,4905,4911,4936,564182,633110,6333,6759",
               checkdigit: true};
  cards [10] = {name: "maestro",
               length: "12,13,14,15,16,18,19",
               prefixes: "5018,5020,5038,6304,6759,6761",
               checkdigit: true};
  cards [11] = {name: "visaelectron",
               length: "16",
               prefixes: "417500,4917,4913,4508,4844",
               checkdigit: true};
  cards [12] = {name: "lasercard",
               length: "16,17,18,19",
               prefixes: "6304,6706,6771,6709",
               checkdigit: true};

  // Establish card type
  var cardType = -1;
  for (var i=0; i<cards.length; i++) {

    // See if it is this card (ignoring the case of the string)
    if (cardname.toLowerCase () == cards[i].name.toLowerCase()) {
      cardType = i;
      break;
    }
  }

  // If card type not found, report an error
  if (cardType == -1) {
     ccErrorNo = 0;
     return false;
  }

  // Ensure that the user has provided a credit card number
  if (cardnumber.length == 0)  {
     ccErrorNo = 1;
     return false;
  }

  // Now remove any spaces from the credit card number
  cardnumber = cardnumber.replace (/\s/g, "");

  // Check that the number is numeric
  var cardNo = cardnumber
  var cardexp = /^[0-9]{13,19}$/;
  if (!cardexp.exec(cardNo))  {
     ccErrorNo = 2;
     return false;
  }

  // Now check the modulus 10 check digit - if required
  if (cards[cardType].checkdigit) {
    var checksum = 0;                                  // running checksum total
    var mychar = "";                                   // next char to process
    var j = 1;                                         // takes value of 1 or 2

    // Process each digit one by one starting at the right
    var calc;
    for (i = cardNo.length - 1; i >= 0; i--) {

      // Extract the next digit and multiply by 1 or 2 on alternative digits.
      calc = Number(cardNo.charAt(i)) * j;

      // If the result is in two digits add 1 to the checksum total
      if (calc > 9) {
        checksum = checksum + 1;
        calc = calc - 10;
      }

      // Add the units element to the checksum total
      checksum = checksum + calc;

      // Switch the value of j
      if (j ==1) {j = 2} else {j = 1};
    }

    // All done - if checksum is divisible by 10, it is a valid modulus 10.
    // If not, report an error.
    if (checksum % 10 != 0)  {
     ccErrorNo = 3;
     return false;
    }
  }

  // The following are the card-specific checks we undertake.
  var LengthValid = false;
  var PrefixValid = false;
  var undefined;

  // We use these for holding the valid lengths and prefixes of a card type
  var prefix = new Array ();
  var lengths = new Array ();

  // Load an array with the valid prefixes for this card
  prefix = cards[cardType].prefixes.split(",");

  // Now see if any of them match what we have in the card number
  for (i=0; i<prefix.length; i++) {
    var exp = new RegExp ("^" + prefix[i]);
    if (exp.test (cardNo)) PrefixValid = true;
  }

  // If it isn't a valid prefix there's no point at looking at the length
  if (!PrefixValid) {
     ccErrorNo = 3;
     return false;
  }

  // See if the length is valid for this card
  lengths = cards[cardType].length.split(",");
  for (j=0; j<lengths.length; j++) {
    if (cardNo.length == lengths[j]) LengthValid = true;
  }

  // See if all is OK by seeing if the length was valid. We only check the
  // length if all else was hunky dory.
  if (!LengthValid) {
     ccErrorNo = 4;
     return false;
  };

  // The credit card is in the required format.
  return true;
}

/*============================================================================*/
