/**
 * ASNU.net
 *
 * Real estate social network
 *
 * @package ASNU.net
 * @author Wizardry, Golubev Sergii
 * @copyright Copyright (c) 2009, Wizardry
 * @link http://www.wizardry.ua
 * @version 0.1
 */

/**
 * Facebook auth js
 *
 * @package ASNU.net
 * @subpackage JS
 * @category JS
 */

/**
 * Init FB SDK.
 */
function fb_init()
{
    FB.init({
        appId  : '175929619115534', //ASNU.net
//        appId  : '162259377157973', //asnu.lun.ua
        status : true, // check login status
        cookie : true, // enable cookies to allow the server to access the session
        xfbml  : true  // parse XFBML
    });
    //add event listener for the FB login
    FB.Event.subscribe('auth.login', function(response) {
        if (response.session)
        {
            reload();
        }
    });
}

$(document).ready(
    function()
    {
        fb_init();
        //opera fix
        /** @todo fix logout in not FF browsers */
        if($.browser.opera)
        {
            FB.XD._transport = 'postmessage';
            FB.XD.PostMessage.init();
        }
        $('a.logout').click(
            function ()
            {
                FB.Connect.logoutAndRedirect('/users/logout/');
//                FB.Connect.logout(function() { redirect('/users/logout/'); })
            }
        );
    }
    );

/* End of file facebook.js */
/* Location: ./application/view_files/js/facebook.js */
