/* vim: set ts=2 sts=2 sw=2 : */
function getParameterByName(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.href);
  if(results == null)
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

IDKIT.getLoginStatus(function(response) {
  var param = getParameterByName('next');
  if(response.session) {
    window.location = '/identitynet/login_with_token/?token=' + response.session.access_token + (param ? '&next=' + param : '');
  }
});

