/*
/*  jwufoopopup.js
*/

(function () {
  var $ = jQuery;
  
  $(document).ready(function () {
    $("a[href*=wufoo.com]").click(function () {
      new Popup(680, 580, { scrollbars: "yes" }).open(this.href);
      return false;
    });
  });
  
  function Popup (width, height, options) {
    this.options = {};
    this.setSize(width || 600, height || 400);
    $.extend(this.options, options || {});
  };
  
  Popup.prototype.setSize = function (width, height) {
    this.options.width  = Math.min(screen.availWidth, width);
    this.options.height = Math.min(screen.availHeight, height);
    this.updatePosition();
  };
  
  Popup.prototype.updatePosition = function () {
    this.options.top  = screen.availHeight / 2.0 - this.options.height / 2.0;
    this.options.left = screen.availWidth  / 2.0 - this.options.width  / 2.0;
  };
  
  Popup.prototype.buildOptions = function () {
    var values = [];
    for (var key in this.options)
      values.push(key + "=" + this.options[key]);
    return values.join(",");
  };
  
  Popup.prototype.open = function (url) {
    window.open(url, "", this.buildOptions());
  };
})();

