$(document).ready(function(){$("#group_button").click(function(){create_group();return false;});$("#search_button").click(function(){search();return false;});$("#tim_login_button").click(function(){$(this).hide();$("#tim_login_cancel").fadeIn();$("#tim_login").fadeIn();$("#habari_username").focus();return false;});$("#tim_login_cancel").click(function(){$(this).hide();$("#tim_login").hide();$("#tim_login_button").fadeIn();return false;});$("#what").click(function(){$(this).attr("value","");});$("#geo_loc").click(function(){$(this).attr("value","");});$("#when").click(function(){$(this).attr("value","");});$("#custom_location").click(function(){$("#location_message").fadeIn();$("#location_message_count").fadeIn();$("#location_cancel").fadeIn();return false;});$("#custom_group").click(function(){$("#group_message").fadeIn();$("#group_message_count").fadeIn();$("#group_cancel").fadeIn();return false;});$("#location_cancel").click(function(){$("#location_message").fadeOut();$("#location_message_count").fadeOut();$("#location_cancel").fadeOut();$("#location_message").val("");$("#location_message_count").html("Word Count 0");return false;});$("#group_cancel").click(function(){$("#group_message").fadeOut();$("#group_message_count").fadeOut();$("#group_cancel").fadeOut();$("#group_message").val("");$("#group_message_count").html("Word Count 0");return false;});$("#location_message").each(function(){this.relatedElement=$("span")[1];var A=this.getAttribute("maxlength");var B=this.value.length;if(B>0){this.relatedElement.firstChild.nodeValue=B;}});$("#location_message").keyup(function(){var A=this.getAttribute("maxlength");var B=this.value.length;if(B>=A){this.relatedElement.className="toomuch";this.value=this.value.substring(0,A);}else{this.relatedElement.className="";}this.relatedElement.firstChild.nodeValue=B;});$("#group_message").each(function(){this.relatedElement=$("span")[3];var A=this.getAttribute("maxlength");var B=this.value.length;if(B>0){this.relatedElement.firstChild.nodeValue=B;}});$("#group_message").keyup(function(){var A=this.getAttribute("maxlength");var B=this.value.length;if(B>=A){this.relatedElement.className="toomuch";this.value=this.value.substring(0,A);}else{this.relatedElement.className="";}this.relatedElement.firstChild.nodeValue=B;});$("#apply_beta").click(function(){var A="";var B="";A+='<form id="apply_beta_form" name="apply_beta_form" method="POST" action="javascript:signup(); return false;">';A+='<p><label>Name: </label> <input type="text" id="name"></p>';A+='<p><labe>Email: </label><input type="text" id="email"></p>';A+='<p><a href="#" class="go_button" onclick="signup(); return false;" title="Apply for the beta">Sign me up!</a></p>';A+="</form>";B+="<h2><span>Glad to have you!</span> Just fill out the form to the right and we'll get in touch with you when there is room in the beta.</h2>";B+="<h3>We here at Tim are very serious about privacy, so rest assured this email will only be used to contact you.</h3>";$("#secondary").hide();$("#primary").hide();$("#primary").html(B);$("#apply_beta").fadeOut();$("#secondary").html(A);$("#secondary").fadeIn();$("#primary").fadeIn();return false;});$("#show_loc").click(function(){$("#show_group").removeClass("selected");$("#find_groups").hide();$("#show_loc").addClass("selected");$("#find_followers").fadeIn();return false;});$("#show_group").click(function(){$("#show_loc").removeClass("selected");$("#find_followers").hide();$("#show_group").addClass("selected");$("#find_groups").fadeIn();return false;});});function signup(){var B=$("#name").val();var A=$("#email").val();if(B==""||A==""){$("<p>Whoa partner, we need to have your name and email before you can get in.</p>").prependTo("#apply_beta_form");}else{$.post("http://timapp.com/ajax/twittersignup?name="+B+"&email="+A,function(C){if(C==1){$("#apply_beta_form").hide();$("#apply_beta_form").html("<p>Thanks for the info, we'll be in touch!</p>");$("#apply_beta_form").fadeIn();}else{if(C==2){$("#apply_beta_form").hide();$("#apply_beta_form").html("<p>Whoops, looks like you have already signed up. Be patient, we'll get to you as soon as we can!</p>");$("#apply_beta_form").fadeIn();}}});}return false;}function complete_signup(){var B=$("#twit_name").val();var C=$("#twit_pass").val();var E=$("#tim_pass").val();var D=$("#hash").val();if(E.length<=0){E=C;}var A=$("#displayname").val();if(C==""||B==""){$("<p>Whoa partner, we need to have your twitter username and password before we can let you in.</p>").prependTo("#update_info");}else{$.post("http://timapp.com/ajax/completesignup?twit_name="+B+"&twit_pass="+C+"&tim_pass="+E+"&displayname="+A+"&hash="+D,function(F){if(F==1){window.location="http://timapp.com";}else{$("#apply_beta_form").hide();$("#apply_beta_form").html("<p>Whoops, looks like you have already signed up. Be patient, we'll get to you as soon as we can!</p>");$("#apply_beta_form").fadeIn();}});}return false;}function follower_lookup(){var C=$("#geo_loc").val();var B=$("#what").val();var A=$("#when").val();var E=$("#message").val();var D=$("#go").html();$("#go").attr("disabled","disabled");$("#go").html("tweeting...");$.post("http://timapp.com/auth_ajax/twittercomm?geo_loc="+C+"&what="+B+"&when="+A+"&message="+E,function(F){$("#message").fadeOut();$("#results").html(F);$("#results").fadeIn();$("#go").html(D);$("#go").attr("disabled","");});return false;}function group_lookup(){var A=$("#group_id").val();var C=$("#group_message").val();var B=$("#go").html();$("#group_go").attr("disabled","disabled");$("#group_go").html("tweeting...");$.post("http://timapp.com/auth_ajax/groupdm?group_id= "+A+"&message="+C,function(D){$("#group_message").fadeOut();$("#results").html(D);$("#results").fadeIn();$("#group_go").html(B);$("#group_go").attr("disabled","");});}function update_profile(){var B=$("#twit_name").val();var D=$("#twit_pass").val();var A=$("#displayname").val();var C=$("#message").val();$.post("http://timapp.com/auth_ajax/twitterprofile?twit_name="+B+"&twit_pass="+D+"&displayname="+A+"&message="+C,function(E){$("#welcome").html("<span>You should be all set now.</span>");$("#sub").html('If you are ready to start tweeting, go ahead and click on <a href="/" title="Start Tweeting">this linky-loo</a>.');$("#update_info").fadeOut();});return false;}function cache_followers(){$("#cache_results").html('<img class="spinner" src="http://timapp.com/user/themes/tim/images/spinner.gif" alt="working">');$("#cache_results").fadeIn();$.post("http://timapp.com/auth_ajax/cachefollowers",function(A){if(A==1){$("#cache_results").fadeOut();$("#cache_results").html('<img src="http://timapp.com/user/themes/tim/images/thumbsup.png" alt="all done">');$("#cache_results").fadeIn();$("#create_cache").fadeTo("fast",0.5);}else{if(A==2){$("#cache_results").hide();$("#cache_results").html('<img src="http://timapp.com/user/themes/tim/images/thumbsdown.png" alt="whoops, crap">');$("#cache_results").fadeIn();}}});}function delete_cache(){$("#cache_results").html('<img class="spinner" src="http://timapp.com/user/themes/tim/images/spinner.gif" alt="working">');$("#cache_results").fadeIn();$.post("http://timapp.com/auth_ajax/burninatecache",function(A){if(A==1){$("#cache_results").fadeOut();$("#cache_results").html('<img src="http://timapp.com/user/themes/tim/images/thumbsup.png" alt="all done">');$("#cache_results").fadeIn();$("#delete_cache").fadeTo("fast",0.5);}else{if(A==2){$("#cache_results").hide();$("#cache_results").html('<img src="http://timapp.com/user/themes/tim/images/thumbsdown.png" alt="whoops, crap">');$("#cache_results").fadeIn();}}});}function refresh_cache(){$("#cache_results").html('<img class="spinner" src="http://timapp.com/user/themes/tim/images/spinner.gif" alt="working">');$("#cache_results").fadeIn();$.post("http://localhost:8888/habatimri/auth_ajax/freshen_cache",function(A){if(A==1){$("#cache_results").fadeOut();$("#cache_results").html('<img src="http://timapp.com/user/themes/tim/images/thumbsup.png" alt="all done">');$("#cache_results").fadeIn();$("#refresh_cache").fadeTo("fast",0.5);}else{if(A==2){$("#cache_results").hide();$("#cache_results").html('<img src="http://timapp.com/user/themes/tim/images/thumbsdown.png" alt="whoops, crap">');$("#cache_results").fadeIn();}}});}function search(){var A=$("#criteria").val();$("#search_results").hide();$("#search_results").html();$("#search_results").fadeIn();if(A.length>0){$.post("http://timapp.com/auth_ajax/search?criteria="+A,function(B){if(B){$("#search_results").html(B);$(".follower").draggable({helper:"clone"});$(".accept").droppable({accept:".follower",hoverClass:"drophover",drop:function(D,E){var C=($(E.draggable).text());var F=$(this).attr("id");addtogroup(F,C);}});$("#search_results").fadeIn();$("#groups").fadeIn();}});}else{$("#search_results").html("<h2>You need to give me something to work with!</h2>");$("#search_results").fadeIn();}}function addtogroup(D,C){var A=$("#"+D+"_count").html();var B=parseInt(A)+1;$.post("http://timapp.com/auth_ajax/addtogroup?group_id="+D+"&follower="+C,function(E){if(E==1){$("#"+D+"_count").html(B);}else{alert("There seems to have been a problem with your request, please try it again.");}});}function create_group(){var B=$("#group_name").val();var A=$("#group_desc").val();if(B.length>0){$("#go").html("Site Tight...");$.post("http://timapp.com/auth_ajax/creategroup?group_name="+B+"&group_desc="+A,function(C){window.location="/tim/manage/groups";});}return false;}function burninate(A){$.post("http://timapp.com/auth_ajax/burninategroup?id="+A,function(B){if(B==1){$("#group_"+A).remove();}else{alert("whoops, Something went a wee bit wrong. Please try again.");}});}