var Amplicon = Class.create();
Object.extend(Amplicon,{
   current: false
})

Amplicon.prototype = {
  initialize: function(begin, end, name, options) {
    this.begin = begin
    this.end = end
    this.name = name
    this.feature = null
    this.options = $H(options)
  },

  fixup_options: function() {
    this.options.set('begin', this.begin-200)
    this.options.set('end', this.end+200)
    this.options.set('name', this.name)
    this.options.unset('features');
    this.options.unset('displayGroup');  
  },

  popup: function() {
    this.fixup_options()
    var _options = this.options
    Amplicon.current = this
    var m = new Control.Modal(false,{
      contents: function(){
          new Ajax.ULRequest(featureBrowser.warName()+'/amplicon?'+Hash.toQueryString(_options),{
            onLoading: function() {},
            onComplete: function(request){
              m.update(request.responseText);              
            }.bind(this)
        });
        return 'loading';
      }
    });
    m.open();
  },

  indicator: function(status) {
    var amplicon_image = ($('feature_image_' + this.name))
    var image = null
    if(status == 'FAIL') {
      image = 'red_dot.gif'
    }
    else if(status == 'SUCCESS') {
      image = 'green_dot.gif'
    }
    else {
      image = 'yellow_dot.gif'      
    }
    var success_indicator = Builder.node('img', {className: 'ball', src: featureBrowser.warName()+'/images/' + image});
    success_indicator.style.position = 'absolute'
    success_indicator.style.top=(parseInt(amplicon_image.style.top) - 3) + 'px'
    if(amplicon_image.style.right) {
      success_indicator.style.right=(parseInt(amplicon_image.style.right) - 7) + 'px'
    } else {
      success_indicator.style.left=(parseInt(amplicon_image.style.left) + parseInt(success_indicator.style.width)) + 'px'  
    }
    success_indicator.onclick = amplicon_image.onclick
    amplicon_image.parentNode.appendChild(success_indicator);
  },

  to_s: function() {
    return '[' + this.begin + ", " + this.end + ']'
  }
}