function isUSCurrency (sString) 
{
var M;

  M = sString.match(/^\d+(\.\d{2})?$/ );    
  if (!M) {
	  return false;
	}

return true;



}

function ValidateFormPage3(theForm)
{

var totalamt;
var contributeamount;
var numtickets;
var ticketamt;
var tributelevel;
var totalcontribution;

contributeamount=0.0;
numtickets=0;
ticketamt=0.0;
totalamt=0.0;
totalcontribution=0.0;
tributelevel=0.0;

if ( theForm.cantcome.checked && (!theForm.cantcome.disabled) ) {
	if (isUSCurrency(theForm.contributeamount.value)) {
		contributeamount=theForm.contributeamount.value
	}
	else {
		alert('Please enter a contribution amount');
		return false;
		}
  }
if ( !theForm.cantcome.checked ) {

	if (!(isWhitespace(theForm.contributeamount.value))  && (!theForm.contributeamount.disabled) ) {
		alert('Please check off the box that says you cannot come if you would like to make a contribution instead');
		return false;
	}
//	else {
//		alert('Please enter a contribution amount');
//		return false;
//		}
	else {
		theForm.contributeamount.value=0.0;
		}

  }  
 //alert(theForm.contributeamount.value);

if  ((!( isWhitespace(theForm.numtickets.value ))) &&  (!theForm.numtickets.disabled) ){ 
		if (!(isInteger(theForm.numtickets.value ))) {
			alert("Please enter the number of Gala tickets you would like to purchase");
			return(false);
			}
		else {
			ticketamt=theForm.numtickets.value * 180.00;
			}			
		}
else {
		theForm.numtickets.value=0;
	}

	if (isUSCurrency(theForm.tributelevel.value) || (isInteger(theForm.tributelevel.value )) ) {
		tributelevel=theForm.tributelevel.value
	}
	else {
		theForm.tributelevel.value=0.0;
//		alert('Please enter a tribute level');
//		return false;
		}
 

	if (isUSCurrency(theForm.totalcontribution.value) || (isInteger(theForm.totalcontribution.value )) ) {
		totalcontribution=theForm.totalcontribution.value;
		}
		
 
totalamt=parseFloat(ticketamt)+parseFloat(contributeamount)+parseFloat(tributelevel);

//alert('totalamt='+totalamt);

if (totalcontribution != 0.0 ) {
	if (parseFloat(totalcontribution)==parseFloat(totalamt) ){
			theForm.totalcontribution.value=totalcontribution;
			return true;
		}
	else {
		alert('Please make sure the total contribution amount is correct.');
		return false;
	}
}
else {
//alert('it is 0');
	totalcontribution=parseFloat(totalamt);
//alert('and now it it'+totalcontribution);	
	}

//alert('going to return');
//alert('and the value=' + parseFloat(totalcontribution));

	theForm.totalcontribution.value = parseFloat(totalcontribution);	
//	alert('totalcontr='+theForm.totalcontribution.value);
	return(true);		
}


function ValidateForm1(theForm)
{

	var extension;

 
  if ((theForm.firstname.value == "")|| (isblank(theForm.firstname.value)))
 {
   alert("Please enter your first name.");
    theForm.firstname.focus();
    return (false);
 }
 	
  if ((theForm.lastname.value == "")|| (isblank(theForm.lastname.value)))
 {
   alert("Please enter your last name.");
    theForm.lastname.focus();
    return (false);
 }
 

 
   if ((theForm.address1.value == "")|| (isblank(theForm.address1.value)))
 {
   alert("Please enter your address.");
    theForm.address1.focus();
    return (false);
 }
 
 if (theForm.address1.value.length <3)
 {
 	alert("Please enter your address.");
	theForm.address1.focus();
 	return (false);
 }
 
   if ((theForm.city.value == "") || (isblank(theForm.city.value)))
 {
   alert("Please enter your city.");
    theForm.city.focus();
    return (false);
 }
 
 if (theForm.city.value.length <3)
 {
 	alert("Please enter your city.");
	theForm.city.focus();
 	return (false);
 }
 
 
   if ((theForm.zip.value == "") || (isblank(theForm.zip.value)))
 {
   alert("Please enter your zip code.");
    theForm.zip.focus();
    return (false);
 }
 
 if (theForm.zip.value.length <5)
 {
 	alert("Please enter your zip.");
	theForm.zip.focus();
 	return (false);
 }


   s = theForm.zip;
  if (!( checkZIPCode (s,0))){
  		alert("Please enter a valid zip code.");    
  		theForm.zip.focus();
    	return false;
   		}


  s = theForm.phone; 
 	

// if (!( checkUSPhone (s,0))){
 // 		alert("Please enter a valid phone number.");    
 // 		theForm.phone.focus();
  //  	return false;
   //		}

//  else {
 // 	  if (isEmpty(s)) {
 // 		alert("Please enter a valid phone number.");    
 // 		theForm.phone.focus();
  //  	return false;
   //		}
   //	}
   	

   s = theForm.email.value;

  if (isEmpty(s)) {
 	alert("Please enter your email address.");
	theForm.email.focus();  
	return false;
  }
  
  else {
  	if (!(isEmail (s,0))){
  		alert("Please enter a valid email address.");    
  		theForm.email.focus();
    	return false;
   		}
   	}
   	

if ( theForm.donate.checked && (!theForm.donate.disabled) ) {	
	if ( theForm.anotherAmount.checked) {
		if (isUSCurrency(theForm.theotherAmount.value)) {
			amount=theForm.theotherAmount.value;
			if ( amount < 10.00 ) {
				alert('The mimumum donation is $10.00');
				return false;
				}
			}
		else {
			alert('Please enter a contribution amount');
			return false;
			}
		}

	else 
		{  /* checked a radio button? */
		var radioObj=theForm.amount;
		var amtSelected;
		var radioLength = radioObj.length;

/*	if(radioObj.checked) {
		alert('here1'+ radioObj.value);
		amtSelected=radioObj.value;
		}
	else {
		return ('gotothing');*/
		var gotAmt;
		gotAmt=false;
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				/*alert( 'here2'+radioObj[i].value);*/
				amtSelected=radioObj[i].value;
				gotAmt=true
				}
			}
		if (!gotAmt) {
			alert('Please select a donation amount');
			return(false);
			}
		}
   }

//if ( (theForm.membership.checked) && (!theForm.donate.disabled)) {
//	if (theForm.amount.value < 10.00) {
//		alert('We will be happy to let you know when membership priviledges are available but a minimun donation of $10.00 is needed');
//		return false;
//		}
//	}		

  return (true);
}

