
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
preload('treeon','topc.gif')
preload('treeoff','topbk.gif')
preload('greymar','mario0.gif')
preload('mario0','mario1.gif')
preload('mario1','mario2.gif')
var loaded = (!(navigator.userAgent.indexOf('Netscape6')+1));
test = new GifAnim("topmario","mario","mario",1,100,1)
mariopath = new Array(50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350)



function preload(imgObj,imgSrc) {
	if (document.images) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
	}
}

function systemgo(){
	if (ns4) {
		document.topimg.document.images["tree"].src = treeon.src
		block = document.topmario
		test.play(true)
	}else if (ie4) {
		document.images["tree"].src = treeon.src
		block = topmario.style
		test.play(true)
	}else{
		document.getElementById("tree").src = treeon.src
		block = document.getElementById("topmario").style
		test.play(true)
	}
}
function systemstop(){
	if (ns4) {
		test.stop()
		document.topimg.document.images["tree"].src = treeoff.src
		document.topmario.document.images["mario"].src = greymar.src
			
	}else if (ie4) {
		test.stop()
		document.images["tree"].src = treeoff.src
		document.images["mario"].src = greymar.src
	}else{
		test.stop()
		document.getElementById("tree").src = treeoff.src
		document.getElementById("mario").src = greymar.src
	}
}
function GifAnim(layer,imgName,imgSeries,end,speed,startFrame) {
	this.layer = layer
	this.imgName = imgName
	this.frame = new Array()
	for (var i=0; i<=end; i++) this.frame[i] = imgSeries+i
	this.end = end
	this.speed = speed
	this.active = false
	this.count = (startFrame)? startFrame : 0
	this.obj = imgName + "GifAnim"
	eval(this.obj + "=this")
	this.play = GifAnimPlay
	this.run = GifAnimRun
	this.stop = GifAnimStop
	this.goToFrame = GifAnimGoToFrame
}
function GifAnimPlay(loop,reset,fn) {
	if (!this.active) {
		this.active = true
		if (!loop) loop = false
		if (!reset) reset = false
		if (!fn) fn = null
		this.run(loop,reset,fn)
	}
}
function GifAnimRun(loop,reset,fn) {
	if (this.active && this.count <= this.end) {
		changeImage(this.layer,this.imgName,this.frame[this.count])
		block.left = parseInt(block.left) + 5
		if (parseInt(block.left) > 600){block.left = 5}
		this.count += 1
		setTimeout(this.obj+".run("+loop+","+reset+",\""+fn+"\")",this.speed)
		
	}
	else {
		if (loop && this.active) {
			this.count = 0
			this.run(loop,reset,fn)
		}
		else {
			this.active = false
			if (reset) this.goToFrame(0)
			eval(fn)
		}
	}
}
function test23(){
	document.write(block.left)
}
function GifAnimStop() {
	this.active = false
}
function GifAnimGoToFrame(index) {
	this.count = index
	changeImage(this.layer,this.imgName,this.frame[this.count])
}
function changeImage(layer,imgName,imgObj) {
	if (document.layers && layer!=null) eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src');
	else document.images[imgName].src = eval(imgObj+".src");
}
