/*
 * @(#) xtd.js  1.0 02/10/04
 *
 * Copyright 2002 Orgdot AS. All Rights Reserved.
 * http://www.orgdot.com/javaopensource
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

/**
 * Javascript utilities that should work on both old and new browsers
 *
 * @author      Olaf Havnes
 * @version     1.0, 10/04/02
 * @since       SWFIT1.0
 */

/**
 * Preload an image
 */
function preloadImage(url)
{
    var im = new Image();
    im.src = url;
    return im;
}

/**
 * Preload an array of images
 */
function preloadImages (urls)
{
    var ims = new Array();
    if (document.images != null) for (var i = 0; i < urls.length; i++)
    {
        ims [i] = new Array();
        for (var j = 0; j < urls[i].length; j++) ims[i][j] = preloadImage (urls[i][j]);
    }
    return ims;
}

/**
 * Swap images using the preloaded array
 */
function flipIm(i, j)
{
    if
    (
        document.images &&
        ims.length >= i &&
        ims[i].length >= j &&
        eval ("document.images.im_" + i) != null
    )
    eval ("document.images.im_" + i + ".src=ims[" + i + "][" + j + "].src");
    return true;
}



