
var _imageRootPath;

var _images = new Object;
var _files = new Object;
var _links = new Object;

function setImageRootPath(_irp) {

    _imageRootPath = _irp;

}

function createRollover(_link_id, _mouseover_text, _mouseout_text) {

    var argCount = arguments.length;

    if ( (document.images == null) || (argCount < 4)) {
        return;
    }

    _link = document.getElementById(_link_id);
    
    if ( _link == null ) {
        return;
    }
    
                        
    var _path;
    
    if ( _imageRootPath != null ) {
        _path = _imageRootPath + "/";
    } else {
        _path = "./";
    }
    
    var _img_data = new Array;
            
    for (_a = 3; _a < argCount; _a++) {
    
        _img_id = arguments[_a][0];
        _mouseover_img = arguments[_a][1];
        _mouseout_img = arguments[_a][2];
    
        _images[_img_id]  = document.getElementById(_img_id);
    
        if ( _images[_img_id] != null ) {
        
            _img_data[ _img_data.length ] = _img_id;
            _img_data[ _img_data.length ] = _path + _mouseover_img;
            _img_data[ _img_data.length ] = _path + _mouseout_img;

            preloadImage(_path + _mouseover_img);
            preloadImage(_path + _mouseout_img);

        }
        
    }
        
    _links[_link_id] = _img_data;            
 
    _link.onmouseover = function () {

        for (_i = 0; _i < _links[_link_id].length; _i = _i + 3) {
            
            _images[ _links[_link_id][_i] ].src = 

                _files[ _links[_link_id][_i + 1] ].src;

        }

        if ( _mouseover_text != null ) {
            window.status = _mouseover_text;
        } else {
            window.status = '';
        }

    };

    _link.onmouseout = function () {

        for (_i = 0; _i < _links[_link_id].length; _i = _i + 3) {

            _images[ _links[_link_id][_i] ].src = 

                _files[ _links[_link_id][_i + 2] ].src;

        }

        if ( _mouseout_text != null ) {
            window.status = _mouseout_text;
        } else {
            window.status = '';
        }

    };

}

function preloadImage(_img_path) {

    if ( document.images && (_files[ _img_path ] == null) ) {

        _files[ _img_path ] = new Image;
        _files[ _img_path ].src = _img_path;

    }

}
