﻿var myNewWindow = null;
var isRoleSelectionOpened = false;
var timerHide = new Object();

function newWindow(url, width, height) {

    if ((myNewWindow == null) == false) {
        myNewWindow.close();
    }

    myNewWindow = window.open(url, '', 'width=' + width + ',height=' + height + ',top=0,left=0');
}

function newWindowWithScroll(url, width, height) {

    if ((myNewWindow == null) == false) {
        myNewWindow.close();
    }

    myNewWindow = window.open(url, '', 'width=' + width + ',height=' + height + ',top=0,left=0,scrollbars=yes');
}

function reloadParent() {
    window.opener.location.reload();
}

function collapseDiv(elementid) {
    if (document.getElementById(elementid).style.display == 'none') {
        document.getElementById(elementid).style.display = '';
    } else {
        document.getElementById(elementid).style.display = 'none';
    }
}

function maximizeWindow() {
    window.moveTo(0, 0);
    window.resizeTo(screen.availWidth, screen.availHeight);
}

function toggleIsRoleSelectionOpened() {
    if (isRoleSelectionOpened == false) {
        isRoleSelectionOpened = true;
        document.getElementById(getControlUniqueId("PopupMenu", 'div')).className = "roleSelectionVisible";
    } else if (isRoleSelectionOpened == true) {
        isRoleSelectionOpened = false;
        document.getElementById(getControlUniqueId("PopupMenu", 'div')).className = "roleSelectionHide";
    }
}

function toggleRoleSelection(option) {

    if (option == "show") {
        document.getElementById(getControlUniqueId("PopupMenu", 'div')).className = "roleSelectionVisible";
    } else if (option == "hide") {
        isRoleSelectionOpened = false;
        document.getElementById(getControlUniqueId("PopupMenu", 'div')).className = "roleSelectionHide";
    }
}