var captcha_form_id;
function submit_captcha(what) 
{
    captcha_form_id = what.id;
    
    email = $('email');
    new Ajax.Request('/download/ajax_captcha', {
        method: 'post',
        parameters: what.serialize,
        onFailure:
          function() {
            alert('Error');
          },
        onSuccess:
            function(transport) {
                var response = transport.responseText;
                var data = response.evalJSON(true);
                if( data.type == 'error' ){
                    alert(data.message);
                } else {
                    $(captcha_form_id).submit();
                }
            }
    });
}

function refresh_download_captcha(base) {
  var now = new Date();
  //alert(base + now.getTime())
  $('captcha_img').src = base + now.getTime();
}
