	function showCandlesSection() {
	
		if(document.getElementById('candlesToFranCheckBox').checked) {
			document.getElementById('candleheader').style.display='inline';		
			document.getElementById('candlescontent').style.display='inline';	
			document.getElementById('NumOfCandles').focus();
		}
		else {
			document.getElementById('candleheader').style.display='none';	
			document.getElementById('candlescontent').style.display='none';	
			document.getElementById('NumOfCandles').value = '';
			document.getElementById('prayer_intention').value = '';
			document.getElementById('sendToPrayerIntention').checked = false;
			document.getElementById('candlescharge_total').value = "0";						
		}
		if(document.getElementById('NumOfCandles').value == '') {
			document.getElementById('candlescharge_total').value = "0";
		}
		getGrandTotal();
	}
	
	
	
	function showMassesSection() {
	
		if(document.getElementById('massesToFranCheckBox').checked) {
			document.getElementById('massesheader').style.display='inline';		
			document.getElementById('massescontent').style.display='inline';	
			document.getElementById('NumOfMasses').focus();
		}
		else {
			document.getElementById('massesheader').style.display='none';	
			document.getElementById('massescontent').style.display='none';	
			document.getElementById('NumOfMasses').value = '';						
			document.getElementById('massescharge_total').value = "0";						
		}
		if(document.getElementById('NumOfMasses').value == '') {
			document.getElementById('massescharge_total').value = "0";
		}
		getGrandTotal();
	}	
	
	
	
	function formatCurrency(num) {
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + '$' + num + '.' + cents);
	}
	
	
	function getGrandTotal() {
		
		var donateValue = document.getElementById('donatecharge_total').value;
		var candlesValue = document.getElementById('candlescharge_total').value;
		var massesValue = document.getElementById('massescharge_total').value;
		
		var grandtotal = 0;
		if(donateValue != '') {
			grandtotal += eval(donateValue);
		}
		if(candlesValue != '') {
			grandtotal += eval(candlesValue);
		}	
		if(massesValue != '') {
			grandtotal += eval(massesValue);
		}		
		
		document.getElementById('donategift').innerHTML = formatCurrency(donateValue);
		document.getElementById('candlesgift').innerHTML = formatCurrency(candlesValue);			
		document.getElementById('massesgift').innerHTML = formatCurrency(massesValue);
		document.getElementById('totalgift').innerHTML = formatCurrency(grandtotal);
		 
	}
	
	function ShowDesc() {
		var valueOfDD = document.getElementById('gift_type_id').value;
		if(valueOfDD == 'St. Anthony Bread') {
			document.getElementById('selectGiftDesc').innerHTML = '<a href="donateoptions.asp#StAnthonyBread" title="Click here to find out more" target="_blank" style="color:#996600;font-weight:bold;text-decoration:none;">What Is St. Anthony Bread?</a>';
		}
		else if(valueOfDD == 'Shrine Society') {
			document.getElementById('selectGiftDesc').innerHTML = '<a href="donateoptions.asp#ShrineSociety" title="Click here to find out more" target="_blank" style="color:#996600;font-weight:bold;text-decoration:none;">What is The St. Anthony Shrine Society?</a>';		
		}
		else if(valueOfDD == 'Missions') {
			document.getElementById('selectGiftDesc').innerHTML = '<a href="donateoptions.asp#MissionWork" title="Click here to find out more" target="_blank" style="color:#996600;font-weight:bold;text-decoration:none;">What is mission work?</a>';		
		}		
		else if(valueOfDD == 'Formation') {
			document.getElementById('selectGiftDesc').innerHTML = '<a href="donateoptions.asp#Formation" title="Click here to find out more" target="_blank" style="color:#996600;font-weight:bold;text-decoration:none;">What is formation?</a>';		
		}	
		else if(valueOfDD == 'Retired Friars') {
			document.getElementById('selectGiftDesc').innerHTML = '<a href="donateoptions.asp#Retired" title="Click here to find out more" target="_blank" style="color:#996600;font-weight:bold;text-decoration:none;">Helping retired and infirm friars</a>';		
		}			
		else {
			document.getElementById('selectGiftDesc').innerHTML = '<a href="donateoptions.asp" title="Click here to find out more" target="_blank" style="color:#996600;font-weight:bold;text-decoration:none;">What are the donation options?</a>';		
		}
		
		showHideStatueOption();			
	}
	
	function IsNumeric(sText, field) {
	   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) {

				document.getElementById(field).select();
				alert('This is not a numeric value.');
				return false;
			}
	   }  
	   return true;
	}	
	
	function localFormCheck() {
			var A500 = document.getElementById('chk_charge_total_500').checked;
			var A250 = document.getElementById('chk_charge_total_250').checked;
			var A100 = document.getElementById('chk_charge_total_100').checked;
			var A75 = document.getElementById('chk_charge_total_75').checked;
			var A50 = document.getElementById('chk_charge_total_50').checked;
			var A35 = document.getElementById('chk_charge_total_35').checked;
			var A25 = document.getElementById('chk_charge_total_25').checked;
			var A10= document.getElementById('chk_charge_total_10').checked;
			var A10= document.getElementById('chk_charge_total_10').checked;			
			var AOther= document.getElementById('chk_charge_total_other').checked;	
			
			var numOfMassesVar = document.getElementById('NumOfMasses').value;
			var checkboxForMassesVar = document.getElementById('massesToFranCheckBox').checked;				

            var prayer_intention = document.getElementById('prayer_intention').value.length;            
            var bill_note_id = document.getElementById('bill_note_id').value.length;            			
			
			if(A500 == false && A250 == false && A100 == false && A75 == false && A50 == false && A35 == false && A25 == false && A10 == false && AOther == false) {
				alert('Please select a donation amount');
				return false;
			}
			else if (checkboxForMassesVar == true && numOfMassesVar == '')	{
				alert('Please type the number of masses you would like to have offered.')
				return false;
			}	
            else if(prayer_intention > 400) {
                alert('The prayer intention text can only be 400 characters. It is currently ' + prayer_intention + ' characters in length.');
				document.getElementById('prayer_intention').focus();
                return false;
            }  
            else if(bill_note_id > 400) {
                alert('The comments text can only be 400 characters. It is currently ' + bill_note_id + ' characters in length.');
				document.getElementById('bill_note_id').focus();
                return false;
            }  			
			else {
				return CheckForm("Donation");
			}	

	}
	
	function gup( name ){  
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
		var regexS = "[\\?&]"+name+"=([^&#]*)";  var regex = new RegExp( regexS );  
		var results = regex.exec( window.location.href );  
		if( results == null )    
			return "";  
		else    
			return results[1];
	}	
	
	function setDonationValue() {
		var donateoption = gup('donateoption');
		if(donateoption!='') {
			document.getElementById('gift_type_id').value = unescape(donateoption); 
			ShowDesc();
		}
	}
	
	function ShowStatueDiv() {
		document.getElementById('DivStatue').style.display='inline';		
		
	}
	
	function HideStatueDiv() {
		document.getElementById('DivStatue').style.display='none';
	}	


