var interview;

var Interview = Class.create({

  initialize: function() {
    this.attempts = 0;
    this.result = false;

    var myBoxObject = new curvyCorners(this.settings, "rounded");
    myBoxObject.applyCornersToAll();

    // set up draggables
    $('answers').select('li.drag').each(function(draggable) {
        new Draggable(draggable.id, { revert: true });
      },
      this);

    // Adding droppable
    Droppables.drops = [];
    Droppables.add($('question').select('p.drop')[0],
                   { accept: 'drag',
                     onDrop: this.drop.bind(this) } );

    var drop = $('question').select('p.drop')[0];
  },

  settings: { tl: { radius: 10 },
              tr: { radius: 10 },
              bl: { radius: 10 },
              br: { radius: 10 },
              antiAlias: true,
              autoPad: true },

  drop: function(draggable, droppable, event) {
    this.attempts++;
    if (draggable.hasClassName('correct')) {
      Draggables.drags.each(function(d) { d.destroy(); });
      droppable.update(draggable.innerHTML);
      this.result = (this.attempts == 1 ? 1 : 0);
      $('result_holder').value = this.result;
      $('info').show();
      $('actions').show();
    }
    else {
      $('wrong').show();
      new Effect.Pulsate(draggable.id, { duration: 1.5 });
    }
  }
});

function load_flash(server_scriptname) {
  var score_vars = {
    xml_source: server_scriptname + '/interview/stats'
  };

  swfobject.embedSWF("/swfcharts/gauge.swf",
                     "score",
                     "585",
                     "300",
                     "6",
                     "expressinstall.swf",
                     score_vars,
                     {},
                     {});
};