jQuery('document').ready(function($){		

	$("#quantity").change(function(){
		var quantity=$(this).val();
		if(quantity > 0 )
		{
			var price=quantity*200;
			$("#price").val(price);
		}else{
			alert("QUANLITY INVALID");
			$("#quantity").val("1");
			$("#price").val("200");
		}
	});
	//console.log(js_data);
	$('.buy-tickets').click(function(){
		
	});
	
	
	$("#purchase_form").submit(function(){
		console.log($("#state").val());
			if($("#state").val() == "")
			{
				$("#ajax_message").html('<p class="error">Please select state.</p>');
				$("#state").focus();
				$("#state").select();
				return false;
			}
	       	var post_data=$(this).serialize();
          		$.ajax({
	        		type: 'POST',
	            	enctype: 'multipart/form-data',
	            	url: js_data.admin_ajax,
	            	data: post_data,
					dataType: "json",
	            	beforeSend: function(){
	               		//$("#pre_ajax_loading").show();
						$("#buy-submit").html("PROCESSING...");
	           		},
	            	complete: function(){
	               		//$("#pre_ajax_loading").hide();
						$("#buy-submit").html("PROCESS YOUR PAYMENT");
	            	},
	            	success: function(data){
	               		//var rs = $.parseJSON(data);
						if(data.response=='sucess')
						{
							//$("#ajax_message").slideDown().html(data.message);// success
							$("input[type='text']").val("");
							var modal_buy = $('[data-remodal-id=remodal-buy]').remodal();
							var  modal_thank = $('[data-remodal-id=remodal-thanks]').remodal();
							modal_buy.close();
							modal_thank.open();
						}else{
							$("#ajax_message").slideDown().html(data.message);	//errror
						}
						setTimeout(function(){ $("#ajax_message").slideUp().html("");},5000);
						//console.log(data.response);
						//console.log(data);
	                }
	     		});
           	return false;
	 	});

		/*
		$('.readmore-popup').click(function(){
			var id = $(this).attr('data-id');			
			var post_data = {'action':'get_package','id':id};
			$.ajax({
	        		type:'POST',
	            	enctype:'multipart/form-data',
	            	url:js_data.admin_ajax,
	            	data:post_data,
					dataType: "html",
	            	beforeSend: function(){
	            		//Do something	 
	            		$('#modal-package .modal-content .modal-package-content').html("<div class='loading_html'>Loading...</div>");
						$('#modal-package').modal('show');               		              		
	           		},
	            	complete: function(){	               		
	            		//Do something
	            	},
	            	success: function(data){	
	            		$('#modal-package .modal-content .modal-package-content').html(data);
						$('#modal-package').modal('show');               		
	                }
	     		});			
			return false; 
		});
		*/

		var inst_package = $('[data-remodal-id=remodal-package]').remodal();
		$('.readmore-popup').click(function(){
			var id = $(this).attr('data-id');			
			var post_data = {'action':'get_package','id':id};
			$.ajax({
	        		type:'POST',
	            	enctype:'multipart/form-data',
	            	url:js_data.admin_ajax, 
	            	data:post_data,
					dataType: "html",
	            	beforeSend: function(){
	            		//Do something	 	            		
	            		$('.modal-package-content  .modal-content-ajax').html("<div class='loading_html'>Loading...</div>");
						inst_package.open();              		              		
	           		},
	            	complete: function(){	               		
	            		//Do something
	            	},
	            	success: function(data){	
	            		$('.modal-package-content  .modal-content-ajax').html(data);						             	
	                }
	     		});			
			return false; 
		});


});