﻿(function(){
  if (window != top || window.location.hash[0] === '#') {
    var temp_location = window.location;
    if (window.location.search.length === 0) {
      var redirect_location = 'main';
      if (window.location.hash[0] === '#') {
        redirect_location = window.location.hash.substring(1);
        temp_location.hash = '';
      }
      temp_location.href = 'login?target=/' + redirect_location;
    }
    top.location = temp_location;
    delete temp_location;
  }
})();


window.addEvent("domready_nk", function() {
  var target = $('login_target');
  if (!target) {
    return;
  }
  if (target.get('value').length === 0) {
    var loc_href = document.location.href;
    var idx = loc_href.indexOf('#');
    if (idx === -1) {
      target.set('value', 'main');
    } else {
      var short_href = loc_href.substring(idx + 1);
      target.set('value', short_href);
    }
  }
});