<!--
//CHECK FORM starts the checking of the form data
function CheckForm(objForm)
{
	if (IsFormComplete(objForm) == true)
		return true;
	else
		return false;
}
//**************END FUNCTION****************************
/* IS FORM COMPLETE? Loops through all the form elements validating data.
                    bill_first_name 
                    bill_last_name 
                    bill_address_one
                    bill_city
		            bill_state_or_province
                    bill_postal_code
                    bill_country
                       bill_phone
                    bill_email
                    credit_card_type
                    credit_card_number
                       bill_note
                    expire_month
                    expire_year
                    charge_total
        	        other_textbox 
					   CHECKBOXES
*/
function IsFormComplete(FormName)
{
var x = 0;
var FormOk = true;

while ((x < document.forms[FormName].elements.length) && (FormOk))
   {  //if NO value in text box, and the form element isn't Preview, DeliveryDate, failload (hidden element)
      //&& (document.forms[FormName].elements[x].name!='expire_month') && (document.forms[FormName].elements[x].name!='expire_year')
     if ((document.forms[FormName].elements[x].value == '') && (document.forms[FormName].elements[x].name!='donatecharge_total') && (document.forms[FormName].elements[x].name!='candlescharge_total') && (document.forms[FormName].elements[x].name!='prayer_intention') && (document.forms[FormName].elements[x].name!='bill_note') && (document.forms[FormName].elements[x].name!='NumOfCandles') && (document.forms[FormName].elements[x].name!='bill_phone')&& (document.forms[FormName].elements[x].name!='other_textbox')&& (document.forms[FormName].elements[x].name!='DonationSite')&& (document.forms[FormName].elements[x].name!='gift_type')) 
     {
        if (document.forms[FormName].elements[x].name == 'bill_first_name')
		{
				alert('Please type your first name and then try again.')
		}	
        if (document.forms[FormName].elements[x].name == 'bill_last_name')
		{
				alert('Please type your last name and then try again.')
		}
        if (document.forms[FormName].elements[x].name == 'bill_address_one')
		{
				alert('Please type your street address and then try again.')
		}
        if (document.forms[FormName].elements[x].name == 'bill_city')
		{
				alert('Please type your city and then try again.')
		}
        if (document.forms[FormName].elements[x].name == 'bill_state_or_province')
		{
				alert('Please choose your state or province\-\-or NOT LISTED\-\-and then try again.')
		}
        if (document.forms[FormName].elements[x].name == 'bill_postal_code')
		{
				alert('Please type your Zip\/Postal code and then try again.')
		}
        if (document.forms[FormName].elements[x].name == 'bill_country')
		{
				alert('Please choose your country\-\-or NOT LISTED\-\-and then try again.')
		}
        //if (document.forms[FormName].elements[x].name == 'bill_phone')
		//{
		//		alert('Please type the phone number and then try again.')
		//}
        if (document.forms[FormName].elements[x].name == 'bill_email')
		{
				alert('Please type your e-mail address and then try again.')
		}
        if (document.forms[FormName].elements[x].name == 'credit_card_type')
		{
				alert('Please choose your credit card type and then try again.')
		}
        if (document.forms[FormName].elements[x].name == 'credit_card_number')
		{
				alert('Please type your credit card number and then try again.')
		}
        if (document.forms[FormName].elements[x].name == 'expire_month')
		{
			 alert('Please choose your expire month and then try again.')
		}
        if (document.forms[FormName].elements[x].name == 'expire_year')
		{
				alert('Please choose your expire year and then try again.')
		}
        if (document.forms[FormName].elements[x].name == 'charge_total')
		{
				alert('Please choose, or type, your donation amount and then try again.')
		}
        if (document.forms[FormName].elements[x].name == 'charge_total')
		{
				alert('Please choose, or type, your donation amount and then try again.')
		}		
		
        document.forms[FormName].elements[x].focus();
        FormOk = false;
     }
	 else // the field is not empty but needs further checking -------------------------------
	 {
		if (document.forms[FormName].elements[x].name == 'bill_email')
		{
		        FormOk = IsEmailValid(FormName,document.forms[FormName].elements[x].name)
		}
		if (document.forms[FormName].elements[x].name == 'credit_card_number')
		{
		       FormOk = isValidCreditCard(FormName,document.forms[FormName].elements['credit_card_type'].value,document.forms[FormName].elements['credit_card_number'].value)
		} 
		if (document.forms[FormName].elements['chk_charge_total_other'].checked)
		{
	     if (document.forms[FormName].elements['other_textbox'].value == '')
			{
			  alert('Please type in a donation amount between 1 and 1000 dollars. \nJust the number with no dollar sign, please.')
			  FormOk = false;
			}
			else
			{
			  FormOk = ValidNumericLength(FormName,document.forms[FormName].elements['other_textbox'].name);
			}
		}
		
		if(document.forms[FormName].elements[x].name == 'prayer_intention') {
			if(document.forms[FormName].elements[x].value == '' && document.getElementById('sendToPrayerIntention').checked == true) {
				alert('Please enter a prayer intention.');	
			    FormOk = false;
			}
		}
	 }
     x ++
   }
return FormOk
}
//**************END FUNCTION****************************

