/*
 * Library:       rollover.js
 * Created On:    07-FEB-99
 * Created By:    brucek@arsdigita.com
 * Modified On:   
 * Modified By:   
 *
 * Comments:
 *  07-FEB-99 (brucek@arsdigita.com) I created this out of embedded JS
*/

/*
 * USAGE:
 *  1. Include this file in your html (<SCRIPT LANGUAGE=JavaScript SRC=/js/rollover.js>)
 *  2. Define your rollover images using make_rollover_image()
 *  3. set current_picture = "Default img_name", last_picture = Default img_name, 
 *     current_target = Default target, default_main = /graphics/Default Main Image 
 *     (see /index.tcl for an example)
 *  4. Use onMouseOver=map_window_status(Default Main Image); return true 
 *     onClick=redirect(current_target) for the main image
 *  5. Use onMouseOver=rollover(Image Name); return true for the title images
*/
function redirect( dest ) {
    window.location.href = dest;
}

function map_window_status (  ) {
    window.status = rollover[current_picture].alt;
}

function rollover_image (img_name, width, height, main_width, main_height, target, alt) {

        if (navigator.appVersion.charAt(0) >=3) {

        img_prefix = "/graphics/" + img_name;

        this.rolloff_img = new Image (width, height);

        this.rolloff_img.src = img_prefix + "_u.gif";

        this.rollover_img = new Image (width, height);

        this.rollover_img.src = img_prefix +"_l.gif";
        
        this.main = new Image (main_width, main_height);
        
        this.main.src = img_prefix + "_main.gif";
        
	this.target = target;

	this.alt = alt;
        }
}

function make_rollover_image (img_name, width, height, main_width, main_height, target, alt) {
        rollover [img_name] = new rollover_image (img_name, width, height, main_width, main_height, target, alt);
}

function rollover (img_name) {

        if (navigator.appVersion.charAt(0) >= 3) {

        current_picture = img_name;
	current_target = rollover[img_name].target;

        if (current_picture!=last_picture) {
 
                document [current_picture].src = rollover [current_picture].rollover_img.src;
                document.images ["main"].src = rollover [current_picture].main.src;

		map_window_status();
                if (last_picture != "") {
                        document.images [last_picture].src = rollover [last_picture].rolloff_img.src;
                }

                last_picture = current_picture;
        }
        }

}

function rolloff () {

        if (navigator.appVersion.charAt(0) >=3) {

        if (current_picture != "") {
                document.images [current_picture].src = rollover [current_picture].rolloff_img.src;
                document.images ["main"].src = default_main;
        }

        current_picture = "";
        last_picture = "";
        }
}
