﻿function showPromptDialogArguments(message, title, text) {
  this.Title = title;
  this.Message = message;
  this.Text = text;
}

function showPrompt(message, title, siteRootUrl, text) {
    return showModalDialog(siteRootUrl + '/Components/PromptDialog.aspx', new showPromptDialogArguments(message, title, text), 'dialogWidth:600px;dialogHeight:300px;');
}

function openModalDialog(url, arguments, windowSettings, callback) {
  return showModalDialog(rootUrl + "Components/ModalDialogParent.htm?" + rootUrl + url, arguments, windowSettings);
}

var frame;

function openJQueryDialog(url, title, windowWidth, windowHeight, callback) {
  var dialogFrame = $get('iframe#dialog') == null ? $('<iframe id="dialog" style="padding: 0px;" FRAMEBORDER="0" scrolling="no" />') : $('iframe#dialog');
  dialogFrame.attr('src', rootUrl + url);
  dialogFrame.data("callback", callback);
  dialogFrame.dialog({
    autoOpen: true,
    width: windowWidth,
    height: windowHeight,
    title: title,
    modal: true,
    resizable: false
  }).width(windowWidth).height(windowHeight);
  frame = dialogFrame;
}

function closeJQueryDialog(result) {
  var dialogFrame = frame; //$('iframe#dialog');
  CloseJQueryDialogFrame(dialogFrame, result);
}

function CloseJQueryDialogFrame(dialogFrame, result) {
  dialogFrame.dialog('close');
  var callback = dialogFrame.data("callback");
  if (callback !== undefined && callback != null)
    callback(result);
}