/********Validates Length and IsNumeric of other_textbox********************************
DESCRIPTION: Validates other_textbox textbox for length and custom IsNumber() function below
			Has to be a number between 1 and 1000.
PARAMETERS:
   FormName - form name 
   ElemName - form element name


RETURNS:
   True if valid, otherwise false.
*************************************************/
function ValidNumericLength(FormName,ElemName) {
var iTextBox = document.forms[FormName].elements[ElemName].value; //value of other_textbox text box
if (isNumber(iTextBox)==false)
  {
    alert("Error... not a number! \nPlease type in a donation amount between 10 and 1000 dollars. \nJust the number with no dollar sign, please.");
    return false;
  }
else
  {
	  if (parseInt(iTextBox) < 1 || parseInt(iTextBox) > 1000)
	  {
		alert("Please type in a donation amount between 1 and 1000 dollars. \nJust a whole number with no dollar sign, please.");
        document.forms[FormName].elements[ElemName].value=parseInt(iTextBox); //(Sender or Recipient) e-mail text box excised of all spaces
		return false;
	  }
  }
  
  return true;
}
//**************END FUNCTION****************************


/********Donation Functions********************************
DESCRIPTION: Manipulates donation checkboxes changing checked or unchecked, disabiling and 
			 setting value of hidden charge_total element.
    	
TECH NOTES:
     //Set Custom Amount starts the checking of the form data
	 
PARAMETERS:
   

RETURNS:
   
*************************************************/
function selectChargeTotal(amount,item, formname)
{
	clearChecks(formname);
	item.checked = true;	
	document.getElementById('other_textbox').value = "";
	var numOfCandles = document.getElementById('NumOfCandles').value;
	document.getElementById('donatecharge_total').value = amount;
	showHideStatueOption();
}

