var
  vk_members_data = {},
  lastCommentsResponse,
  lastCommentsPage = null,
  baseURL = window.location.protocol + '//' + window.location.hostname + '/';


function doLogin() {
  VK.Auth.login(
    null,
    VK.access.FRIENDS | VK.access.WIKI
  );
}
function doLogout() {
  VK.Auth.logout(logoutOpenAPI);
}
function loginOpenAPI() {
  loginOnServer();
}
function logoutOpenAPI() {
  window.location = '/sign_out';
}

function loginOnServer(){
	window.location = '/users/vkontakte_login'
}

function getInitData() {
  var code;
  code = 'return {';
  code += 'me: API.getProfiles({uids: API.getVariable({key: 1280}), fields: "photo"})[0]';
  code += ',info: API.getGroupsFull({gids:1})[0]';
  code += ',news: API.pages.get({gid:1, pid: 2424933, need_html: 1})';
  code += ',friends: API.getProfiles({uids: API.getAppFriends(), fields: "photo"})';
  code += '};';
  VK.Api.call('execute', {'code': code}, onGetInitData);
}



function onGetInitData(data) {
  var r, i, j, html;
  if (data.response) {
    r = data.response;
    /* Insert user info */
    if (r.me) {
alert(r.me.photo);
 alert(r.me.first_name + ' ' + r.me.last_name);
alert(r.me.photo);
 alert('http://vkontakte.ru/id' + r.me.uid);

    }

} else {
  
  }
}

