
var seasonPrice = 0;
var theTotal = 0;


function changeIt(textHere)
  {
  var seasonSection = textHere;
  window.document.seasonForm.perSeason.value = seasonSection;
  }

function totalIt()
 {
 window.document.seasonForm.seasonTotal.value = window.document.seasonForm.ticketQuantity.value * window.document.seasonForm.perSeason.value;
 window.document.seasonForm.Extra_SeasonopenerTotal.value = window.document.seasonForm.Extra_Seasonopener.value * window.document.seasonForm.ExtraPriceSeasonopener.value;
 window.document.seasonForm.Extra_NutcrackerTotal.value = window.document.seasonForm.Extra_Nutcracker.value * window.document.seasonForm.ExtraPriceNutcracker.value;
 window.document.seasonForm.Extra_lasylphideTotal.value = window.document.seasonForm.Extra_lasylphide.value * window.document.seasonForm.ExtraPricelasylphide.value;
 window.document.seasonForm.Extra_studiotheaterTotal.value = window.document.seasonForm.Extra_studiotheater.value * 45;
 window.document.seasonForm.Extra_magicfluteTotal.value = window.document.seasonForm.Extra_magicflute.value * window.document.seasonForm.ExtraPricemagicflute.value;
 window.document.seasonForm.Extra_NAOTDTotal.value = window.document.seasonForm.Extra_NAOTD.value * 14;
 window.document.seasonForm.quietTotal.value = window.document.seasonForm.quietQuantity.value * 20;
 window.document.seasonForm.springTotal.value = window.document.seasonForm.springQuantity.value * 15;
 window.document.seasonForm.grandTotal.value = (window.document.seasonForm.seasonTotal.value - 0) + (window.document.seasonForm.Extra_SeasonopenerTotal.value - 0) + (window.document.seasonForm.Extra_NutcrackerTotal.value - 0) + (window.document.seasonForm.Extra_lasylphideTotal.value - 0) + (window.document.seasonForm.Extra_studiotheaterTotal.value - 0) + (window.document.seasonForm.Extra_magicfluteTotal.value - 0) + (window.document.seasonForm.Extra_NAOTDTotal.value - 0) + (window.document.seasonForm.quietTotal.value - 0) + (window.document.seasonForm.springTotal.value - 0) + (window.document.seasonForm.Partnership.value - 0) + (window.document.seasonForm.Donation.value - 0) + 5;
 window.document.seasonForm.x_Amount.value = Math.round((window.document.seasonForm.grandTotal.value - 0) / (window.document.seasonForm.Payments.value - 0));
 // window.document.seasonForm.AmtLeftToPay.value = (window.document.seasonForm.grandTotal.value - 0) - (window.document.seasonForm.x_Amount.value - 0);
 }

function multIt(Quantity,Price,Result)
{
  Result = (Quantity - 0) * (Price - 0);
  totalIt();
}

function payPlan(FullAmount,PaymentPlan)
{
  window.document.seasonForm.x_amount.value = (FullAmount - 0) / (PaymentPlan - 0);
}

function setDonation(donation_level)
{
  var theDonation = 0;

  if (donation_level == "None")
  {
   theDonation = 0 - 0;
   window.document.seasonForm.Partnership.value = theDonation;
  }

  if (donation_level == "Premiere")
  {
   theDonation = 5000 - 0;
   window.document.seasonForm.Partnership.value = theDonation;
  }

  if (donation_level == "Principal")
  {
   theDonation = 3500 - 0;
window.document.seasonForm.Partnership.value = theDonation;
  }

  if (donation_level == "Preferred")
  {
   theDonation = 2500 - 0;
   window.document.seasonForm.Partnership.value = theDonation;
  }

  if (donation_level == "Partner")
  {
   theDonation = 1500 - 0;
   window.document.seasonForm.Partnership.value = theDonation;
  }
  
  if (donation_level == "Corps")
  {
   theDonation = 1000 - 0;
   window.document.seasonForm.Partnership.value = theDonation;
  }
  
  if (donation_level == "Enthusiast")
  {
   theDonation = 750 - 0;
   window.document.seasonForm.Partnership.value = theDonation;
  }
  
  if (donation_level == "Contributor")
  {
   theDonation = 500 - 0;
   window.document.seasonForm.Partnership.value = theDonation;
  }
  
  if (donation_level == "Supporter")
  {
   theDonation = 250 - 0;
   window.document.seasonForm.Partnership.value = theDonation;
  }
  
  if (donation_level == "Patron")
  {
   theDonation = 100 - 0;
   window.document.seasonForm.Partnership.value = theDonation;
  }
  
  if (donation_level == "Friend")
  {
   theDonation = 50 - 0;
   window.document.seasonForm.Partnership.value = theDonation;
  }
  
  if (donation_level == "Crew")
  {
   theDonation = 200 - 0;
   window.document.seasonForm.Partnership.value = theDonation;
  }
  
  if (donation_level == "Petite")
  {
   theDonation = 100 - 0;
   window.document.seasonForm.Partnership.value = theDonation;
  }
  
  totalIt();

}