function showHideStatueOption() {
	var donateAmount = document.getElementById('donatecharge_total').value;
	var donateOptions = document.getElementById('gift_type_id').value;
	if(donateAmount >= 35 && donateOptions=='Shrine Society' ) {
		document.getElementById('statueRow').style.display='inline';
		document.getElementById('statue').checked = true;		
	}
	else {		
		document.getElementById('statueRow').style.display='none';
		document.getElementById('statue').checked=false;			
	}
}

function getCandlesTotal(formname) {
	var numOfCandles = document.getElementById('NumOfCandles').value;
	document.getElementById('candlescharge_total').value = numOfCandles * 5;
}


function getMassesTotal(formname) {
	var numOfMasses = document.getElementById('NumOfMasses').value;
	document.getElementById('massescharge_total').value = numOfMasses * 10;
}


function setChargeTotal(formname)
{
	document.getElementById('donatecharge_total').value = document.getElementById('other_textbox').value;
}

function clickOtherCheckbox(formname)
{
	clearChecks(formname);
	document.getElementById('donatecharge_total').value="0";
	document.getElementById('other_textbox').value = "";
	document.getElementById('other_textbox').disabled = false;
	document.getElementById('chk_charge_total_other').checked = true;
	showHideStatueOption();
}

function clearChecks(formname)
{

	if(document.getElementById('chk_charge_total_0')) {
		document.getElementById('chk_charge_total_0').checked = 0;	
	}

	document.getElementById('chk_charge_total_10').checked = 0;
	document.getElementById('chk_charge_total_25').checked = 0;
	document.getElementById('chk_charge_total_35').checked = 0;
	document.getElementById('chk_charge_total_50').checked = 0;
	document.getElementById('chk_charge_total_75').checked = 0;
	document.getElementById('chk_charge_total_100').checked = 0;
	document.getElementById('chk_charge_total_250').checked = 0;
	document.getElementById('chk_charge_total_500').checked = 0;
	document.getElementById('chk_charge_total_other').checked = 0;
	document.getElementById('other_textbox').disabled = 0;
	
}
//**************END FUNCTIONS****************************

