// Preloader.js
// version 0.0.1
// author:      Michel Carroll
// created:    2005-06-01

/// <summary>
/// associative array to hold preloaded images
/// </summary>
var pgImages = new Array()

/// <summary>
/// checks for the existence of a preloads variable
/// and populates the pgImages array if present
/// </summary>
/// <consumer>available for client use</consumer>
function registerImages(){
    if(preloads)if(preloads.length>0){
        for(var i=0;i<preloads.length;i++){
            registerImage(preloads[i])
        }
        preloads=null
    }
}

/// <summary>
/// creates a new javascript Image object and loads it into the pgImages collection
/// returns a single node
/// </summary>
/// <consumer>available for client use</consumer>
/// <param name="inp">the input expression (the value of the text input control)</param>
/// <param name="imData" value="an array">
///     <param idx="0">the name (key) of the image - used to identify it in pgImages</param>
///     <param idx="1">the source url of the image</param>
///     <param idx="2">optional - the alt text of the image</param>
///     <param idx="3">optional - the title text of the image</param>
/// </param>
function registerImage(imData){
    pgImages[imData[0]] = new Image()
    pgImages[imData[0]].src = imData[1]
    if(imData.length>2){
        pgImages[imData[0]].alt = imData[2]
    }
    if(imData.length>3){
        pgImages[imData[0]].title = imData[3]
    }
}

