function init(){/* CFInstall.check({node: "cf",onmissing:function(){$('#cf').before($('<div id="cfclose">Close Google chrome frame X</div>').click(function(){$(this).add('#cf').remove();}));}});*/ADS.sort(function(){return(Math.round(Math.random())-0.5)});$(".pics").each(function(I){$(this).bind("error",function(){$(this).attr("src","/images/ads/jsaces.png").parent().attr("href","/piclink/4009")}).attr("src","/picimage/"+ADS[I]).parent().attr("href","/piclink/"+ADS[I])});var C=0,H=(google.loader.ClientLocation&&google.loader.ClientLocation.address.country_code)?google.loader.ClientLocation.address.country_code.toLowerCase():"us";for(l in google.language.Languages){var B=(l.length>0)?l.substring(0,1)+l.substring(1).toLowerCase():"",E=google.language.Languages[l];if(google.language.isTranslatable(E)&&E!=""&&B.indexOf("_")==-1&&$GDL[E]){$("#lnglist").append('<li id="'+E+'"><a>'+($GDL[E]||B)+"</a></li>");$("#lngfrom,#lngto").append($("<option>").val(E).text(($GDL[E]||B)));if(lng2cc[E.toLowerCase()]&&$.inArray(H,lng2cc[E.toLowerCase()])!=-1){$("#lngfrom option:last,#lngto option:last").attr("selected","selected").addClass("slng");$("#"+E.toLowerCase()).css("backgroundPosition","-15px 50%");$Lfrom=$Lto=E.toLowerCase()}else{$L.push(E);$LReset.push(E)}}}if(entries_from_twitter){$Lfrom=$LFROM;$Lto=$LTO;var D=$("#lngto option[value="+$LTO+"]").attr("selected","selected").addClass("slng"),C=$("#lngto option").index(D[0]);$L.remove(C);$LReset.remove(C);D=$("#lngfrom option[value="+$LFROM+"]").attr("selected","selected").addClass("slng");C=$("#lngfrom option").index(D[0]);$L.remove(C);$LReset.remove(C);$("#twit").val($TWEETO);$("#twitd ul li:last").html($TWEETJ+" <span>"+(140-$TWEETJ.length)+"</span>");$("#twitauth").css({height:"auto",opacity:1,display:"block"});$("#tvit").text("Try again");$("#counter").css("display","block").html(140-$("#twit").val().length)}else{if($("#lngfrom option.slng").length==0){var D=$('#lngto option:contains("English"),#lngfrom option:contains("English")').attr("selected","selected").addClass("slng"),C=$("#lngto option").index(D[0]);$("#en").css("backgroundPosition","-15px 50%");$Lfrom=$Lto="en";$L.remove(C);$LReset.remove(C)}}if($TWITTERID){$.getJSON("http://twitter.com/statuses/friends/"+$SCREENNAME+".json?screen_name="+$SCREENNAME+"&callback=?",function(J){var I=$("#com").change(function(){if($("#comprefix").val()==="at"&&$(this).val()!=""){var K=(140-($.trim($("#twitd").clone().find("span").remove().end().text()).length+($(this).val().length+2)));$("#twitd").find("span").text(K)}else{var K=(140-($.trim($("#twitd").clone().find("span").remove().end().text()).length));$("#twitd").find("span").text(K)}});$("#comprefix").change(function(){if($(this).val()==="at"&&$("#com").val()){var K=(140-($.trim($("#twitd").clone().find("span").remove().end().text()).length+($("#com").val().length+2)));$("#twitd").find("span").text(K)}else{var K=(140-($.trim($("#twitd").clone().find("span").remove().end().text()).length));$("#twitd").find("span").text(K)}});$.each(J,function(K,L){I.append('<option value="'+L.screen_name+'">'+L.screen_name+"</option>")})})}$("#lngfrom,#lngto").bind("change",function(){var I=$(this).val();$("#"+I).css("backgroundPosition","-15px 50%");$LReset=$L=$.grep($L,function(J){return J!=I});$L.push((this.id=="lngfrom")?$Lfrom:$Lto);$LReset.push((this.id=="lngfrom")?$Lfrom:$Lto);$Lfrom=(this.id=="lngfrom")?I:$Lfrom;$Lto=(this.id=="lngto")?I:$Lto});$("#lnglist").delegate("click",{a:function(J){J=$(J.target).parent();var I=$.inArray(J.attr("id"),$L);if(I===-1){J.css("backgroundPosition","0 50%");$L.push(J.attr("id"));$LReset.push(J.attr("id"))}else{J.css("backgroundPosition","-15px 50%");$L.remove(I);$LReset.remove(I)}}});function F(){if($.trim($("#twit").val())!=""){$("#twitd").animate({height:"80px"},"slow",function(){$(this).children("ul").html("<li>&nbsp;</li>").append("<li></li>");$LT=[];$LTL=$L.length;$L=$.unique($L);$LReset=$.unique($LReset);A($("#twit").val());$(this).unbind();$("#buttoncover").show();$("#lnglistcover").show()});$("#twitauth").animate({opacity:"0",height:"0"},"slow")}}function G(){if(/^@/.test($.trim($("#twit").val()))){var I=confirm('It looks like your tweet starts with an @username; if so it will be translated with the rest of the text.\nYou can set the @username when you send the tweet. Click OK to translate with the "@", or cancel and remove it.');if(!I){return false}else{F()}}else{F()}$("#twitauth").find("div#twitresponse").remove()}$("#tvit").bind("click",G);function A(K,J){var L=Math.floor(Math.random()*$L.length),I=$L[L];$L.remove(L);J=J||$Lfrom;if($L.length==0){I=$Lto}if($LTL>$LT.length){google.language.translate(K,J,I,function(M){if(!M.error){r=M.translation;$LT.push(I);$("#"+J).css("color","black");$("#"+I).animate({backgroundColor:"#ffff00"},500,function(){$(this).animate({backgroundColor:"#ffffff"},1000)});if($("#showAllHops:checked").length>0){$("#twitd").css({height:"auto","min-height":"80px"}).children("ul").append($("<li>").text(r.replace(/&#39/g,"'").replace(/&quot;/g,'"')))}else{$("#twitd").css({height:"80px","min-height":"auto"}).find("li:last").text(r.replace(/&#39/g,"'").replace(/&quot;/g,'"'))}$("#twitd").find("li:last").append("<span>"+(140-$("#twitd").find("li:last").text().length)+"</span>");if($L.length==0){$("#tvit").text("Try again").bind("click",G);$("#buttoncover").hide();$("#lnglistcover").hide();$("div#buttonwrap span").show();$.each($LReset,function(P,O){$L.push(O)});var N=$("#twitd").find("li:last").text().length;if(N>140){alert("Final result is over 140 characters; click Try Again, or shorten your original text.")}$("#lnglist li").css({backgroundPosition:"0 50%",backgroundColor:"#fff"}).each(function(P,O){if($.inArray(O.id,$L)==-1){$(O).css("backgroundPosition","-15px 50%")}})}else{A(r,I)}}else{A(r,I)}})}}$("h2").click(function(){$(this).next().slideToggle("slow")});$("#tweet").click(function(){$("#twitauth").animate({opacity:"1",height:"120px"},"slow")});$("#twitauth span.security").click(function(){var I=$("h2.last");if($("div#faqs").css("display")=="none"){I.trigger("click")}$("html,body").animate({scrollTop:(I.offset()&&I.offset().top)||0},2000,function(){var J=$("div#faqs").find("dt:eq(4),dd:eq(4)").animate({backgroundColor:"#ffff00"},500,function(){J.find("strong").css({backgroundColor:"#ffff00"});J.animate({backgroundColor:"#ffffff"},1000,function(){setTimeout(function(){J.find("strong").animate({backgroundColor:"#ffffff"},2000)},2000)})})})});$("#twit").focus(function(){if($(this).val().indexOf("What is Twibberish? Type a tweet here and press 'Start' to find out")!=-1){$(this).val("")}}).blur(function(){if($(this).val()===""){$(this).val("What is Twibberish? Type a tweet here and press 'Start' to find out...\nIf you want to translate a tweet sent from here, click on 'Get a tweet' below.")}}).blur().bind("keyup paste input",function(I){if(this.value.length>=140){$(this).addClass("overlimit");this.value=this.value.substring(0,140)}else{$(this).removeClass("overlimit")}$("#counter").css("display","block").html(140-this.value.length+"<span> </span>")});$("#eraser").click(function(){$("#twit").val("").focus();$("#counter").html("<span> </span>");$("#twitd").children("ul").html("<li>&nbsp;</li>").append("<li></li>").animate({height:"80px"},"slow",function(){$LT=[];$LTL=$L.length;$L=$.unique($L);$LReset=$.unique($LReset)});$("#twitauth").animate({opacity:"0",height:"0"},"slow")});$("#twitterlogin").click(function(){var J=$("#twitd li:last").clone().find("span").remove().end();var I={twit:$("#twit").val(),twitd:J.text(),lngfrom:$("#lngfrom").val(),lngto:$("#lngto").val()};$.getJSON("/twitter/login",I,function(K){if(K.status==="success"){window.location.href="/oauth/twitter/login"}});return false});$("form#auth").submit(function(){var K=$("#twitd li:last").clone().find("span").remove().end();var I={username:$("#username").val(),pass:$("#pass").val(),twit:$("#twit").val(),twitd:K.text(),comprefix:$("#comprefix").val(),com:$("#com").val(),lngfrom:$("#lngfrom").val(),lngto:$("#lngto").val(),user_id:$TWITTERID,screen_name:$SCREENNAME};if(google.loader.ClientLocation){var J={lat:google.loader.ClientLocation.latitude,lon:google.loader.ClientLocation.longitude,city:google.loader.ClientLocation.address.city,cc:google.loader.ClientLocation.address.country_code,region:google.loader.ClientLocation.address.region};I=$.extend({},I,J)}$.ajax({type:"POST",url:"/tweet",data:I,dataType:"json",success:function(M){var L="Your twibber has been sent!",N="";if(M.message=="Error"){L=M.tweet_response.error;N=' class="error"'}$("#twitauth").find("div#twitresponse").remove().end().prepend('<div id="twitresponse"'+N+">"+L+"</div>")},error:function(L,N,M){alert(N)}});return false});jQuery.fn.slideFadeToggle=function(I,K,J){return this.animate({opacity:"toggle",height:"toggle"},I,K,J)};$("#source form").submit(function(){var I=$(this);I.parent().find("p.tweet,p.error").slideFadeToggle(function(){$(this).remove()});$.ajax({type:"POST",url:"/twibber",data:I.serialize(),dataType:"json",success:function(J){if(J.status==="success"){$("<p>").addClass("tweet").html(J.message).appendTo(I.parent()).slideFadeToggle()}else{$("<p>").addClass("error").html(J.message).appendTo(I.parent()).slideFadeToggle()}}});return false});$.getScript('http://www.google-analytics.com/ga.js',function(){try{var pageTracker = _gat._getTracker("UA-10715404-1");pageTracker._trackPageview();}catch(err){}});}Array.prototype.remove=function(C,B){var A=this.slice((B||C)+1||this.length);this.length=C<0?this.length+C:C;return this.push.apply(this,A)};
