var maxNum = 52
var changeNum = maxNum;
var backImage = new Array();
images=new Array("GIF/01.gif","GIF/02.gif","GIF/03.gif","GIF/04.gif","GIF/05.gif", "GIF/25.gif","GIF/18.gif","GIF/24.gif","GIF/26.gif","GIF/35.gif")

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

loaded=0
a_index=0
is_error=0

var preloaded=new Array()

function tx(){	
	if (changeNum==maxNum){
	alert("This is a Magazine contains some material (adult concepts and nudity) NOT suitable for children. It also contains some stroboscopic effects, if you think you may be at risk please refrain from reading. Depending on your connection speed you may encounter some erratic behaviour whilst the GIF loads, chaos happens. All artist made gifs are numbered and referenced in the source code of this page and on the contributors page of www.thisisamagazine.com. New gif-works will be added and this Issue can grow indefinitely. Click to go forward, never go back...");}
	else {
	document.getElementById('artist').value  = maxNum-changeNum;}
	ss(changeNum);
	}

function ss(showImage){	
		if (changeNum>0){
		backImage[changeNum] = "GIF/" + changeNum-- + ".gif";
	
		if (document.body){
		document.body.background = backImage[showImage];
	
			}
		} else {
		backImage[changeNum] = "GIF/" + "endpage" + ".gif";
		if (document.body){
		document.body.background = backImage[showImage];
						}
				}
		}

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(){
a_index++
if(a_index!=images.length){
setTimeout("preload_image()",100)
}
if(a_index==run_num){
loaded=1
do_this() // FUNCTION TO RUN
}
}

function no_image(){
is_error=1
a_index++
setTimeout("is_error=0;preload_image()",100)
}

function do_this(){
alert("This would be your function to run")
}
