var searchKeyWordFocused=false;
var searchKeyUserFocused=false;
var previousSearchTab=null;
var previousSearchedToken=null;
var searching=false;
var loading_comments=false;
var already_tweeting=false;
var oauth_callback=null;
var oauth_close_popup_if_ok=true;
var comments_ajax=new StarRequest(true,true);
comments_ajax.onload=commentsLoaded;
comments_ajax.onfail=commentsLoaded;
function initSearchBox(){
if(location.pathname.startsWith("/search/term")){
searchKeyWordFocused=true;
previousSearchedToken=location.pathname.substring(13);
previousSearchTab=1;
}else{
if(location.pathname.startsWith("/search/from")){
searchKeyUserFocused=true;
previousSearchedToken=location.pathname.substring(13);
previousSearchTab=2;
}
}
};
function showTab1(){
$("tab2").style.display="none";
$("tab1").style.display="block";
};
function showTab2(){
$("tab1").style.display="none";
$("tab2").style.display="block";
};
function searchTerm(){
if(searching||!searchKeyWordFocused){
return;
}
var _1=getSearchToken(1);
if(previousSearchTab==1&&previousSearchedToken==_1){
return;
}
searching=true;
cursor.showCursor();
document.location="/search/term/"+URLencode(_1);
};
function searchFrom(){
if(searching||!searchKeyUserFocused){
return;
}
if(!isOAuthenticated()){
showOAuthPopup(function(){
searchFrom();
},false);
return;
}
var _2=getSearchToken(2);
if(previousSearchTab==2&&previousSearchedToken==_2){
return;
}
searching=true;
cursor.showCursor();
document.location="/search/from/"+URLencode(_2);
};
function getSearchToken(_3){
var _4=$(_3==1?"key_word":"key_user");
var _5=_4.value.trim();
_4.value=_5;
return _5;
};
function userTweetCloud(_6){
if(searching){
return;
}
searching=true;
cursor.showCursor();
document.location="/search/from/"+URLencode(_6);
};
function termTweetCloud(_7){
if(searching){
return;
}
searching=true;
cursor.showCursor();
document.location="/search/term/"+_7;
};
function clearKeyWordSearch(){
if(!searchKeyWordFocused){
$("key_word").value="";
$("key_word").style.color="black";
searchKeyWordFocused=true;
}
};
function clearKeyUserSearch(){
if(!searchKeyUserFocused){
$("key_user").value="";
$("key_user").style.color="black";
searchKeyUserFocused=true;
}
};
function submitenter(_8,e){
var _9;
if(window.event){
_9=window.event.keyCode;
}else{
if(e){
_9=e.which;
}else{
return true;
}
}
if(_9==13){
if(_8==1){
searchTerm($("key_word").value);
}
if(_8==2){
searchFrom($("key_user").value);
}
return false;
}else{
return true;
}
};
function showTagComments(_a,_b,_c,_d){
if(!loading_comments){
loading_comments=true;
if(_d){
$("comments_div").style.display="none";
$("comments_load").style.display="";
}
comments_ajax.getURL("/?a=64&p=2&page="+_b+"&tid="+_a,true,"comments_div");
}
};
function showQueryComments(_e,_f){
if(!loading_comments){
loading_comments=true;
comments_ajax.getURL("/?a=64&p=2&page="+_f+"&qid="+_e,null,"comments_div");
}
};
function commentsLoaded(r){
loading_comments=false;
$("comments_load").style.display="none";
$("comments_div").style.display="";
StarScroll.scrollTo($("comments_flag"));
};
function tweetIt(_10){
if(!isOAuthenticated()){
showOAuthPopup(function(){
tweetIt(_10);
},true);
return;
}
if(already_tweeting){
return false;
}
already_tweeting=true;
var _11={};
_11["text"]=_10;
_11["url"]=document.location.href;
var req=new StarRequest(false,true);
req.onload=function(_12){
if(!_12["ok"]){
already_tweeting=false;
alert("Your tweet couldn't be sent to Twitter.\nPlease try again.");
}else{
tweetSent($("tweet_button"));
tweetSent($("tweet_button_popup"));
}
};
req.getURL("/home/tweet",_11,null,true);
};
function tweetSent(but){
but.src=f2fconstants.STATIC_URI+"c/images/tweet_sent.gif";
but.alt="Tweet sent!";
but.title="Tweet sent!";
but.onclick="return false;";
};
function showAbout(){
popup.loadPopup(64,4,true);
};
function showFeedback(){
popup.loadPopup(64,5,true);
};
function showShare(_13,_14,_15){
var _16={};
_16["url"]=document.location.href;
if(_13!=null&&_13!=undefined){
_16["page"]=_13;
}
if(_14!=null&&_14!=undefined){
_16["from"]=_14;
}
if(_15!=null&&_15!=undefined){
_16["term"]=_15;
}
popup.loadPopup(64,7,true,_16,true);
};
function setPageTimeout(_17){
window.setTimeout(function(){
document.location.href=document.location.href;
},_17*60*1000);
};
function isOAuthenticated(){
return getCookie(f2fconstants.TKCN)!=null;
};
function showOAuthPopup(_18,_19){
oauth_callback=_18;
oauth_close_popup_if_ok=_19;
popup.showPopup("/home/twittersignin",true);
};
function oAuthCallback(ok){
if(ok){
if(oauth_close_popup_if_ok){
popup.unloadPopup();
}else{
$("oauth_popup_text").innerHTML="Contacting Twitter...";
$("oauth_popup_image").innerHTML="<img src='"+f2fconstants.STATIC_GLOBAL_URI+"images/loading.gif' width='32' height='32' border='0'/>";
}
oauth_callback.apply(oauth_callback);
}
};
function twitterSignInRedirect(){
openCenteredWindow(f2fconstants.CALLBACK_URI+"home/twittersigninredirect","tweetcloud_oauth",900,380);
};

