$(document).ready(function() {
  $("a.CIARD-modal").click(function () {  
    style  = "top=10, left=10, ";
    style += "width=" + $(this).attr('width')+ ", height=" + $(this).attr('height') + ", ";
    style += "status=no, menubar=no, toolbar=no, scrollbar=yes";
    href  = $(this).attr('href');
    href += '&modal';
    window.open(href, '', style);
    return false;
  });
  var regexS = "[\\?&]modal";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if(results) {
    var cancelbutton = '<input type=button value="Close Window" onClick="javascript:window.close();">';
    $("#submit").after(cancelbutton);
  }
});