var dns = "https://hosting.wialon.com";
var url = dns + "/login.html";
url += "?access_type=-1";
url += "&response_type=hash";
url += "&redirect_uri=" + dns + "/post_token.html";
document.querySelector("#loginform").src=url;
document.addEventListener('DOMContentLoaded', loadForm, false);
function tokenRecieved(e) {
if (typeof msg == "string" && msg.indexOf("access_hash=") >= 0) {
var hash = msg.replace("access_hash=", "");
window.open(dns+'?authHash='+hash, "_blank");
document.location.href = dns+'?authHash='+hash;
window.addEventListener("message", tokenRecieved);