function openWin(url, name, W, H) {
    openWindow(url, name, W, H);
    return "#";
}

function loadFrame(frameID, URL) {
    document.frames[frameID].location.href = URL;
}

function openDialog(url, W, H) {
    window.showModalDialog(url, "", "center:yes;status=yes;resizable=yes;dialogWidth=" + W + "px;dialogHeight=" + H + "px;");
    return false;
}

function openDialogAndRefreshParentOnClose(url,purl, W, H) {
    var value = window.showModalDialog(url, "", "center:yes;status=yes;resizable=yes;dialogWidth=" + W + "px;dialogHeight=" + H + "px;");
    if (value = 1) {
        window.location = purl;
    }
    return false;
}

function openWindow(url, name, W, H) {
    var windowW = parseInt("" + W);
    var windowH = parseInt("" + H);
    var windowX = Math.ceil((window.screen.width - windowW) / 2);
    var windowY = Math.ceil((window.screen.height - windowH) / 2);

    if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) >= 4)
        isie = true;
    else
        isie = false;

    if (isie) {
        H = H + 20 + 2;
        W = W + 2;
    }

    s = ",left=" + Math.ceil(windowX) + ",top=" + Math.ceil(windowY) + ",width=" + windowW + ",height=" + (windowH / 3);

    splashWin = window.open(url, name, "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1" + s, true);
    splashWin.focus();
    splashWin.resizeTo(windowW, windowH * 2 / 3);
    splashWin.resizeTo(windowW, windowH);

    return splashWin;
}

function closeWindow() {
    self.close()
}

function moveFocus(controlName) {
    var control = document.all(controlName);
    if (control != null) {
        if (!control.disabled)
            control.focus();
        if (control.select != null)
            control.select();
    }
}

function closeWindowAndReloadParent() {
    var parentWindow = window.opener;
    window.close();
    if (parentWindow != null) {
        // extract the current document URL
        var url = parentWindow.document.location.href;
        // If there is anchor, then remove the anchor
        // because when anchor is present, location.replace
        // just moves to the anchor instead of reloading the
        // page.
        if (url.indexOf("#") > 0)
            url = url.substr(0, url.indexOf("#"));

        parentWindow.document.location.replace(url);
        // parentWindow.location = url;
    }
}

function printPage() {
    window.print();
}

function confirmDelete() {
    return confirm("Are you sure? Click OK to proceed, otherwise click CANCEL to abort.");
}

function scrollAdjust() {
    window.scrollBy(0, -50);
}

window.onbeforeprint = function() {
    var allItems = document.all.tags("DIV");
    for (var i = 0; i < allItems.length; i++) {
        var item = allItems[i];
        if (item.className == "HidePrint") {
            if (item.style != null) {
                item._innerHTML = item.innerHTML;
                item.innerHTML = "";
            }
        }
    }
}

window.onafterprint = function() {
    var allItems = document.all.tags("DIV");
    for (var i = 0; i < allItems.length; i++) {
        var item = allItems[i];
        if (item.className == "HidePrint")
            if (item.style != null)
            item.innerHTML = item._innerHTML;
    }
}