function setDialogProperties(showCloseBtn) 
{
    showCloseBtn = showCloseBtn == null ? true : showCloseBtn;

    var dialog = $('#modalDialog');
    dialog.css({
    	  height  : $(document).height()
        , width   : $(document).width()
        , top 	  : 0
        , left 	  : 0
        , filter  : 'alpha(opacity=100)'
        , opacity : 1
    })
    
    var innerDialog = $('#innerModalDialog');
    var dWidth = innerDialog.width();
    if ($('#innerModalDialog iframe').length > 0) {
    	dWidth = $('#innerModalDialog iframe').width();
    }
    var dTop  = ($(window).height() - innerDialog.height()) / 2
    				+ $(document).scrollTop();
    var dLeft = ($(window).width() - dWidth) / 2;
    innerDialog.css({
        top    : dTop,
        left   : dLeft
    });

    var closeButton = $('#closeDialogButton');
    closeButton.css({
        top     : dTop - closeButton.height(),
        left    : dLeft + dWidth,
        display : showCloseBtn ? "block" : "none"
    });
}

function showDialog(URL, height, width, showCloseBtn) {

    if (height == null) height = 480;
    if (width == null) width = 640;

    $('#innerModalDialog').css({
        height : height,
        width  : width
    });
    // var innerDialog = document.getElementById("innerModalDialog");
    // innerDialog.style.height = height;
    // innerDialog.style.width = width;

    setDialogProperties(showCloseBtn);
    document.body.style.overflowY = "hidden";
    document.body.style.overflowX = "hidden";

    
    var dialog = document.getElementById("modalDialog");
    
    if (URL != null)
        loadMainContent(URL, null, "innerModalDialog"
        	, function () { setDialogProperties(showCloseBtn); });
    
    dialog.style.display = "block";
}

function hideDialog() {
    var dialog = document.getElementById("modalDialog");
    dialog.style.display = "none";
    document.body.style.overflowY = "scroll";
    document.body.style.overflowX = "scroll";
    var innerDialog = document.getElementById("innerModalDialog");
	innerDialog.style.backgroundColor = "#ffffff";
    innerDialog.innerHTML = "";
}
