function jqueryUiDialog(sContent, sTitle, bModal) {
	if(typeof(sTitle) == "undefined") var sTitle = "Info";
	if(typeof(bModal) == "undefined") var bModal = false;
	
	$jQuery('#jqueryUiDialogContainer').html(sContent);
	$jQuery('#jqueryUiDialogContainer').dialog('option', 'bgiframe', true);
	$jQuery('#jqueryUiDialogContainer').dialog('option', 'title', sTitle);
	$jQuery('#jqueryUiDialogContainer').dialog('option', 'modal', bModal);
	$jQuery("#jqueryUiDialogContainer").dialog('open');
}

function jqueryUiDialogConfirm(sContent, sTitle, bModal, sOnConfirm) {
	if(typeof(sTitle) == "undefined") var sTitle = "Info";
	if(typeof(bModal) == "undefined") var bModal = false;

	$jQuery('#jqueryUiDialogContainer').html(sContent);
	$jQuery('#jqueryUiDialogContainer').dialog('option', 'buttons', { Ok: function() {eval(sOnConfirm);} });
	$jQuery('#jqueryUiDialogContainer').dialog('option', 'bgiframe', true);
	$jQuery('#jqueryUiDialogContainer').dialog('option', 'title', sTitle);
	$jQuery('#jqueryUiDialogContainer').dialog('option', 'modal', bModal);
	$jQuery("#jqueryUiDialogContainer").dialog('open');
}

function jqueryUiDialogConfirmAbort(sContent, sTitle, bModal, sOnConfirm, sOnCancel) {
	if(typeof(sTitle) == "undefined") var sTitle = "Info";
	if(typeof(bModal) == "undefined") var bModal = false;

	$jQuery('#jqueryUiDialogContainer').html(sContent);
	$jQuery('#jqueryUiDialogContainer').dialog('option', 'buttons', { Ok: function() {eval(sOnConfirm);}, Cancel: function() {eval(sOnCancel);} });
	$jQuery('#jqueryUiDialogContainer').dialog('option', 'bgiframe', true);
	$jQuery('#jqueryUiDialogContainer').dialog('option', 'title', sTitle);
	$jQuery('#jqueryUiDialogContainer').dialog('option', 'modal', bModal);
	$jQuery("#jqueryUiDialogContainer").dialog('open');
}

function jqueryUiDialogWindow(sUrl, bModal, iWidth, iHeight) {
	var sWindowId			= 'jqueryUiDialogWindow_' + jqueryUiDialogGetInstance();
	var sFrameId			= sWindowId + '_iFrame';
	var sButtonId			= sWindowId + '_sButton';
	var sWindowIndex		= '#' + sWindowId;
	
	if(typeof(iWidth) == "undefined" || iWidth == false) iWidth	= 600;
	if(typeof(iHeight) == "undefined" || iHeight == false) iHeight	= 400;
	if(typeof(bModal) == "undefined" || bModal == false) bModal	= false;
	
	if(sUrl.length < 1) {alert('No Url specified!'); return;}
	if(sUrl.substr(0, 7) != "http://") sUrl = "http://" + sUrl;
	
	sWindowTitle	= '<input type="hidden" id="' + sWindowId + '_iWidth" value="' + iWidth + '" />';
	sWindowTitle	= sWindowTitle + '<input type="hidden" id="' + sWindowId + '_iHeight" value="' + iHeight + '" />';
	sWindowTitle	= sWindowTitle + '<a href="javascript:jqueryUiDialogWindowMinimize(\'' + sWindowId + '\');" title="Minimize">[_]</a>';
	sWindowTitle	= sWindowTitle + '<a href="javascript:jqueryUiDialogWindowRestore(\'' + sWindowId + '\');" title="Restore">[O]</a>';
	sWindowTitle	= sWindowTitle + ' .:. ' + sUrl;
	
	$jQuery('#bodyContainer').prepend('<div id="' + sWindowId + '" style="display: none;"></div>');
	$jQuery(sWindowIndex).html('<iframe id="' + sFrameId + '" src="' + sUrl + '" style="width: 100%; height: 100%; border: 0px none;" frameborder="no">Content available with iFrames allowed only</iframe>');
	$jQuery(sWindowIndex).dialog({autoOpen: false});
	$jQuery(sWindowIndex).dialog('option', 'bgiframe', true);
	$jQuery(sWindowIndex).dialog('option', 'title', sWindowTitle);
	$jQuery(sWindowIndex).dialog('option', 'modal', bModal);
	$jQuery(sWindowIndex).dialog('option', 'width', iWidth);
	$jQuery(sWindowIndex).dialog('option', 'height', iHeight);
	$jQuery(sWindowIndex).bind('dialogbeforeclose', function(event, ui){$jQuery(sWindowIndex).remove();});
	$jQuery(sWindowIndex).dialog('open');
}

function jqueryUiDialogWindowMinimize(sWindowId) {
	var sWindowIndex		= '#' + sWindowId;
	coreSet(sWindowId + '_iWidth', 'value', $jQuery(sWindowIndex).dialog('option', 'width'));
	coreSet(sWindowId + '_iHeight', 'value', $jQuery(sWindowIndex).dialog('option', 'height'));
	$jQuery(sWindowIndex).dialog('option', 'width', 200);
	$jQuery(sWindowIndex).dialog('option', 'height', 25);
}

function jqueryUiDialogWindowRestore(sWindowId) {
	var sWindowIndex		= '#' + sWindowId;
	iWidth					= parseInt(coreGet(sWindowId + '_iWidth', 'value'));
	iHeight					= parseInt(coreGet(sWindowId + '_iHeight', 'value'));
	$jQuery(sWindowIndex).dialog('option', 'width', iWidth);
	$jQuery(sWindowIndex).dialog('option', 'height', iHeight);
	// alert(iWidth+":"+iHeight);
}

function jqueryUiDialogGetInstance() {
	jQueryInstances++;
	return jQueryInstances;
}

function jqueryUiDialogClose() {
	$jQuery("#jqueryUiDialogContainer").dialog('close');
}
