/*
 * flashingtext.js
 * fait clignoter un text
 */

var FlashingItem = function(fieldId, colorVisible, colorHidden) {
    this.field = document.getElementById(fieldId);
    this.colorVisible = colorVisible;
    this.colorHidden = colorHidden;
    this.timeVisible = 3000;
    this.timeHidden = 1000;
    this.visible = true;
    
    this.flash = function() {
        var obj = this;
        
        if (this.visible) {
            this.field.style.color = this.colorVisible;
            setTimeout(function() { obj.flash() }, this.timeVisible);
        } else {
            this.field.style.color = this.colorHidden;
            setTimeout(function() { obj.flash() }, this.timeHidden);
        }
        
        this.visible = !this.visible;
    }

    if (this.field != null) {
        this.flash();
    }
}

