
var eleTicketType; 
var eleDescription;
var eleNumberOfTickets;
   
function purchaseOnline()
{
    var validated = "";
    validated = validateForm();
        
    if(validated == 0)
    {
        //alert(eleTicketType.options[eleTicketType.selectedIndex].value);
        //alert(eleDescription.value);
               
	if(eleTicketType.selectedIndex == 1 || eleTicketType.selectedIndex == 3)       
	{
		window.open('/sim.php?amount='+ (eleTicketType.options[eleTicketType.selectedIndex].value * eleNumberOfTickets.options[eleNumberOfTickets.selectedIndex].value)  +'&description=Ticket Type: '+eleTicketType.options[eleTicketType.selectedIndex].text+', Number of Tickets: '+eleNumberOfTickets.options[eleNumberOfTickets.selectedIndex].value+', Attendee Name(s): '+ eleDescription.value);
	}
	else
	{
		//alert("test");	
		window.open('/sim.php?amount='+ eleTicketType.options[eleTicketType.selectedIndex].value  +'&description=Ticket Type: '+eleTicketType.options[eleTicketType.selectedIndex].text+', Attendee Name(s): '+ eleDescription.value);
	}
 
    }   
}


function validateForm()
{
   var validated = 0;
   eleTicketType = document.getElementById('amount');
   eleDescription = document.getElementById('description');
   eleNumberOfTickets = document.getElementById('NumberOfTickets');

   //alert(eleTicketType.selectedIndex);
   //alert(eleTicketType.options[eleTicketType.selectedIndex].value);
   //alert(eleDescription.value);
   
   $("#error").html("");

   if(eleTicketType.selectedIndex == 0)
   {
        validated++;
        $("#error").html("To use our online form please select a ticket type.<br><br>");
        $("#tickettypenote").html("*");   
   }
 
   if(eleTicketType.selectedIndex == 1 || eleTicketType.selectedIndex == 3)
   {
        if(eleNumberOfTickets.selectedIndex == 0)
	{
		validated++;
		$("#error").html("Please select the # of tickets to purhchase.<br><br>");
	        $("#ticketnumber").html("*");
	}
        
        
   }
   
   return validated;  
 
}
