/**
* JavaScript bindings for PHP-Captcha
*/
IwCaptcha = function(id) {
    if (!id) {
        id = 'captcha';
    }
    
    this.id = id;
    this.image = $('#' + this.id + '-image')[0];
    this.link = $('#' + this.id + '-reload-link');  
    
    this.attach();  
}

IwCaptcha.prototype.attach = function() {
    var captcha = this;
    this.link.bind(
        'click',
        function(e) {
            e.preventDefault();
            e.stopPropagation();
            captcha.reload();
        }
    );    
}

IwCaptcha.prototype.reload = function() {
    var date = new Date();
    this.image.src = Paths.www + '/captcha.php?reload=' + date.getTime();
}