var shows_replicated	= 1;
	var general_admission	= 20.00;
	var patron_admission	= 18.00;
	var total				= 0.00;
	
	$(function() {
		
		$('.patron-admission, .general-admission').change(function() {
			display_total();
		});
		
		$(".addnew").click(function () { 
			
			$('.datepicker').datepicker('destroy');
			
			display_total();
			
			shows_replicated++;
			
			var some_html	= $('#event-type').html();
			
			some_html		= some_html.replace('id="shows"', 'id="shows'+shows_replicated+'"');
			some_html		= some_html.replace('id="dp', 'id="dp'+shows_replicated);
			some_html		= some_html.replace('name="show[1]"', 'name="show['+shows_replicated+']"');
			some_html		= some_html.replace('name="general_admission_quantity_for_show[1]"', 'name="general_admission_quantity_for_show['+shows_replicated+']"');
			some_html		= some_html.replace('name="patron_quantity[1]"', 'name="patron_quantity['+shows_replicated+']"');
			some_html		= some_html.replace('name="show_date[1]"', 'name="show_date['+shows_replicated+']"');
			
			$('#form-seg').append('<table>'+some_html+'</table>');
			
			$('.patron-admission, .general-admission').change(function() {
				display_total();
			});
			
			$(".datepicker").datepicker();
		
		});
	});
	
	function display_total() {
		
		total	= 0.00;
		
		$('.general-admission').each(function() {
			
			var price 	= (isNaN(parseInt($(this).val())))? 0:parseInt($(this).val());
			total 		+=  price * general_admission;
			
		});
		$('.patron-admission').each(function() {
		
			var price 	= (isNaN(parseInt($(this).val())))? 0:parseInt($(this).val());
			total 		+= price * patron_admission;
			
		});
		
		$('#your-total').html('$'+total+'.00');
		
	}
	
$(document).ready(function() {

	$("#contact-me").validationEngine();

});
