// Script to preload images and swap them via a function call...

var aryImages = new Array(17);

// Set the large images...
aryImages[0] = "valueshopper.jpg";
aryImages[1] = "valueshopperXL.jpg";
aryImages[2] = "smartshopper.jpg";
aryImages[3] = "powershopper.jpg";
aryImages[4] = "smartchair.jpg";
aryImages[5] = "valueshopper_small.jpg";
aryImages[6] = "valueshopperXL_small.jpg";
aryImages[7] = "smartshopper_small.jpg";
aryImages[8] = "powershopper_small.jpg";
aryImages[9] = "smartchair_small.jpg";
aryImages[10] = "valueshopper_small_dim.jpg";
aryImages[11] = "valueshopperXL_small_dim.jpg";
aryImages[12] = "smartshopper_small_dim.jpg";
aryImages[13] = "powershopper_small_dim.jpg";
aryImages[14] = "smartchair_small_dim.jpg";
aryImages[15] = "hpimage.jpg";
aryImages[16] = "ourproducts.jpg";

// Preload the large images...
for (i=0; i < aryImages.length; i++) {
	var preload = new Image();
    preload.src = aryImages[i];
}

function swap(target, imgIndex, imgPath) {
	if (document.all[target] != undefined) 
		{
			document.all[target].src = imgPath + aryImages[imgIndex];
		}
}

function hpImageSwap(largeTarget, imgIndexLarge, largeImagePath, smallTarget, imgIndexSmall, smallImagePath) {
    if (document.all[largeTarget] != undefined)
        {
            swap(largeTarget, imgIndexLarge, largeImagePath);
        }
    if (document.all[smallTarget] != undefined)
        {
            // Dim all images first...
            for (i=10; i<=14; i++) {
                var imgTarget = "img" + i;
                if (document.all[imgTarget] != undefined)
                    {
                        swap(imgTarget, i, smallImagePath);
                    }
            }
            swap(smallTarget, imgIndexSmall, smallImagePath);
        }
}
