

function roll_on() {
        this.state='on';
        this.update();
}

function roll_off() {
        this.state='off';
        this.update();
}

function current_image_src() {
        if (this.state=='on') {
        return this.lit_source.src;
        } else {
        return this.unlit_source.src;
        }
}

function update_face() {
        document.images[this.name].src = this.src();
}

function rollover_image(image_name, unlit_source, lit_source) {
        this.name = image_name;
        this.unlit_source = new Image();
        this.unlit_source.src = unlit_source;
        this.lit_source = new Image();
        this.lit_source.src = lit_source;
        this.state = 'off';
        this.src = current_image_src;
        this.update = update_face;
        this.on = roll_on;
        this.off = roll_off;
}


//multiple rollovers

function multiple_rollover_image(rollover_name, unlit_source, image_names, image_sources) {
        this.name = rollover_name;
        this.image_names = image_names;
        this.image_sources = image_sources;
        this.unlit_source = new Image();
        this.unlit_source.src = unlit_source;
        this.state = 'multiple_internal_off';
        this.src = multiple_current_image_src;
        this.update = update_face;
        this.on = multiple_roll_on;
        this.off = multiple_roll_off;
}

function multiple_roll_on(desired_image) {
        this.state=desired_image;
        this.update();
}

function multiple_roll_off() {
        this.state='multiple_internal_off';
        this.update();
}

function multiple_current_image_src() {
        if (this.state=='multiple_internal_off') {
        return this.unlit_source.src;
        } else {
                for (i=0; i < this.image_names.length; i++) {
                        if (this.state==this.image_names[i]) {
                          return this.image_sources[i];
                        }
                }
        return this.unlit_source.src;
        }
}


//compound rollovers


function compound_update() {
        for (i=0; i<this.component_image.length; i++) {
                this.component_image[i].update();
        }
}

function compound_off() {
        for (i=0; i<this.component_image.length; i++) {
                this.component_image[i].state='off';
                this.component_image[i].update();
        }
}

function compound_on() {
        for (i=0; i<this.component_image.length; i++) {
                this.component_image[i].state='on';
                this.component_image[i].update();
        }
}

function compound_rollover_image(components) {
        this.component_image = new Array (components.length);

        for (i=0; i<components.length; i++) {
        this.component_image[i] = new rollover_image(components[i]);
        }
        this.update = compound_update;
        this.on = compound_on;
        this.off = compound_off;
}
