$(document).ready(function(){$('body').append('
');$(document).on('click','.facebookLoginButton',fbRegister);window.fbAsyncInit=function(){FB.init({appId:facebookAppId,channelURL:facebookChannelUrl,status:true,cookie:true,oauth:true,xfbml:true});FB.Event.subscribe('comment.create',function(response){var path="https://"+window.location.host,subscribe_url=path+"/fbmod/notify-comment";$.post(subscribe_url,response,function(msg){console.log(msg);});});FB.Event.subscribe('comment.remove',function(response){console.log(response);var path="https://"+window.location.host,subscribe_url=path+"/fbmod/denotify-comment";console.log("Sending notification to: "+subscribe_url);$.post(subscribe_url,response,function(msg){console.log(msg);});});if(facebookAutologin){FB.getLoginStatus(function(response){if(response.authResponse){var uid=response.authResponse.userID;jQuery.ajax({url:facebookAutologinUrl,type:'POST',dataType:'json',data:{uid:response.authResponse.userID},success:fbLoginResponse});}else{}});}};(function(d){var js,id='facebook-jssdk',ref=d.getElementsByTagName('script')[0];if(d.getElementById(id)){return;} js=d.createElement('script');js.id=id;js.async=true;js.src="//connect.facebook.net/en_US/all.js";ref.parentNode.insertBefore(js,ref);}(document));});function fbRegister(){FB.login(function(response){if(response.authResponse){var fb_data={access_token:response.authResponse.accessToken,uid:response.authResponse.userID,signed_request:response.authResponse.signedRequest};jQuery.ajax({url:facebookcheckRegisteredUserUrl,type:'POST',dataType:'json',data:fb_data,success:function(json){if(!json.regisreted){$('#facebook-email-register').val(json.email);$.fancybox.open({padding:0,src:'#fb_confirm',type:'inline'});$('form#fb_authorization').submit(function(e){e.preventDefault();var err=false;$('form#fb_authorization .act-legal input[type="checkbox"]:visible').not(':checked').each(function(){showError($(this).data('err_msg'),null,$(this).data('err_title'),'err');e.preventDefault();err=true;});if(!err){fb_register_user(fb_data);}});}else{fb_register_user(fb_data);}}});function fb_register_user(fb_data){jQuery.ajax({url:facebookRegisterUrl,type:'POST',dataType:'json',data:fb_data,success:fbRegisterResponse});}}else{console.log('User cancelled login or did not fully authorize.');}},{scope:'email'});} function fbRegisterResponse(response){var curUrl=document.location.href+'';if(curUrl.indexOf('#')!=-1){curUrl=curUrl.substr(0,curUrl.indexOf('#'));} window.location=curUrl;} function fbLoginResponse(response){}