var ShowMeSeasonMsg = "Show me the subscription package";
var BuyStockingStufferMsg = "Buy Winter Bargain Hunter Special Now";
var BuyTicNowMsg = "Buy tickets now for this concert only";

//--------------------------------
// HelloWorld - Self explanatory
//--------------------------------
function HelloWorld()
{
  alert ('Hello World');
}

//--------------------------------
// gotoSubscribePage - Takes us to the subscription page
//--------------------------------
function gotoSubscribePage()
{
  window.location="index.php?page=box-office_1112";
}

//--------------------------------
// TooLate - Display pop-up for condition where we are too close to the performance
//           time to accept online orders
//--------------------------------
function TooLate()
{
alert("We are no longer accepting online orders for this concert.<br />Please purchase tickets at the box office before the performance.<br />The box office opens at 6:30pm.");
}

//--------------------------------
// SoldOut - Display pop-up for a sold-out concert
//           This is in response to click on "Buy tickets now for this concert only"
//--------------------------------
function SoldOut()
{
alert("Online tickets for this concert have sold out, but tickets may be available from the Corning Info Center.<br />Please call 1.866.463.6264 for more information.");
}

//--------------------------------
// BuyNowButtons - Buy now buttons for a concert
//--------------------------------
function BuyNowButtons(prmSoldOut, prmTooLate, prmItemName, prmItemNumber, prmItemPrice)
{
// If concert is sold out
// then
//   connect Sold Out message with button click
// else if too close to concert start time
// then
//   connect Too Late message with button click
// else
//   connect PayPal with button click

	if (prmSoldOut)
  {
		var SoldOutMsg = "Online tickets for this concert have sold out, but tickets may be available on a wait list basis the night of the performance.  We expect some empty seats as not all of our season subscribers attend every concert.<br />The waiting list will begin when the box office opens at 6:30.<br />Tickets are $" + prmItemPrice + ". Cash or check only please.";
    document.getElementsByTagName('span')['BuyNowErrorMsg'].innerHTML = SoldOutMsg;
  }
  else if (prmTooLate)
  {
    document.getElementsByTagName('span')['BuyNowErrorMsg'].innerHTML = "We are no longer accepting online orders for this concert.<br />Please purchase tickets at the box office before the performance.<br />The box office opens at 6:30pm.";
  }
	else
  {
		document.write('<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" name="frmPayPal">');
		document.write('<input type="hidden" name="add" value="1">');
		document.write('<input type="hidden" name="cmd" value="_cart">');
		document.write('<input type="hidden" name="business" value="paypal@corningcivicmusic.org">');
		document.write('<input type="hidden" name="item_name" value="'  + prmItemName + '">');
		document.write('<input type="hidden" name="item_number" value="' + prmItemNumber + '">');
		document.write('<input type="hidden" name="no_shipping" value="2">');
		document.write('<input type="hidden" name="no_note" value="1">');
		document.write('<input type="hidden" name="currency_code" value="USD">');
		document.write('<input type="hidden" name="return" value="http://www.corningcivicmusic.org">');
		document.write('<input type="hidden" name="cancel_return" value="http://www.corningcivicmusic.org">');
		document.write('<input type="hidden" name="amount" value="' + prmItemPrice + '">');
		document.write('<input type="hidden" name="shipping" value="0.00">');
		document.write('<input type="hidden" name="shipping2" value="0.00">');
		document.write('<input type="hidden" name="tax_x" value="0.00">');
		document.write('</form>');

		// Turn on Subscription button and link to subscripion page
	  document.getElementById("btnJoinNow").src="uploads/images/JoinNow.jpg";
	  document.getElementById("btnJoinNow").onclick=gotoSubscribePage;

		// Turn on buy single tickets button
		document.getElementById("btnBuyNow").src="uploads/images/BuyNow.jpg";
		document.getElementById("btnBuyNow").onclick=SubmitToPayPal;
  }

	return;
}

//--------------------------------
// SubmitToPayPal - Submit the single tickets form to PayPal
//--------------------------------
function SubmitToPayPal()
{
	document.frmPayPal.submit();
}

//--------------------------------
// BuyStockingStufferButton - Buy now button for Stocking Stuffer Promo
//--------------------------------
function BuyStockingStufferButton(prmItemName, prmItemNumber, prmItemPrice)
{
  document.write('<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">');
  document.write('<input type="submit" value="' + BuyStockingStufferMsg + '" class="BuyButtons"><br>');
  document.write('<input type="hidden" name="add" value="1">');
  document.write('<input type="hidden" name="cmd" value="_cart">');
  document.write('<input type="hidden" name="business" value="paypal@corningcivicmusic.org">');
  document.write('<input type="hidden" name="item_name" value="'  + prmItemName + '">');
  document.write('<input type="hidden" name="item_number" value="' + prmItemNumber + '">');
  document.write('<input type="hidden" name="no_shipping" value="2">');
  document.write('<input type="hidden" name="no_note" value="1">');
  document.write('<input type="hidden" name="currency_code" value="USD">');
  document.write('<input type="hidden" name="return" value="http://www.corningcivicmusic.org">');
  document.write('<input type="hidden" name="cancel_return" value="http://www.corningcivicmusic.org">');
  document.write('<input type="hidden" name="amount" value="' + prmItemPrice + '">');
  document.write('<input type="hidden" name="shipping" value="0.00">');
  document.write('<input type="hidden" name="shipping2" value="0.00">');
  document.write('<input type="hidden" name="tax_x" value="0.00">');
  document.write('</form>');
}

