var applicationRoot = '/gcrm';

var popupWin = null;
var mouseX = 0;
var mouseY = 0;

function setMousePos(evt) {
    if (navigator.appName.indexOf("Microsoft") != -1) evt = window.event;
    mouseX = evt.screenX;
    mouseY = evt.screenY;
}

function closePopup() {
    if (popupWin != null) {
        if (!popupWin.closed) {
            popupWin.close();
        }
        popupWin = null;
    }
}

function openPopup(url, name, width, height, options) {
    closePopup();

    if (mouseX - width < 0) {
        mouseX = width;
    }
    if (mouseY + height > screen.height) {
        mouseY -= (mouseY + height + 50) - screen.height;
    }
    mouseX -= width;
    mouseY += 10;
    options += ",screenX=" + mouseX + ",left=" + mouseX + ",screenY=" + mouseY + ",top=" + mouseY;

    popupWin = window.open(url, name, options);
    popupWin.focus ();
}

function openWindow(url, name, width, height, options) {
    closePopup();

    options += ",width=" + width + ",left=" + "50" + ",height=" + height + ",top=" + "50" + ",scrollbars=yes,resizable=yes";

    popupWin = window.open(url, name, options);
    popupWin.focus ();
}

function changeLang(object) {
   location.replace(object.options[object.selectedIndex].value);
}
