var Popup = {
  open: function(options)
  {
    this.options = {
      url: '#',
      width: 600,
      height: 500,
      name:"_blank",
      location:"no",
      menubar:"no",
      toolbar:"no",
      status:"yes",
      scrollbars:"yes",
      resizable:"yes",
      left:"",
      top:"",
      normal:false
    }
    Object.extend(this.options, options || {});

    if (this.options.normal){
        this.options.menubar = "yes";
        this.options.status = "yes";
        this.options.toolbar = "yes";
        this.options.location = "yes";
    }

    this.options.width = this.options.width < screen.availWidth?this.options.width:screen.availWidth;
    this.options.height=this.options.height < screen.availHeight?this.options.height:screen.availHeight;
    var openoptions = 'width='+this.options.width+',height='+this.options.height+',location='+this.options.location+',menubar='+this.options.menubar+',toolbar='+this.options.toolbar+',scrollbars='+this.options.scrollbars+',resizable='+this.options.resizable+',status='+this.options.status
    if (this.options.top!="")openoptions+=",top="+this.options.top;
    if (this.options.left!="")openoptions+=",left="+this.options.left;
    window.open(this.options.url, this.options.name,openoptions );
    return false;
  }
} 

var remoteLink = Behavior.create({
  onclick: function() {
    Popup.open({ 
      url: this.element.getAttribute("href"), 
      normal: true  
    });
    return false;
  }
});  

var interviewPlayers = Behavior.create({
  initialize: function() {
    this.element.down().childElements().each( 
      function(row) {
       playerCol = row.childElements()[1];
       interviewUrl = playerCol.down().href;
       var s1 = new SWFObject("/images/mediaplayer.swf","mediaplayer","200","20","7");
       s1.addVariable("width","200");
       s1.addVariable("height","20");
       s1.addVariable("file", interviewUrl);
       s1.addVariable("link", interviewUrl);
       s1.write(playerCol);
      }
    );
  }
});

Event.addBehavior({
  'a.external': remoteLink,
  'table.interviews': interviewPlayers
});  

