/**
* @package   SP Soccer
* @author    JoomShaper http://www.joomshaper.com
* @copyright Copyright (C) 2010 - 2017 JoomShaper. All rights reserved.
* @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later.
*/

jQuery(function($) { 'use strict'
  	$(document).on('click', '.poll-submit', function () {
  		var self = $(this),
  		parentWrap = self.closest('.spsoccer-module-poll');

  		var value   = parentWrap.find('input[name=question]:checked').val(),
  			request = {
  					'option' : 'com_ajax',
  					'module' : 'sp_soccer_poll',
  					'data'   : value,
  					'format' : 'raw'
  				};
  		$.ajax({
  			type   : 'POST',
  			data   : request,
  			success: function (response) {
  				parentWrap.find('.spsoccer-poll').hide();
  				parentWrap.find('.status').html(response);
  			}
  		});
  		return false;
  	});
});
