function fbLoggedinAction(){FB.api("/me",function(response){$("#facebookUserLogin").html("Welcome "+response.name+" <img src='http://graph.facebook.com/"+response.id+"/picture'>");});}function fbLoggedoutAction(){$("#facebookUserLogin").html("<a href='#' id='facebook_login'><img src='"+MASTER_SITEIMAGE_URL+"/facebook.gif'></a> ");}function handleFacebookUsers(){try{FB.init({apiKey:FACEBOOK_APP_ID,status:true,cookie:true,xfbml:true});}catch(ex){}FB.getLoginStatus(function(response){if(response.session){fbLoggedinAction();}else{}});FB.Event.subscribe("auth.sessionChange",function(response){if(response.session){var UID="";var UNAME="";FB.api("/me",function(response){UID=response.id;UNAME=response.name;SetCookie("SIDLITEUSER_FBUID",UID,"1");});SetCookie("SIDLITEUSER_FBUSER","1");fbLoggedinAction();}else{fbLoggedoutAction();delete_cookie("SIDLITEUSER_FBUSER");delete_cookie("SIDLITEUSER_FBUNAME");delete_cookie("SIDLITEUSER_FBUID");delete_cookie("SIDLITEUSER_FBUPIC");}});$("#facebook_login").bind("click",function(){FB.login(function(response){if(response.session){fbLoggedinAction();}else{fbLoggedoutAction();}});});}function handleLoginUsingFB(){$("#facebook_login").bind("click",function(){FB.login(function(response){if(response.session){$("#loggedin_text").html("Welcome User!");showDisplay();}else{$("#loggedin_text").html("Guest You are not Logged in");}});});$("#facebook_logout").bind("click",function(){FB.logout(function(response){if(response.session){location.href="logout.php";}else{$("#loggedin_text").html("You could not be Logged Out");}});});$("#disconnect").bind("click",function(){FB.api({method:"Auth.revokeAuthorization"},function(response){clearDisplay();});});function clearDisplay(){$("#loggedin_text").html("Guest You are not Logged in");$("#user_info").hide("fast");$("#user_tools").hide("fast");}function showDisplay(){$("#loggedin_text").html("Hi You are Logged in");$("#user_info").show("fast");$("#user_tools").show("fast");$("#loggedin_method").hide();}}function getLoggedInUserName(){var loggedUser=GetCookie("SIDLITEUSERLOGGEDIN");if(!loggedUser||loggedUser=="-1"){displayLoggedInUserName("-1");}else{var splitdata=loggedUser.split("_");displayLoggedInUserName(splitdata[2]);}}function getLoggedInUserName2(){var loggedUser=GetCookie("SIDLITEUSERLOGGEDIN");if(!loggedUser||loggedUser=="-1"){try{FB.getLoginStatus(function(response){if(response.session){FB.api({method:"fql.query",query:"SELECT name, pic FROM profile WHERE id="+FB.getSession().uid},function(response){var user=response[0];SetCookie("SIDLITEUSER_FBUNAME",user.name,"1");SetCookie("SIDLITEUSER_FBUID",FB.getSession().uid,"1");SetCookie("SIDLITEUSER_FBUPIC",FB.getSession().pic,"1");displayLoggedInUserName(user.name);});}else{delete_cookie("SIDLITEUSER_FBUNAME");delete_cookie("SIDLITEUSER_FBUID");delete_cookie("SIDLITEUSER_FBUPIC");displayLoggedInUserName("-1");}});}catch(err){alert(err);displayLoggedInUserName("-1");}}else{var splitdata=loggedUser.split("_");displayLoggedInUserName(splitdata[2]);}}function displayLoggedInUserName(name){if(name=="-1"){var title="Login To Nefunda";var htmlstr="Welcome Guest <a href='login.php' class='loginlink cboxElement' title='Login'>&nbsp;<b>Login</b></a>";}else{var title="Logout From Nefunda";var htmlstr="welcome"+name+" <a href='logout.php' class='loginlink' title='Logout'>&nbsp;<b>Logout</b></a>";}$("#nefundalogintop").html(htmlstr);}function showBLockOnlyIfLoggedin(showhide){var loggedUser=GetCookie("SIDLITEUSERLOGGEDIN");if(!(loggedUser=="-1")&&(loggedUser.length>0)){$("#"+showhide).show("fast");}}