function setPrice(season,price,studiotheater,check,Shows,nutcracker,extraticket)
  {
	window.document.seasonForm.perSeason.value = season;
	window.document.seasonForm.ExtraPriceSeasonopener.value = price;
	window.document.seasonForm.ExtraPricemagicflute.value = price;
	window.document.seasonForm.ExtraPricelasylphide.value = price;
	window.document.seasonForm.ExtraPriceNutcracker.value = nutcracker;
	window.document.seasonForm.ExtraTicket.value = season;
	totalIt();
	
	switch (Shows)
    {
	 case 6 :
	 window.document.seasonForm.ChooseXShows.value = "Please choose 3 shows at Long Center + Studio Theater Project";
	 window.document.seasonForm.SeasonPackage.value = 4;
	 window.document.seasonForm.S_studiotheater.disabled = false;
	 window.document.seasonForm.S_NAOTD.disabled = true;
	 break;
     case 5 :
	 window.document.seasonForm.ChooseXShows.value = "Please choose 2 shows at the Long Center + Not Afraid of the Dark";
	 window.document.seasonForm.SeasonPackage.value = 3;
	 window.document.seasonForm.S_studiotheater.disabled = true;
	 window.document.seasonForm.S_NAOTD.disabled = false;
	 break;
     case 4 :
	 window.document.seasonForm.ChooseXShows.value = "You will attend all 4 shows at Long Center + Studio Theater Project";
	 window.document.seasonForm.SeasonPackage.value = 5;
	 window.document.seasonForm.S_studiotheater.disabled = false;
	 window.document.seasonForm.S_NAOTD.disabled = true;
	 break;
     case 3 :
	 window.document.seasonForm.ChooseXShows.value = "You will attend all 4 shows at Long Center";
	 window.document.seasonForm.SeasonPackage.value = 4;
	 window.document.seasonForm.S_studiotheater.disabled = true;
	 window.document.seasonForm.S_NAOTD.disabled = true;
	 break;
	 case 2 :
	 window.document.seasonForm.ChooseXShows.value = "Please choose 3 shows at Long Center";
	 window.document.seasonForm.SeasonPackage.value = 3;
	 window.document.seasonForm.S_studiotheater.disabled = true;
	 window.document.seasonForm.S_NAOTD.disabled = true;
	 break;
     default :
 	 window.document.seasonForm.ChooseXShows.value = ""; 
    } 
	
	if (studiotheater != 1)
	 {
	 window.document.seasonForm.studiotheaterdate.options[0].value = "Omit";
	 window.document.seasonForm.studiotheaterdate.options[0].text = "Omit This Option";
	 }
	else
	 {
	 window.document.seasonForm.studiotheaterdate.options[0].value = "";
	 window.document.seasonForm.studiotheaterdate.options[0].text = "-- Select One --";
	 }
	 
	 if (check == 1)
	 {
	 window.document.seasonForm.S_Seasonopener.checked = true;
	 window.document.seasonForm.S_Nutcracker.checked = true;
	 window.document.seasonForm.S_lasylphide.checked = true;
	 window.document.seasonForm.S_studiotheater.checked = true;
	 window.document.seasonForm.S_magicflute.checked = true;
     window.document.seasonForm.S_NAOTD.checked = false;
	 }
	 else if (check == 2)
	 {
	 window.document.seasonForm.S_Seasonopener.checked = true;
	 window.document.seasonForm.S_Nutcracker.checked = true;
	 window.document.seasonForm.S_lasylphide.checked = true;
	 window.document.seasonForm.S_studiotheater.checked = false;
	 window.document.seasonForm.S_magicflute.checked = true;
     window.document.seasonForm.S_NAOTD.checked = false;
	 }
	 else if (check == 3)
	 {
	 window.document.seasonForm.S_Seasonopener.checked = false;
	 window.document.seasonForm.S_Nutcracker.checked = false;
	 window.document.seasonForm.S_lasylphide.checked = false;
	 window.document.seasonForm.S_studiotheater.checked = false;
	 window.document.seasonForm.S_magicflute.checked = false;
     window.document.seasonForm.S_NAOTD.checked = true;
	 }
	 else
	 {
	 window.document.seasonForm.S_Seasonopener.checked = false;
	 window.document.seasonForm.S_Nutcracker.checked = false;
	 window.document.seasonForm.S_lasylphide.checked = false;
	 window.document.seasonForm.S_studiotheater.checked = false;
	 window.document.seasonForm.S_magicflute.checked = false;
     window.document.seasonForm.S_NAOTD.checked = false;
	 }
  } 


