function redirect_to_self(){var a=location.href;var b=a.indexOf("#");if(b!=-1){a=a.substring(0,b)}location.href=a}function set_enter_handler(b,a){$(b).keyup(function(c){if(c.which!=13){return}a()})}function FormHelper(a){if(a){this.__form=$("#"+a)}else{this.__form=$("form")}}FormHelper.prototype.bind_for_ajax=function(b,c){var a=this;this.__form.submit(function(){a.ajax_submit(b,c);return false})};FormHelper.prototype.ajax_submit=function(b,c){this.__clear_errors();var a=this;$.post(this.__form.attr("action"),this.__form.serialize(),function(d){if(d.success){b(d)}else{if(c!=undefined){c(d)}else{a.__fill_errors(d)}}},"json");this.__toggle_inputs_disable_state(true)};FormHelper.prototype.__fill_errors=function(a){for(var b in a.form.errors){if(b!="non_field_errors"){this.__form.find("#id_error_container_"+b).html(a.form.errors[b])}else{this.__form.prepend('<div id="id_non_field_errors" class="error error_container">'+a.form.errors.non_field_errors+"</div>")}}this.__toggle_inputs_disable_state(false)};FormHelper.prototype.__toggle_inputs_disable_state=function(a){this.__form.find("input, select").attr("disabled",a)};FormHelper.prototype.__clear_errors=function(){this.__form.find("div.error_container").empty()};function APIWrapper(){this.__JOIN_CAMPAIGN_URL="/api/user/joinCampaign/";this.__SET_ACTION_VALUE_URL="/api/user/setActionValue/";this.__PUBLISH_TWEET_URL="/api/user/publishTweet/";this.__SUBMIT_AY_QUIZ_URL="/api/apps/submitAYQuiz/"}APIWrapper.prototype.join_campaign=function(a){$.post(this.__JOIN_CAMPAIGN_URL,{},function(b){a(b)},"json")};APIWrapper.prototype.set_action_value=function(c,a,b){$.post(this.__SET_ACTION_VALUE_URL,{code:c,value:a},function(d){b(d)},"json")};APIWrapper.prototype.publish_tweet=function(a,b){$.post(this.__PUBLISH_TWEET_URL,{tweet:a},function(c){b(c)},"json")};APIWrapper.prototype.submit_ay_quiz=function(a,b,c){b+="&quiz_id="+a;$.post(this.__SUBMIT_AY_QUIZ_URL,b,function(d){c(d)},"json")};