//************Trim functions**************************
// Description: Trim functions trim strings of spaces
//     on (1)both ends, (2)left, (3)right and (4)All spaces 
//     whether on the ends or between characters in the string. 
//     
// Returns:String
//
// Trim(i_value);
function Trim(String) {
 if (String == null) {
    return (false);
   }
    return String.replace(/(^\s+)|(\s+$)/g,"");
   }
// TrimAllDashes(i_value);
function TrimAllDashes(str) {
 if (str == null) {
    return (false);
   }
    return str.replace(/(\-+)/g,"");
   }

// TrimAll(i_value);
function TrimAll(str) {
 if (str == null) {
    return (false);
   }
    return str.replace(/(\s+)/g,"");
   }

// TrimLeft(i_value);
function trimLeft(str) {
	// remove all spaces on left
	var newstr = str.replace(/[ ]*/,"");
	return (newstr);
}

// TrimRight(i_value);
function trimRight(str) 
{
	// remove all spaces on right
	var newstr = str.replace(/[ ]*$/,"");
	return (newstr);
}

// TrimBOTH(i_value);   !!!// Trim(i_value); above is better!!!
function trimBoth(str) {
	// reomve all spaces on both side
	var newstr = trimRight(trimLeft(str));
	return (newstr);
}

//**************END FUNCTION****************************

// EMAIL VALIDATION
function IsEmailValid(FormName,ElemName)
{
var EmailOk  = true;
var strTextBox = document.forms[FormName].elements[ElemName].value; //value of Sender or Recipient text box

//These "regexpFilter" variables use the RegExp object and its functions to find patterns
//created with a sequence of characters and symbols
//var regexpFilter = /^.+@.+\..{2,4}$/;
				//   /............/ creates a new RegExp object
			 	//  ^.  -Match Any character at beginning of string
            	//  @.  -An ampersand followed by any character
            	//  \.  -A period (.)
            	//  .{2,4}$  -At least two characters but no more than four at the end of the string

var regexpFilter = /^([a-zA-Z0-9_\-])+(\.([a-zA-Z0-9_\-])+)*@((\[(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))\]))|((([a-zA-Z0-9])+(([\-])+([a-zA-Z0-9])+)*\.)+([a-zA-Z])+(([\-])+([a-zA-Z0-9])+)*))$/;
				// see http://regexlib.com/RETester.aspx?regexp_id=284
				
strTextBox=TrimAll(strTextBox); //value of Sender e-mail or Recipient e-mail text box excised of all spaces
document.forms[FormName].elements[ElemName].value=strTextBox; //(Sender or Recipient) e-mail text box excised of all spaces
//strTextBox=dropSpaces(strTextBox)
// Checks for the general format of e-mail addresses (x@x.xx or x@x.xxx)
if (!regexpFilter.test(strTextBox)) 
	{
      alert('Please enter a valid e-mail address. \n\nExample: stanthony@americancatholic.org')
      EmailOk = false;
	}
return (EmailOk);
}
//**************END FUNCTION****************************
// -->

