/******************************************************************************
* FILE:		preload.js
* DESCRIPTION:	JavaScript images preloader
* COMPANY:	mediacube web solutions - http://www.mediacube.ws
* AUTHOR:	Marco Del Tongo - http://www.marcodeltongo.com
*
* VERSION:	1.0
* UPDATED:	February 20, 2002
*
* Copyright © 2000, 2001, 2002 by Marco Del Tongo & mediacube web solutions.
******************************************************************************/

// You may modify the following:
    var locationAfterPreload = "index2.html" // URL of the page after preload finishes
    var lengthOfPreloadBar = 320 // Length of preload bar (in pixels)
    var heightOfPreloadBar = 32 // Height of preload bar (in pixels)
    // Put the URLs of images that you want to preload below (as many as you want)
//    var yourImages = new Array("http://www.yourdomain.com/test1.gif","http://www.yourdomain.com/test2.gif","http://www.yourdomain.com/test3.gif","http://www.yourdomain.com/test4.gif","http://www.yourdomain.com/test5.gif")
var yourImages = new Array("gfx/sfondo_top.gif","gfx/sfondo_main.gif","gfx/mediacube_ws.gif","gfx/lattimo.gif","gfx/loghini_new.gif","gfx/top.jpg","gfx/main.gif","gfx/menu_a.gif","gfx/menu_b.gif","gfx/menu_c.gif","gfx/menu_d.gif","gfx/menu_e.gif","gfx/menu_f.gif","gfx/menu_g.gif","gfx/titolo_a.gif","gfx/titolo_b.gif","gfx/titolo_c.gif","gfx/titolo_d.gif","gfx/titolo_e.gif","gfx/titolo_f.gif","gfx/titolo_g.gif");

// Do not modify anything beyond this point!
if (document.images) {
    var dots = new Array() 
    dots[0] = new Image(1,1)
    dots[0].src = "gfx/bg.gif" // default preloadbar color (note: You can substitute it with your image, but it has to be 1x1 size)
    dots[1] = new Image(1,1)
    dots[1].src = "gfx/fg.gif" // color of bar as preloading progresses (same note as above)
    var preImages = new Array(),coverage = Math.floor(lengthOfPreloadBar/yourImages.length),currCount = 0
    var loaded = new Array(),i,covered,timerID
    var leftOverWidth = lengthOfPreloadBar%coverage
}
function loadImages() { 
    for (i = 0; i < yourImages.length; i++) { 
        preImages[i] = new Image()
        preImages[i].src = yourImages[i]
    }
    for (i = 0; i < preImages.length; i++) { 
        loaded[i] = false
    }
    checkLoad()
}
function checkLoad() {
    if (currCount == preImages.length) { 
        top.window.location.replace(locationAfterPreload)
        return
    }
    for (i = 0; i <= preImages.length; i++) {
        if (loaded[i] == false && preImages[i].complete) {
            loaded[i] = true
            eval("document.img" + currCount + ".src=dots[1].src")
            currCount++
        }
    }
    timerID = setTimeout("checkLoad()",10) 
}

// It is recommended that you put a link to the target URL just in case if the visitor wants to skip preloading
// for some reason, or his browser doesn't support JavaScript image object.
if (document.images) {
    var preloadBar = ''
    for (i = 0; i < yourImages.length-1; i++) {
        preloadBar += '<img src="' + dots[0].src + '" width="' + coverage + '" height="' + heightOfPreloadBar + '" name="img' + i + '" align="absmiddle">'
    }
    preloadBar += '<img src="' + dots[0].src + '" width="' + (leftOverWidth+coverage) + '" height="' + heightOfPreloadBar + '" name="img' + (yourImages.length-1) + '" align="absmiddle">'
    document.write(preloadBar)
    loadImages()
}
