//评卷状态模块
var image_server_selector = function(option, success) {
    var object = new ImageServerSelector(option);
    success();
    return object;
}

function ImageServerSelector(option) {
    this.markControl = option.markControl;
    this.servers = option.servers;
    this.flag = option.flag != undefined && option.flag.length > 0 ? option.flag : '/ok.jpg';

    this.connect(0);
}

ImageServerSelector.prototype.connect = function(index) {
    if (isArray(this.servers) && this.servers.length > index) {
        var self = this;
        var url = this.servers[index].trim();
        if (url.length > 0) {
            $.ajax({
                url: url + this.flag,
                type: 'GET',
                cache: false,
                //timeout: 1000,
                error: function() {
                    self.connect(index + 1);
                },
                success: function() {
                    self.markControl.context.imageServer = url;
                }
            });
        } else {
            self.connect(index + 1);
        }
    }
}