/********Validation functions********************************
DESCRIPTION: validates credit cards
    	
TECH NOTES:
-----------------------------------------------------------------------------
Matches major credit cards including: 
Visa (length 16, prefix 4), 
Mastercard (length 16, prefix 51-55), 
Discover (length 16, prefix 6011), 
American Express (length 15, prefix 34 or 37). 
All 16 digit formats accept optional hyphens (-) between each group of four digits. 
-----------------------------------------------------------------------------

PARAMETERS:

RETURNS:
   True if valid, otherwise false.
   
*************************************************/
function isValidCreditCard(FormName, type, ccnum) {
  ccnum=TrimAll(ccnum); //value of credit_card_number text box excised of all spaces
  ccnum=TrimAllDashes(ccnum); //value of credit_card_number text box excised of all dashes
  document.forms[FormName].elements['credit_card_number'].value=ccnum; //repopulate credit_card_number text box excised of all spaces
   if (type == "Visa") {
      // Visa: length 16, prefix 4, dashes optional.
      var creditcardPattern = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "MC") {
      // Mastercard: length 16, prefix 51-55, dashes optional.
      var creditcardPattern = /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "Disc") {
      // Discover: length 16, prefix 6011, dashes optional.
      var creditcardPattern = /^6011-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "AmEx") {
      // American Express: length 15, prefix 34 or 37.
      var creditcardPattern = /^3[4,7]\d{13}$/;
   } else if (type == "Diners") {
      // Diners: length 14, prefix 30, 36, or 38.
      var creditcardPattern = /^3[0,6,8]\d{12}$/;
   }

   if (!creditcardPattern.test(ccnum)) 
     {
    alert("Error... credit card number is invalid! \nPlease try again.")
    return false;
     }
   else if (isCardNumValid(ccnum)) 
     {
    alert("Checksum Error...  credit card number is invalid! \nPlease try again.")
    return false;
     }
   else
	 {
    return true;
	 }
   // Checksum ("Mod 10")
   // Add even digits in even length strings or odd digits in odd length strings.
   //var checksum = 0;
  // for (var i=(2-(ccnum.length % 2)); i<=ccnum.length; i+=2) {
  //    checksum += parseInt(ccnum.charAt(i-1));
  // }
   // Analyze odd digits in even length strings or even digits in odd length strings.
  // for (var i=(ccnum.length % 2) + 1; i<ccnum.length; i+=2) {
  //    var digit = parseInt(ccnum.charAt(i-1)) * 2;
  //    if (digit < 10) { checksum += digit; } else { checksum += (digit-9); }
  // }
  // if ((checksum % 10) == 0) return true; else return false;
}

function isCardNumValid(num) {
	var num1, num2, tempNum;
	if (!isNumber(num)) {
		return true;
	}
	num1 = ""
   // Add even digits in even length strings or odd digits in odd length strings.
	if (!(num.length%2==0)) {
		for(var j=0; j < num.length; j++) {
			if ((j+1)%2==0){
				tempNum = 2 * num.charAt(j);
			}
			else {
				tempNum = 1 * num.charAt(j);
			}
			num1 = num1 + tempNum.toString();
		}
	}
	else{
		for(var j=0; j < num.length; j++){
			if ((j+1)%2==0){
				tempNum = 1 * num.charAt(j);
			}
			else{
				tempNum = 2 * num.charAt(j);
			}
			num1 = num1 + tempNum.toString();
		}
	}
	num2 = 0;
	for (var j = 0; j < num1.length; j++) {
		num2 = num2 + parseInt(num1.charAt(j));
	}
	if (num2%10==0) {
		return false;
	}
	else {
		return true;
	}
}

function isNumber(value) {
	for (var i=0; i < value.length; i++) {
		a = parseInt(value.charAt(i));
		if (isNaN(a)) {
			return false;			
			break;
		}
	}
	return true;
}


// +------------------------------------------------------------+
// "updateClose" Script begins
<!--
var timerOnLoad = '';
var agent = navigator.userAgent;

function updateBrowser() {
		if (agent.indexOf("Netscape6")!= -1) {
			window.document.location.reload()
		}
		else if (agent.indexOf("MSIE")!= -1) {
			window.navigate(window.opener.document.location.href);
		}
		else if (agent.indexOf("Mozilla/4")!= -1) {
			
			window.document.location.reload()
		}
		else { 
			window.document.location.reload()
		}
    
}
//-->

// Script Ends -->
// +------------------------------------------------------------+

/********   END  functions********************************/
