// <!--

function CatName(theForm)
{
	theForm.Full_Name.value = theForm.first_name.value + " " + theForm.last_name.value;
}

function CalcTotal(theForm)
{
	var total, tmp, tickets, discouont;
	tickets = 0;
	discount = 0;
	total = 0;

        if(!(isFloat(theForm.Contribution.value)) && 
	   !(theForm.Contribution.value.length == "0"))
	{
	   alert("Sorry, " + theForm.Contribution.value + 
		" is not a number.  Please enter a Contribution " + 
		"amount. \nie. 100.00 (no comma\'s)");
	   theForm.Contribution.value = "";
	}

	total = theForm.Contribution.value;

        // *1 converts the string value to number.
	total = total.toString().replace(/\$|\,/g,'') *1;

// Start Subscriptions
     if(subscriptionOn) {
       if( !(isInteger(theForm.Adult_Tickets.value)) && 
	 !(theForm.Adult_Tickets.value.length == "0"))
	 {
	    alert("Sorry, " + theForm.Adult_Tickets.value + 
		" is not a number.  Please enter the number of " + 
		"tickets you would like to order.");
	    theForm.Adult_Tickets.value = "";
	 }
	 total = total+theForm.Adult_Tickets.value*adultPricesub*1;
	 tickets = 0 + tickets+theForm.Adult_Tickets.value*1;

       if( !(isInteger(theForm.Senior_Tickets.value)) && 
	 !(theForm.Senior_Tickets.value.length == "0"))
	 {
	    alert("Sorry, " + theForm.Senior_Tickets.value + 
		" is not a number.  Please enter the number of " + 
		"tickets you would like to order.");
	    theForm.Senior_Tickets.value = "";
 	 }
	 total = total+theForm.Senior_Tickets.value*seniorPricesub*1;
	 tickets = tickets+theForm.Senior_Tickets.value*1;

       if( !(isInteger(theForm.Student_Tickets.value)) && 
	 !(theForm.Student_Tickets.value.length == "0"))
	 {
	    alert("Sorry, " + theForm.Student_Tickets.value + 
		" is not a number.  Please enter the number of " + 
		"tickets you would like to order.");
	    theForm.Student_Tickets.value = "";
 	 }
	 total = total+theForm.Student_Tickets.value*studentPricesub*1;
	 tickets = tickets+theForm.Student_Tickets.value*1;       

     }

// Start Concert 1   
     if (todaysDate < concertDate1){   
       if( !(isInteger(theForm.Concert1_ADULT.value)) && 
	  !(theForm.Concert1_ADULT.value.length == "0"))
	  {
	     alert("Sorry, " + theForm.Concert1_ADULT.value + 
	  	" is not a number.  Please enter the number of " + 
	  	"tickets you would like to order.");
	     theForm.Concert1_ADULT.value = "";
	  }
	  total = total+theForm.Concert1_ADULT.value*adultPrice1 * 1;
	  tickets = tickets+theForm.Concert1_ADULT.value*1;

      if( !(isInteger(theForm.Concert1_SENIOR.value)) && 
	  !(theForm.Concert1_SENIOR.value.length == "0"))
	  {
	     alert("Sorry, " + theForm.Concert1_STUD_SENIOR.value+ 
		" is not a number.  Please enter the number of " + 
	  	"tickets you would like to order.");
	     theForm.Concert1_SENIOR.value = "";
	  }
	  total = total+theForm.Concert1_SENIOR.value*seniorPrice1 * 1;
	  tickets = tickets+theForm.Concert1_SENIOR.value*1;

      if( !(isInteger(theForm.Concert1_STUDENT.value)) && 
	  !(theForm.Concert1_STUDENT.value.length == "0"))
	  {
	     alert("Sorry, " + theForm.Concert1_STUDENT.value+ 
		" is not a number.  Please enter the number of " + 
	  	"tickets you would like to order.");
	     theForm.Concert1_STUDENT.value = "";
	  }
	  total = total+theForm.Concert1_STUDENT.value*studentPrice1 * 1;
	  tickets = tickets+theForm.Concert1_STUDENT.value*1;


     }
// End Concert 1

// Start Concert 2
    if (todaysDate < concertDate2){   
       if( !(isInteger(theForm.Concert2_ADULT.value)) && 
	  !(theForm.Concert2_ADULT.value.length == "0"))
	  {
	     alert("Sorry, " + theForm.Concert2_ADULT.value + 
		" is not a number.  Please enter the number of " + 
		"tickets you would like to order.");
             theForm.Concert2_ADULT.value = "";
	  }
	  total = total+theForm.Concert2_ADULT.value*adultPrice2*1;
	  tickets = tickets+theForm.Concert2_ADULT.value*1;

      if( !(isInteger(theForm.Concert2_SENIOR.value)) && 
	  !(theForm.Concert2_SENIOR.value.length == "0"))
	  {
	     alert("Sorry, " + theForm.Concert2_SENIOR.value+ 
		" is not a number.  Please enter the number of " + 
		"tickets you would like to order.");
	     theForm.Concert2_SENIOR.value = "";
	  }
	  total = total+theForm.Concert2_SENIOR.value*seniorPrice2*1;
	  tickets = tickets+theForm.Concert2_SENIOR.value*1;

      if( !(isInteger(theForm.Concert2_STUDENT.value)) && 
	  !(theForm.Concert2_STUDENT.value.length == "0"))
	  {
	     alert("Sorry, " + theForm.Concert2_STUDENT.value+ 
		" is not a number.  Please enter the number of " + 
		"tickets you would like to order.");
	     theForm.Concert2_STUDENT.value = "";
	  }
	  total = total+theForm.Concert2_STUDENT.value*studentPrice2*1;
	  tickets = tickets+theForm.Concert2_STUDENT.value*1;
    }
// End Conert 2

// Start Concert 3
     if (todaysDate < concertDate3){   
        if( !(isInteger(theForm.Concert3_ADULT.value)) && 
	    !(theForm.Concert3_ADULT.value.length == "0"))
	   {
	      alert("Sorry, " + theForm.Concert3_ADULT.value + 
		" is not a number.  Please enter the number of " + 
		"tickets you would like to order.");
	      theForm.Concert3_ADULT.value = "";
	   }
	   total = total+theForm.Concert3_ADULT.value*adultPrice3*1;
	   tickets = tickets+theForm.Concert3_ADULT.value*1;

        if( !(isInteger(theForm.Concert3_SENIOR.value)) && 
	    !(theForm.Concert3_SENIOR.value.length == "0"))
	   {
	      alert("Sorry, " + theForm.Concert3_SENIOR.value+ 
		" is not a number.  Please enter the number of " + 
		"tickets you would like to order.");
	      theForm.Concert3_SENIOR.value = "";
	   }
	   total = total+theForm.Concert3_SENIOR.value*seniorPrice3*1;
	   tickets = tickets+theForm.Concert3_SENIOR.value*1;

        if( !(isInteger(theForm.Concert3_STUDENT.value)) && 
	    !(theForm.Concert3_STUDENT.value.length == "0"))
	   {
	      alert("Sorry, " + theForm.Concert3_STUDENT.value+ 
		" is not a number.  Please enter the number of " + 
		"tickets you would like to order.");
	      theForm.Concert3_STUDENT.value = "";
	   }
	   total = total+theForm.Concert3_STUDENT.value*studentPrice3*1;
	   tickets = tickets+theForm.Concert3_STUDENT.value*1;

     }
// End Concert 3

// Start Concert 4
     if (todaysDate < concertDate4){   
       if( !(isInteger(theForm.Concert4_ADULT.value)) && 
	   !(theForm.Concert4_ADULT.value.length == "0"))
	   {
	      alert("Sorry, " + theForm.Concert4_ADULT.value + 
		" is not a number.  Please enter the number of " + 
		"tickets you would like to order.");
	      theForm.Concert4_ADULT.value = "";
	   }
	   total = total+theForm.Concert4_ADULT.value*adultPrice4*1;
	   tickets = tickets+theForm.Concert4_ADULT.value*1;

         if( !(isInteger(theForm.Concert4_SENIOR.value)) && 
	   !(theForm.Concert4_SENIOR.value.length == "0"))
	   {
	      alert("Sorry, " + theForm.Concert4_SENIOR.value+ 
		" is not a number.  Please enter the number of " + 
		"tickets you would like to order.");
	      theForm.Concert4_SENIOR.value = "";
	   }
	   total = total+theForm.Concert4_SENIOR.value*seniorPrice4*1;
	   tickets = tickets+theForm.Concert4_SENIOR.value*1;

         if( !(isInteger(theForm.Concert4_STUDENT.value)) && 
	   !(theForm.Concert4_STUDENT.value.length == "0"))
	   {
	      alert("Sorry, " + theForm.Concert4_STUDENT.value+ 
		" is not a number.  Please enter the number of " + 
		"tickets you would like to order.");
	      theForm.Concert4_STUDENT.value = "";
	   }
	   total = total+theForm.Concert4_STUDENT.value*studentPrice4*1;
	   tickets = tickets+theForm.Concert4_STUDENT.value*1;

     }
// End Concert 4

// Start Concert 5
     if (todaysDate < concertDate5){   
       if( !(isInteger(theForm.Concert5_ADULT.value)) && 
	   !(theForm.Concert5_ADULT.value.length == "0"))
	   {
	      alert("Sorry, " + theForm.Concert5_ADULT.value + 
		" is not a number.  Please enter the number of " + 
		"tickets you would like to order.");
	      theForm.Concert5_ADULT.value = "";
	   }
	   total = total+theForm.Concert5_ADULT.value*adultPrice4*1;
	   tickets = tickets+theForm.Concert5_ADULT.value*1;

         if( !(isInteger(theForm.Concert5_SENIOR.value)) && 
	   !(theForm.Concert5_SENIOR.value.length == "0"))
	   {
	      alert("Sorry, " + theForm.Concert5_SENIOR.value+ 
		" is not a number.  Please enter the number of " + 
		"tickets you would like to order.");
	      theForm.Concert5_SENIOR.value = "";
	   }
	   total = total+theForm.Concert5_SENIOR.value*seniorPrice4*1;
	   tickets = tickets+theForm.Concert5_SENIOR.value*1;

         if( !(isInteger(theForm.Concert5_STUDENT.value)) && 
	   !(theForm.Concert5_STUDENT.value.length == "0"))
	   {
	      alert("Sorry, " + theForm.Concert4_STUDENT.value+ 
		" is not a number.  Please enter the number of " + 
		"tickets you would like to order.");
	      theForm.Concert5_STUDENT.value = "";
	   }
	   total = total+theForm.Concert5_STUDENT.value*studentPrice4*1;
	   tickets = tickets+theForm.Concert5_STUDENT.value*1;

     }
// End Concert 5


	// IF njArts in ON AND the user checked the box,
	// calculate the discount per ticket
	// Sets the default to 0, if njArts=true 0 is overwritten
	theForm.TotalDiscount.value = 0;
	if (njArts){
	  if (theForm.Member.checked == true)
          {
	  discount = tickets * saveAmt * 1;  
	  total = total-discount;
	  theForm.TotalDiscount.value = formatCurrency(discount);
	  }
	}
	
	theForm.TotalTickets.value = tickets;
	theForm.TotalAmount.value = formatPayPal(total);
	theForm.TotalAmountDisplayed.value = formatCurrency(total);
return;
}