function submitForm()
{
	var NewCount = 0;
 
	if (document.seasonForm.S_Seasonopener.checked)
	 {
	 NewCount = NewCount + 1;
	 }
	 
	if (document.seasonForm.S_Nutcracker.checked)
	 {
	 NewCount = NewCount + 1;
	 }
	
	if (document.seasonForm.S_lasylphide.checked)
	 {
	 NewCount = NewCount + 1;
	 }
	 
	if (document.seasonForm.S_studiotheater.checked)
	 {
	 NewCount = NewCount + 1;
	 }
	
	if (document.seasonForm.S_magicflute.checked)
	 {
	 NewCount = NewCount + 1;
	 }
	 
	if (document.seasonForm.S_NAOTD.checked)
	 {
	 NewCount = NewCount + 1;
	 }
	document.seasonForm.ShowsChecked.value = NewCount;

	if (window.document.seasonForm.DaySelection.value == "")
	 {
	  alert("Please choose a day of the week for your tickets.");
	  window.document.seasonForm.DaySelection.focus();
	  return false;
	 }
	 
	if (window.document.seasonForm.NewVsRenew.value == "")
	 {
	  alert("Please choose if new or renewing.");
	  window.document.seasonForm.NewVsRenew.focus();
	  return false;
	 }
	 
	if (window.document.seasonForm.x_first_name.value == "")
	{
	  alert("Please enter your first name.");
	  window.document.seasonForm.x_first_name.focus();
	  return false;
	}

	if (window.document.seasonForm.x_last_name.value == "")
	{
	  alert("Please enter your last name.");
	  window.document.seasonForm.x_last_name.focus();
	  return false;
	}

	if (window.document.seasonForm.x_address.value == "")
	{
	  alert("Please enter your address.");
	  window.document.seasonForm.x_address.focus();
	  return false;
	}

	if (window.document.seasonForm.x_city.value == "")
	{
	  alert("Please enter your city.");
	  window.document.seasonForm.x_city.focus();
	  return false;
	}

	if (window.document.seasonForm.x_state.value == "")
	{
	  alert("Please enter your state.");
	  window.document.seasonForm.x_state.focus();
	  return false;
	}

	if (window.document.seasonForm.x_zip.value == "")
	{
	  alert("Please enter your zip code.");
	  window.document.seasonForm.x_zip.focus();
	  return false;
	}

	if (window.document.seasonForm.x_phone.value == "(512)")
	{
	  alert("Please enter your evening phone number.");
	  window.document.seasonForm.x_phone.focus();
	  return false;
	}

	if (window.document.seasonForm.DayPhone.value == "(512)")
	{
	  alert("Please enter your daytime phone number.");
	  window.document.seasonForm.DayPhone.focus();
	  return false;
	}

	if (window.document.seasonForm.x_email.value == "")
	{
	  alert("Please enter your email address.");
	  window.document.seasonForm.x_email.focus();
	  return false;
	}
	
	if (window.document.seasonForm.SeasonPackage.value == "")
	{
	  alert("Please choose a season package by clicking on the price of the package.");
	  window.document.seasonForm.DaySelection.focus();
	  return false;
	}
	
	if (((window.document.seasonForm.SeasonPackage.value - 0) != (window.document.seasonForm.ShowsChecked.value - 0)) && ((window.document.seasonForm.ChooseXShows.value == "Please choose four ballets") || (window.document.seasonForm.ChooseXShows.value == "Please choose three ballets")))
	{
	  alert("Please select correct number of performances for selected series.");
	  window.document.seasonForm.DaySelection.focus();
	  return false;
	}
	
	if ((window.document.seasonForm.S_studiotheater.checked == true) && (window.document.seasonForm.studiotheaterdate.value == ""))
	{
	  alert("Please select a date for Studio Theater");
	  window.document.seasonForm.studiotheaterdate.focus();
	  return false;
	}
	
	if ((window.document.seasonForm.S_NAOTD.checked == true) && (window.document.seasonForm.NAOTDdate.value == ""))
	{
	  alert("Please select a date for Not Afraid of the Dark");
	  window.document.seasonForm.NAOTDdate.focus();
	  return false;
	}
	
	if (document.seasonForm.ShowsChecked.value != window.document.seasonForm.SeasonPackage.value)
	{
	  alert("Please select correct number of shows for your series.");
	  window.document.seasonForm.S_Seasonopener.focus();
	  return false;
	}
	
	if (window.document.seasonForm.perseason.value == 0)
	{
	  alert("Please select a season ticket package");
	  window.document.seasonForm.DaySelection.focus();
	  return false;
	}	

	if (window.document.seasonForm.security_code.value == "")
	{
	  alert("Please enter the 5 digit security code before proceeding!");
	  window.document.seasonForm.security_code.focus();
	  return false;
	}
}

