/**
 * open something in a new window, forcing the use of a new window instead of a 
 * tab. 
 * usage: NewWindow.open('http://foo.bar.com', '300px', '300px');
 * usage: <a href="foo.com" onclick="NewWindow.open(this.href);">Hi</a>
 * usage: <a href="foo.com" class="new_window">Hi</a> <-- this will automagically get the new window behavior
 */
var NewWindow = {
  open: function(url, width, height) {
    var width = typeof width == "undefined" ? $(window).width() : width;
    var height = typeof height == "undefined" ? $(window).height() : height;
    var options = "";
    options += "width=" + width;
    options += ", height=" + height;
    options += ", scrollbars=yes, resizable=yes";
    window.open(url, "_blank", options);
  },
  
  observeAll: function(selector) {
    $(selector).click(function(e) {
      e.preventDefault();
      e.stopPropagation();
      var w = $.attr(this, 'w_width');
      var h = $.attr(this, 'w_height');
      
      NewWindow.open(this.href, w, h);
    });
  }
}
$(document).ready(function() {
  NewWindow.observeAll(".new_window");
});