function formatCurrency(num) {
  num = num.toString().replace(/\$|\,/g,'');
  if(isNaN(num)) num = "0";
  cents = Math.floor((num*100+0.5)%100);
  num = Math.floor((num*100+0.5)/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 ('$' + num + '.' + cents);
}

function formatPayPal(num) {
  num = num.toString().replace(/\$|\,/g,'');
  if(isNaN(num)) num = "0";
  cents = Math.floor((num*100+0.5)%100);
  num = Math.floor((num*100+0.5)/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 (num + '.' + cents);
}

function formatfullDate(dateObj) {
dateObj =  new Date(dateObj);

var wday = days[dateObj.getDay() + 1]
var lmonth = months[dateObj.getMonth() + 1]
var date = dateObj.getDate()
var fyear = dateObj.getYear()
if (fyear < 2000)
fyear = fyear + 1900
document.write(wday + ", " + lmonth + " " + date + ", " + fyear);
}


function formatMDYDate(dateObj) {
dateObj =  new Date(dateObj);

var wday = days[dateObj.getDay() + 1]
var lmonth = dateObj.getMonth()+1
var date = dateObj.getDate()
var fyear = dateObj.getYear()
fyear = fyear % 2000
fyear = "0"+fyear
document.write(wday + ", " + lmonth + "/" + date + "/" + fyear);
}

// -->
