/* *  Advpoll module upgrade *  (automatical submit for 1-choice binary polls) */  

if(Drupal.jsEnabled) {
  $(document).ready(function() {
    
    // bind autosubmit form on radiobutton click
    $('.advpoll-vote .form-radios input').click(function() {
      $(this).parents('form').submit();
    });
    
    // select particular radiobutton by click on choice title and submit
    $('.vote_choice').click(function() {
      var choice = $(this).attr('rel');
      $(this).parents('form').find("input[@value='" + choice + "']").attr("checked", "true");
      $(this).parents('form').find("input[@value='" + choice + "']").click();
      return false;
    });
    
    // hide the submit button and radios
    $('.advpoll-vote input').css('display', 'none');
    $('.advpoll-vote .form-radios').css('display', 'none');
    $('.advpoll-vote .form-checkboxes').css('display', 'none');
    
  });
}
              
              

