﻿if (this.HTMLElement) {
    HTMLElement.prototype.click = function() {
        var evt = this.ownerDocument.createEvent('MouseEvents');
        evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
        this.dispatchEvent(evt);
    }
}

function toggle(objId) {
    var obj = document.getElementById(objId);
    if (obj != null) {
        if (obj.style.display == 'none')
            obj.style.display = 'inline';
        else
            obj.style.display = 'none';
    }
}

function show(objId) {
    var obj = document.getElementById(objId);
    if (obj != null) {
        obj.style.display = 'inline';
    }
}

function hide(objId) {
    var obj = document.getElementById(objId);
    if (obj != null) {
        obj.style.display = 'none';
    }

}

function hideCalendar(oCalendar) {

    oCalendar.hide();

    oCalendar.get_element().blur();

}

function toggleAllCheckboxes(sender, checkboxGroup) {
    $('span').filter(function() { return $(this).attr('checkboxGroup') == checkboxGroup; }).each(function() {
        $(this).find('input:checkbox').each(function() {
            this.checked = sender.checked;
        });
    });
}

function ddlSelectedValue(ddl, value) {
    if (value != null && value != '') {
        for (i = 0; i < ddl.length; i++) {
            if (value == ddl.options[i].value) {
                ddl.options[i].selected = true;
                return;
            }
        }
    }
}

function resizeNinety(pnl) {
    var y;
    var y;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        y = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        y = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        y = document.body.clientHeight;
    }
    if (pnl != null) {
        var h = y * .9;
        pnl.style.height = h + 'px';
    }
}


function printPanel(iframeId, divId) {
    try {
        var oIframe = document.getElementById(iframeId);
        var oContent = document.getElementById(divId).innerHTML;
        var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
        if (oDoc.document) oDoc = oDoc.document;
        var pContent = oDoc.getElementById('content');
        pContent.innerHTML = oContent;
        pContent.click();
        oDoc.close();
    }
    catch (e) {
        alert(e.message);
    }
} 