//function not used
function submitIt(seasonForm) 
{	
	if (window.document.seasonForm.DaySelection.value == "")
	 {
	  alert("Please choose a day.");
	  window.document.seasonForm.DaySelection.focus();
	  return false;
	 }
	 
	if (window.document.seasonForm.NewVsRenew.selectedIndex == 0)
	 {
	  alert("Please choose if new or renewing.");
	  window.document.seasonForm.NewVsRenew.focus();
	  return false;
	 }
	
	if (window.document.seasonForm.seatingSelection.value == "")
	 {
	  alert("Please choose a section.");
	  window.document.seasonForm.seatingSelection.focus();
	  return false;
	 }

	if (window.document.seasonForm.ticketQuantity.value < 1)
	 {
	  alert("Please enter a valid number of tickets.");
	  window.document.seasonForm.ticketQuantity.focus();
	  return false;
	 }

	if (window.document.seasonForm.x_first_name.value == "")
	 {
	  alert("Please enter your first name");
	  window.document.seasonForm.x_first_name.focus();
	  return false;
	 }

	if (window.document.seasonForm.x_last_name.value == "")
	 {
	  alert("Please enter your last name.");
	  window.document.seasonForm.x_last_name.focus();
	  return false;
	 }

	if (window.document.seasonForm.x_address.value == "")
	 {
	  alert("Please enter your address.");
	  window.document.seasonForm.x_address.focus();
	  return false;
	 }

	if (window.document.seasonForm.x_city.value == "")
	 {
	  alert("Please enter your city.");
	  window.document.seasonForm.x_city.focus();
	  return false;
	 }

	if (window.document.seasonForm.x_state.value == "")
	 {
	  alert("Please enter your state.");
	  window.document.seasonForm.x_state.focus();
	  return false;
	 }

	if (window.document.seasonForm.x_zip.value == "")
	 {
	  alert("Please enter your zip code.");
	  window.document.seasonForm.x_zip.focus();
	  return false;
	 }

	if (window.document.seasonForm.x_phone.value == "")
	 {
	  alert("Please enter your evening phone number.");
	  window.document.seasonForm.x_phone.focus();
	  return false;
	 }

	if (window.document.seasonForm.x_email.value == "")
	 {
	  alert("An email address is required to receive a receipt.");
	  window.document.seasonForm.x_email.focus();
	  return false;
	 }
	
	if (window.document.seasonForm.security_code.value == "")
	{
	  alert("Enter the 5 digit security code before proceeding!");
	  window.document.seasonForm.security_code.focus();
	  return false;
	}

	return true;
}
