﻿
function fixIEflicker(fix) {
    try {
        document.execCommand("BackgroundImageCache", false, fix);
    } catch (err) { }
}

function forceScrollPosition(elmt, x, y, i) {
    if (elmt == null)
        return;

    if (elmt.scrollLeft == x && elmt.scrollTop == y)
        return;

    elmt.scrollLeft = x;
    elmt.scrollTop = y;

    if (parseInt(elmt.scrollLeft) != x || parseInt(elmt.scrollTop) != y) {
        if (i < 20) {
            var s = this; var e1 = elmt;
            var x1 = x; var y1 = y;
            var i1 = i + 1;
            setTimeout(function() { s.forceScrollPosition(e1, x1, y1, i1); }, 100);
        }
    }
}

function openFullScreenWindow(url) {
    var opts = "scrollbars=yes,resizable=yes,status=yes";
    if (Sys.Browser.agent == Sys.Browser.InternetExplorer && Sys.Browser.version < 7)
        opts += ",top=0,left=0,width=" + screen.availWidth + ",height=" + screen.availHeight; // bug in ie 6 fullscreen
    else
        opts += ",fullscreen=yes";
    window.open(url, '', opts);
}

function openWindow(url, name) {
    var opts = "scrollbars=yes,resizable=yes,status=yes";
    var w = window.open(url, name, opts);
    if (w != null)
        w.focus();
}

function syncCheckState(containerId, checked) {
    var elmt = document.getElementById(containerId);
    if (elmt != null) {
        var inputs = elmt.getElementsByTagName('input');
        for (var i = 0; i < inputs.length; i++) {
            var e = inputs[i];
            if (e.type == 'checkbox')
                e.checked = checked;
        }
    }
}