

images=new Array("foto/foto1.png","foto/foto2.png","foto/foto3.png","foto/foto4.png","foto/foto5.png","foto/foto6.png","foto/foto7.png","foto/foto8.png","foto/foto9.png","foto/foto10.png","foto/foto11.png","foto/foto12.png")




img_total=images.length
run_num=images.length // when to run your function

loaded=0
a_index=0
is_error=0
perc=100/images.length // percent display
percent=0 // percent display
var preloaded=new Array()

function preload_image(){
preloaded[a_index]=new Image()
preloaded[a_index].onerror=no_image
preloaded[a_index].src=images[a_index]
if(is_error==0){chk_loading()}
}

function chk_loading(){
if(preloaded[a_index].complete==true){next_image()}
else{setTimeout("chk_loading()",100)}
}

function next_image(){
img_total-- // counter display
document.getElementById("info").innerHTML="Wczytywanie..." // counter display
progress() // progress bar function

a_index++

if(a_index!=images.length){
setTimeout("preload_image()",100)
}

if(a_index==run_num){
//document.getElementById("info").style.visibility="hidden" // counter display
document.getElementById("progress_bar").style.visibility="hidden" // progress bar display
document.getElementById("info").style.visibility="hidden" // progress bar display
document.getElementById("bg_layer").style.visibility="hidden" // progress bar display
document.getElementById("pictures").style.visibility="visible" // progress bar display
//document.getElementById("bg_layer").style.visibility="hidden" // progress bar display

loaded=1
//do_this() // FUNCTION TO RUN
//location.href = "start.php"


}

}

function no_image(){
if(a_index==images.length-1){return}
is_error=1
img_total-- // counter display
progress() // progress bar display

if(a_index==images.length-1){
return
}
a_index++
setTimeout("is_error=0;preload_image()",100)
}

step=0
function progress(){
Width=document.getElementById("bg_layer").offsetWidth// width of bar
step_size=Width / images.length // calculates step size
step+=(step_size*1)
document.getElementById("progress_bar").style.width=step
}

// add onload="preload_image()" to the opening body tag



