$(window).load(function(){if($("#captcha").length){$("#captcha").focus()}if($("#user_username").length){$("#user_username").focus()}Strands.init_html_form(".content")});jQuery.fn.remotechecker=function(a){a=a||{};a.delay=a.delay||1000;this.each(function(){if(!$(this).hasClass("remotechecker")){var b=this;new jQuery.remotechecker(b,a)}});return this};jQuery.remotechecker=function(h,j){var e=this;var f=$(h).addClass("remotechecker");var g=0;var b=false;h.remotechecker=e;function i(m,l){b=false;var k=f.parents("div:first");k.find("span.tip:first").hide();if(m){$("div.form-feedback span.success",k).show();if(l){$("div.form-feedback span.success span",k).html(l)}$("div.form-feedback span.error",k).hide();$("span.about_input",k).text(f.val())}else{$("div.form-feedback span.success",k).hide();$("div.form-feedback span.error",k).show();if(l){$("div.form-feedback span.error span",k).html(l)}$("span.about_input",k).text("")}g=0}function a(){if(b){return}var k=f.val();if(j.checkformat){var m=j.checkformat.call(h,k);i(m,null);if(!m){return}}if(j.url){if(k.length>0){$.ajax({url:j.url,type:"GET",data:{q:k,language:j.language},cache:false,success:function(n){i(true,null)},error:function(n,p,o){i(false,n.responseText)}});b=true}else{var l=f.parents("div:first");l.find("span.about_input").text(f.val());l.find("span.form-feedback span.error").hide();l.find("div.tip:first").show()}}}function d(){if(g){clearTimeout(g)}g=setTimeout(a,j.delay)}function c(k){if((9!=k.keyCode)&&(16!=k.keyCode)){if(g){clearTimeout(g)}g=setTimeout(a,j.delay)}}f.keydown(c).change(d)};function populateDateKeys(b){var a=b?b[0]:"Month";var c=b?b[1]:"Day";var e=b?b[2]:"Year";$("#user_birthdate_2i").find(":nth-child(1)").html(a);$("#user_birthdate_3i").find(":nth-child(1)").html(c);$("#user_birthdate_1i").find(":nth-child(1)").html(e)}function init_registration_step2(a,b){populateDateKeys(a);$("#user_username").remotechecker({language:b,url:"/accounts/check_availability"});$("#user_email").remotechecker({language:b,url:"/accounts/check_availability_email"});$("#user_password").remotechecker({language:b,checkformat:function(c){var d=/[\W_]/;return(c.length>3&&!d.test(c))},url:null});$("#location_tb").autocomplete("/location/autocomplete_location",$.extend({delay:1000},globalVariables.autocompleteSettings));$("#location_tb").keyup(function(c){$(this).addClass("ac_loading")});$("a.showTipInline").unbind().click(function(){$(this).parent().parent().children(".inlineTip").slideToggle("fast")});tip()}function init_registration_step3(){$("#select_all").unbind().click(function(){$("input[type=checkbox]").attr("checked","checked");return false});$("#de_select_all").click(function(){$("input[type=checkbox]").removeAttr("checked");return false});$("#mainly_a input").change(function(){$("#coolrunners-list").load("/accounts/find_team_strands_members",{activity:$("fieldset#mainly_a input:checked").val(),authenticity_token:$("input#auth_token",null).val()},function(c,a,b){if(a=="success"&&c&&c.length>0){$("#follow_users_container").fadeIn()}else{$("#follow_users_container").fadeOut()}})})}function fast_signup(b,e){var a=b?b[0]:"Month";var c=b?b[1]:"Day";var f=b?b[2]:"Year";$("#user_birthdate_2i").find(":nth-child(1)").html(a);$("#user_birthdate_3i").find(":nth-child(1)").html(c);$("#user_birthdate_1i").find(":nth-child(1)").html(f);$("input#user_username").remotechecker({language:e,url:"/accounts/check_availability"});$("input#user_email").remotechecker({language:e,url:"/accounts/check_availability_email"});$("input#user_password").remotechecker({language:e,checkformat:function(d){var g=/[\W_]/;return(d.length>3&&!g.test(d))},url:null});$("input#bib").remotechecker({language:e,url:"/accounts/check_bib_event_availability?event_id="+$("input#event_id").val()});$("input#bib").remotechecker({language:e,url:"/accounts/check_bib_event_availability?event_id="+$("input#event_id").val()});$("input#location_tb").autocomplete("/location/autocomplete_location",{matchSubset:0,delay:2000,cacheLength:5});$("input#location_tb").keyup(function(d){$(this).addClass("ac_loading")});$("a.showTipInline").unbind().click(function(){$(this).parent().children(".inlineTip").slideToggle("fast")})}function submit_form(){if($("form",null)){$("form",null).submit()}return false}function tip(){var a=$("form span.tip").append('<div class="arrow"></div>').parent().next();a.focus(pop_tip);a.children("input").focus(pop_tip);a.blur(hide_tip);a.children("input").blur(hide_tip)}function pop_tip(){if($(this).parent().hasClass("fieldWithErrors")){var a=$(this).parent().prev().children("span.tip:first")}else{var a=$(this).prev().children("span.tip:first")}if(a.text().length>0){a.fadeIn(150)}}function hide_tip(){if($(this).parent().hasClass("fieldWithErrors")){var a=$(this).parent().prev().children("span.tip")}else{var a=$(this).prev().children("span.tip")}a.fadeOut(150)}$(document).ready(function(){if($("select#user_country").val()!=undefined){user_creation_check_country();$("#foo_us_state").click(function(){update_user_state()});$("#foo_es_state").click(function(){update_user_state()})}jQuery(document).ready(function(){var b=jQuery,a=globalVariables,c=b("#container-content-landing");b(a.nativeGetByClass?".thickbox":"a.thickbox").colorbox(a.thickboxSettings,Strands.invokeAjaxCallbackForElement).removeClass("thickbox");Strands.bind_ajax(c);Strands.init_tooltips(c)})});function update_user_state(){var c=$("#user_country").val().toLowerCase();if(c!="es"&&c!="us"){if(c=="usa"||c=="united states"){c="us"}else{if(c=="spain"||c=="españa"){c="es"}}}var b="#foo_"+c+"_state";var a=$(b).val();if(a==undefined){a=""}$("#user_state").val(a)}function user_creation_check_country(){$("div.user_states_div").hide();var a=($("select#user_country").val()||"").toLowerCase();if(a=="us"||a=="es"){$("div#"+a+"_states").show()}else{if(a=="spain"||a=="españa"){$("div#es_states").show()}else{if(a=="united states"||a=="usa"){$("div#us_states").show()}}}update_user_state()};
