﻿function ConfirmBox(message, messageCount) {
    if (message == null)
        return window.showModalDialog('/MessageBox.htm', 'آيا موافقيد؟', 'dialogWidth:330px;dialogHeight:100px;status:0;scroll:0;help:0;resizable:0');
    return window.showModalDialog('/MessageBox.htm', message, 'dialogWidth:330px;dialogHeight:' + parseInt(messageCount * 25 + 75) + 'px;status:0;scroll:0;help:0;resizable:0');
}

function AlertBox(message, messageCount) {
    if (message == null)
        return window.showModalDialog('/MessageBoxAlert.htm', 'آيا موافقيد؟', 'dialogWidth:330px;dialogHeight:100px;status:0;scroll:0;help:0;resizable:0');
    return window.showModalDialog('/MessageBoxAlert.htm', message, 'dialogWidth:330px;dialogHeight:' + parseInt(messageCount * 25 + 75) + 'px;status:0;scroll:0;help:0;resizable:0');
}

function ClosePanel(panelName) {
    var p = document.getElementById(panelName);
    p.style.display = 'none';
}

function ShowPanel(panelName,flexible) {
    var p = document.getElementById(panelName);
    if (p.style.display == 'none') {
        p.style.display = '';
        var newTop = parseInt((document.body.offsetHeight - p.offsetHeight) / 2);
        var top = p.offsetTop;
        if (flexible && top > newTop)
            p.style.top = newTop + 'px';
        //p.style.left = parseInt((document.body.offsetWidth - p.offsetWidth) / 2) + 'px';
    }
    else
        p.style.display = 'none';
}

function SetUrlOnButtonShow(ListBox, HyperLinkName) {
    document.getElementById(HyperLinkName).href = ListBox.options[ListBox.selectedIndex].getAttribute('formurl');
}

function CheckUrlOnButtonShow(HyperLink, ListBoxName) {
    var ListBox = document.getElementById(ListBoxName)
    if (ListBox.selectedIndex == -1)
        HyperLink.removeAttribute('href');
}

function ChartDialog(ChartPrincipalUrl, ChartPageProperty, CardtablesHiddenFieldID, SecureChart) {
    myValue = window.showModalDialog(ChartPrincipalUrl + '?msp=1&pwu=0&sc=' + SecureChart , '', ChartPageProperty + 'center:1;status:0;help:0');
    if (myValue != '') {
        document.getElementById(CardtablesHiddenFieldID).value = myValue;
        return true;
    }
    return false;                    
}



