// RATER
// =====
// TODO:
// * observe left / right keys
// * NOT WORKING IN SAFARI
var Recorder = {
  initialize:function(opts){
    
    this.container = $(opts.container);
    this.player_dims = {width:this.container.getWidth() - 10, height:this.container.getHeight() - 10}
    
    this.saveUrl = opts.saveUrl;
    
    var flashvars = {};
    
    flashvars.type = "rtmp";
    flashvars.streamer = opts.rtmpUrl;
    flashvars.max_record_time = opts.maxRecordTime;
    flashvars.file = opts.file;

    flashvars.token = opts.token;
    flashvars.rtmp_url = opts.rtmpUrl;
    flashvars.save_callback = "Recorder.save"
    
    flashvars.image = opts.image;
    
    flashvars.width = this.player_dims.width;
    flashvars.height = this.player_dims.height;
    flashvars.fullscreen = "true";
    flashvars.controlbar = "over";
    flashvars.skin = "/iballz_skin.swf";
    flashvars.tracecall = "flash";

    var params = {wmode:"transparent", allowfullscreen:"true", allowscriptaccess:'always'};
    var attributes = {};
    attributes.align = "top";

    swfobject.embedSWF("/lemur_player.swf", this.container.id, this.player_dims.width, this.player_dims.height,
     "9.0.115", VIDEOS_DOMAIN+"expressInstall.swf", flashvars, params, attributes);

    // swfobject.embedSWF(VIDEOS_DOMAIN+"player.swf", this.container.id, this.player_dims.width, this.player_dims.height,
    //  "9.0.115", VIDEOS_DOMAIN+"expressInstall.swf", flashvars, params, attributes);

    this.duration = opts.duration;
   },
   
   save:function(){
     // new Ajax.Updater('new_reel', this.saveUrl, {method:'get',evalScripts:true});
     new Ajax.Request(this.saveUrl, {method:'get', evalScripts:true});
   }
}