/* Put all code that should be run once the page has been loaded in here */

var $ = jQuery;

$(document).ready(function() {
  // Captify images
  $('img.captify').captify({});
});

function getParameterByName(name) {
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.href);
  if (results == null)
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

function getOrCreateDialog(id, title) {
  $box = $('#' + id);
  if (!$box.length) {
    $box = $('<div id="' + id + '" title="' + title + '"><p></p></div>').hide().appendTo('body');
  }
  return $box;
}

function dAlert(message, title) {
  $dAlert = getOrCreateDialog('dAlert', title);
  $("p", $dAlert).html(message);

  $dAlert.dialog({
        autoOpen: false,
        resizable: false,
        modal: true,
        show: "blind",
        buttons     : {
          Ok: function() {
            $(this).dialog('close');
          }
        }
      });
  $dAlert.dialog('open');
}
