jQuery(document).ready(function(){
    $("#reg-form" ).dialog({ 
            modal: true, 
            autoOpen: false,
            draggable: false,
            width: 465,
            resizable: false,
            dialogClass: 'alert',
            closeOnEscape: true,
     });
     $('a[rel="reg-form-dialog"]').click(function () {showRegistrationForm(); return false;});

});

function showRegistrationForm () 
{
    fbinit();
    $('.ui-dialog-titlebar').hide();
    $('#reg-form').dialog('open');
}

function joinWithFBstart () {
    alert(arguments.callee.name);
    //check connection to FB
    joinWithFBsendData();
    return false;
}


function joinWithFBstartJS () {
    //alert(arguments.callee.name);
    //check connection to FB
    FB.getLoginStatus(function(response) {
        //alert('login');
      if (response.status === 'connected') {
        //alert('logged in and connected user, someone you know');
        joinWithFBsendData();
      } else {
        //alert('no user session available, someone you dont know');
        FB.login(function(response) {
          if (response.authResponse) {
              joinWithFBsendData();
          } else {
            alert('For using Facebook Connect you need to login and allow permissions!');
          }
        }, {scope:'email,user_birthday,user_location'});            
      }
    });
    return false;
}

/**/    
function joinWithFBsendData () {
    $('#registration_facebook').submit();
    return false;
}


/**/
