function ShowHidePanel(id)
{
    if((panel = document.getElementById(id)) && (a = document.getElementById(id+':a')))
    {
        a.className = (panel.style.display == 'none')?'Expand':'Collapse';
        panel.style.display = (panel.style.display == 'none')?'':'none';
    }
}

function OnSubmit(DialogId,ButtonId,ObjectId)
{
    var form = document.forms[DialogId];
    if(form)
    {
        if(ButtonId != "cancel")
        {
            var Items = form.elements;
            var Parameters = "submit="+escape(encodeURI(ButtonId));
            for(i=0;i<Items.length;i++)
            {
                Parameters += "&";
                Parameters += Items[i].name + "="+escape(encodeURI(Items[i].value));
            }
            Ajax().Post(form.action, Parameters, ObjectId);
        }
        HideDialog();
    }
}

function HideDialog()
{
    var busyLayer = document.getElementById("busy_layer");
    var busyDialog = document.getElementById("dialog");
    busyDialog.innerHTML = "";
    busyDialog.style.display = "none";
    busyLayer.style.visibility = "hidden";
}

function ShowDialog(Width,Height,AjaxUrl)
{
    var busyLayer = document.getElementById("busy_layer");
    var busyDialog = document.getElementById("dialog");

    if (window.innerHeight && window.scrollMaxY) {
        yScroll = window.innerHeight + window.scrollMaxY;
        var deff = document.documentElement;
        var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
        yScroll -= (window.innerHeight - hff);
    } else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){
        yScroll = document.body.scrollHeight;
    } else {
        yScroll = document.body.offsetHeight;
    }

    if (busyLayer != null) {
        busyLayer.style.visibility = "visible";
        busyLayer.style.height = yScroll;
    }

    
    busyDialog.style.left = ((document.body.clientWidth>>1) - (Width>>1));
    busyDialog.style.top = ((document.body.clientHeight>>1) - (Height>>1));

    
    busyDialog.style.height = Height;
    busyDialog.style.width = Width;
    busyDialog.style.display ="";

    Ajax().Get(AjaxUrl, 'dialog');
}



