// static
Author.instanceList = new Array();

//constructor
function Author(id, name, rank, articlesNumber, joinDate, imgSrc, aboutMe) {
    this.id = id;
    this.name = name;
    this.rank = rank;
    this.articlesCount = articlesNumber;
    this.joinDate = joinDate;
    if (imgSrc != "") {
        this.imgSrc = imgSrc;
    } else {
        this.imgSrc = RESOURCE_PATH + "/new_images/no_author.gif";
    }
    this.aboutMe = aboutMe;
    Author.instanceList[Author.instanceList.length] = this
    
}

//<img src="http://resources.sportingo.com/new_images/registration-empty_pic.gif" alt="" />


Author.getAuthorById = function(id) {

    for (var i = 0; i < Author.instanceList.length; i++) {
        if (Author.instanceList[i].id == id) {
            return Author.instanceList[i];
        }
    }
    return null;
}

Author.getRankImgSrc = function(rank) {

    switch (rank) {
        case '0':
            return "rookie.png";
            
            break;
        case '1':
            return "pro.png";
            break;
        case '2':
            return "all_star.png";
            break;
        case '3':
            return "mvp.png";
            break;
        case '4':
            return "hall_of_fame.png";
            break;
       case '5':
            return "staff.png";
            break;            
    }
}

Author.preloadImages = function () {
    for (var i = 0; i < Author.instanceList.length; i++) {
        new Image().src = Author.instanceList[i].imgSrc;
    }
}

if (!window.attachEvent && window.addEventListener) {
    window.addEventListener("load", Author.preloadImages, false);
} else {
    window.attachEvent("onload", Author.preloadImages);
}