
//Copyright(C)2001 S9 Technologies
// Includes portions of scripts Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynduo/

// BrowserCheck Object
// provides browser checking variables
function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.version = navigator.appVersion
	this.v = parseInt(this.version)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.version.indexOf('MSIE 4')>0)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.min = (this.ns||this.ie)
}
is = new BrowserCheck()

// DynLayer Constructor
function DynLayer(id,nestref,frame) {
	if (!DynLayer.set && !frame) DynLayerInit()
	if (is.ns) {
		if (is.ns) {
			if (!frame) {
				if (!nestref) var nestref = DynLayer.nestRefArray[id]
				if (DynLayer.useTest && !DynLayerTest(id,nestref)) return
				this.css = (nestref)? eval("document."+nestref+".document."+id) : document.layers[id]
			}
			else this.css = (nestref)? eval("parent."+frame+".document."+nestref+".document."+id) : parent.frames[frame].document.layers[id]
			this.elm = this.event = this.css
			this.doc = this.css.document
		}
		if (is.ns5) {
			this.elm = document.getElementById(id)
			this.css = this.elm.style
			this.doc = document
		}
		this.x = this.css.left
		this.y = this.css.top
		this.w = this.css.clip.width
		this.h = this.css.clip.height
	}
	else if (is.ie) {
		this.elm = this.event = (frame)? parent.frames[frame].document.all[id] : document.all[id]
		this.css = (frame)? parent.frames[frame].document.all[id].style : document.all[id].style
		this.doc = document
		this.x = this.elm.offsetLeft
		this.y = this.elm.offsetTop
		this.w = (is.ie4)? this.css.pixelWidth : this.elm.offsetWidth
		this.h = (is.ie4)? this.css.pixelHeight : this.elm.offsetHeight
	}
	this.id = id

	this.obj = id + "DynLayer"
	eval(this.obj + "=this")
	this.show = DynLayerShow
	this.hide = DynLayerHide
	this.clipInit = DynLayerClipInit
	this.write = DynLayerWrite
}

function DynLayerShow() {
	this.css.visibility = (is.ns)? "show" : "visible"
}
function DynLayerHide() {
	this.css.visibility = (is.ns)? "hide" : "hidden"
}


// DynLayer Clip Methods (optional)
// provides layer clipping functionality
function DynLayerClipInit(clipTop,clipRight,clipBottom,clipLeft) {
	this.clipTo = DynLayerClipTo
	this.clipBy = DynLayerClipBy
	this.clipValues = DynLayerClipValues
	if (is.ie) {
		if (arguments.length==4) this.clipTo(clipTop,clipRight,clipBottom,clipLeft)
		else if (is.ie4) this.clipTo(0,this.css.pixelWidth,this.css.pixelHeight,0)
	}
}
function DynLayerClipTo(t,r,b,l) {
	if (t==null) t = this.clipValues('t')
	if (r==null) r = this.clipValues('r')
	if (b==null) b = this.clipValues('b')
	if (l==null) l = this.clipValues('l')
	if (is.ns) {
		this.css.clip.top = t
		this.css.clip.right = r
		this.css.clip.bottom = b
		this.css.clip.left = l
	}
	else if (is.ie) this.css.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"
}
function DynLayerClipBy(t,r,b,l) {
	this.clipTo(this.clipValues('t')+t,this.clipValues('r')+r,this.clipValues('b')+b,this.clipValues('l')+l)
}
function DynLayerClipValues(which) {
	if (is.ie) var clipv = this.css.clip.split("rect(")[1].split(")")[0].split("px")
	if (which=="t") return (is.ns)? this.css.clip.top : Number(clipv[0])
	if (which=="r") return (is.ns)? this.css.clip.right : Number(clipv[1])
	if (which=="b") return (is.ns)? this.css.clip.bottom : Number(clipv[2])
	if (which=="l") return (is.ns)? this.css.clip.left : Number(clipv[3])
}

// DynLayer Write Method (optional)
// rewrites the contents of the layer
function DynLayerWrite(html) {
	if (is.ns) {
		this.doc.open()
		this.doc.write(html)
		this.doc.close()
	}
	else if (is.ie) {
		this.event.innerHTML = html
	}
}

// DynLayerTest Function (optional - disable with DynLayer.useTest=false)
// makes sure the layer target is correct before assigning the DynLayer, outputs useful info if incorrect
function DynLayerTest(id,nestref) {
	var ref = new Array()
	if (nestref) ref = nestref.split('.document.')
	ref[ref.length] = id
	var refstr = (is.ns)? 'document.'+ref[0] : 'document.all.'+ref[0]
	for (var i=1; i<=ref.length; i++) {
		if (eval(refstr)) {
			if (ref.length==i) return true
			else refstr += (is.ns)? '.document.'+ref[i] : '.all.'+ref[i]
		}
		else {
			var str ='DynLayer Error:'
			for (j in ref) {
				str += '\n'+ref[j]
				if (j==i-1) str += '  <-- this layer cannot be found'
			}
			if (DynLayerTest.count++<5) alert(str)
			else alert("Too many DynLayer errors, quitting.")
			return false
		}
	}
	return false
}
DynLayerTest.count = 0

// DynLayerInit
// automatically retrieves nested heirarchy of the layer and defines DynLayers named with "Div"
function DynLayerInit(nestref) {
	if (!DynLayer.set) DynLayer.set = true
	if (is.ns) {
		if (nestref) ref = eval('document.'+nestref+'.document')
		else {nestref = ''; ref = document;}
		for (var i=0; i<ref.layers.length; i++) {
			var divname = ref.layers[i].name
			DynLayer.nestRefArray[divname] = nestref
			var index = divname.indexOf("Div")
			if (index > 0) {
				eval(divname.substr(0,index)+' = new DynLayer("'+divname+'","'+nestref+'")')
			}
			if (ref.layers[i].document.layers.length > 0) {
				DynLayer.refArray[DynLayer.refArray.length] = (nestref=='')? ref.layers[i].name : nestref+'.document.'+ref.layers[i].name
			}
		}
		if (DynLayer.refArray.i < DynLayer.refArray.length) {
			DynLayerInit(DynLayer.refArray[DynLayer.refArray.i++])
		}
	}
	else if (is.ie) {
		for (var i=0; i<document.all.tags("DIV").length; i++) {
			var divname = document.all.tags("DIV")[i].id
			var index = divname.indexOf("Div")
			if (index > 0) {
				eval(divname.substr(0,index)+' = new DynLayer("'+divname+'")')
			}
		}
	}
	return true
}
DynLayer.nestRefArray = new Array()
DynLayer.refArray = new Array()
DynLayer.refArray.i = 0
DynLayer.set = false
DynLayer.useTest = true

// CSS function (optional)
// returns CSS syntax for generated layers
function css(id,left,top,width,height,color,vis,z,other) {
	if (id=="START") return '<STYLE TYPE="text/css">\n'
	else if (id=="END") return '</STYLE>'
	var str = (left!=null && top!=null)? '#'+id+' {position:absolute; left:'+left+'px; top:'+top+'px;' : '#'+id+' {position:relative;'
	if (arguments.length>=4 && width!=null) str += ' width:'+width+'px;'
	if (arguments.length>=5 && height!=null) {
		str += ' height:'+height+'px;'
		if (arguments.length<9 || other.indexOf('clip')==-1) str += ' clip:rect(0px '+width+'px '+height+'px 0px);'
	}
	if (arguments.length>=6 && color!=null) str += (is.ns)? ' layer-background-color:'+color+';' : ' background-color:'+color+';'
	if (arguments.length>=7 && vis!=null) str += ' visibility:'+vis+';'
	if (arguments.length>=8 && z!=null) str += ' z-index:'+z+';'
	if (arguments.length==9 && other!=null) str += ' '+other
	str += '}\n'
	return str
}
function writeCSS(str,showAlert) {
	str = css('START')+str+css('END')
	document.write(str)
	if (showAlert) alert(str)
}

// wipe functions follow
function DynLayerShrink(num,speed,fw){
        endt= (this.clipValues('t') +this.clipValues('b') ) /2
	  endb= endt
        endl= (this.clipValues('l') +this.clipValues('r') ) /2
        endr= endl
        fw = "Vanish"
        this.wipeTo(endt,endr,endb,endl,num,speed,fw) 
}
function DynLayerWipeInit(clipTop,clipRight,clipBottom,clipLeft) {
	if (arguments.length==4) this.clipInit(clipTop,clipRight,clipBottom,clipLeft)
	else this.clipInit()
}
function DynLayerWipeTo(endt,endr,endb,endl,num,speed,fw) {
	var distt = (endt!=null)? endt-this.clipValues('t'):0
	var distr = (endr!=null)? endr-this.clipValues('r'):0
	var distb = (endb!=null)? endb-this.clipValues('b'):0
	var distl = (endl!=null)? endl-this.clipValues('l'):0
	this.wipeStart(distt,distr,distb,distl,endt,endr,endb,endl,num,speed,fw)
}
function DynLayerWipeStart(distt,distr,distb,distl,endt,endr,endb,endl,num,speed,fw) {
	if (this.wipeActive) return
	if (!fw) fw = null
	this.wipeActive = true
	this.wipe(distt/num,distr/num,distb/num,distl/num,endt,endr,endb,endl,this.clipValues('t'),this.clipValues('r'),this.clipValues('b'),this.clipValues('l'),num,1,speed,fw)
}
function DynLayerWipe(dt,dr,db,dl,endt,endr,endb,endl,st,sr,sb,sl,num,i,speed,fw) {
	if (!this.wipeActive) return
	if (i++ < num) {
		this.clipTo(st+i*dt,sr+i*dr,sb+i*db,sl+i*dl)
		setTimeout(this.obj+".wipe("+dt+","+dr+","+db+","+dl+","+endt+","+endr+","+endb+","+endl+","+st+","+sr+","+sb+","+sl+","+num+","+i+","+speed+",\""+fw+"\")",speed)
	}
	else {
		this.wipeActive = false
		this.clipTo(endt,endr,endb,endl)
	      if(fw=="Vanish"){ this.css.visibility = (is.ns)? "hide" : "hidden"}

	}
}
DynLayer.prototype.wipeInit = DynLayerWipeInit
DynLayer.prototype.wipeTo = DynLayerWipeTo
DynLayer.prototype.wipeStart = DynLayerWipeStart
DynLayer.prototype.wipe = DynLayerWipe
DynLayer.prototype.Shrink = DynLayerShrink
DynLayer.prototype.Hide = DynLayerHide
DynLayer.prototype.clipTo=DynLayerClipTo
//ShowImage functions follow

DynLayer.prototype.ShowImage = DynLayerShowImage

function DynLayerShowImage(hgt,wid) {
    this.clipTo(50,75,75,50)   // start small
    this.css.visibility = (is.ns)? "show" : "visible" 
    this.wipeTo(0,wid,hgt,0,10,20)
}


// Main Program: Play sequence
// image hgt=height+2*vspace
// image wid=width+2*hspace
function xPlay(){
if (sequenceCount == maxCount) {  //play sequence done
clearTimeout(playtimer);
sequenceCount = 0;
}
else {
sequenceCount++;
     if (sequenceCount == 4) {
            IMlayer[1].ShowImage(210,210)
		Tlayer[1].show()
		Blayer[1].show()
     }
     if (sequenceCount == 40) {IMlayer[1].Shrink(15,20)}
     if (sequenceCount == 46) {
            Tlayer[1].hide()
            Blayer[1].hide()
            IMlayer[2].ShowImage(210,210)
    Tlayer[2].show()
    Blayer[2].show()
     }
if (sequenceCount == 80) {IMlayer[2].Shrink(10,20)}
if (sequenceCount == 88){
            Tlayer[2].hide()
            Blayer[2].hide()
            IMlayer[3].ShowImage(210,210)
     Blayer[3].show()
     }
if (sequenceCount == 94) {Tlayer[3].show() }
if (sequenceCount == 120) {IMlayer[3].Shrink(5,20)}
if (sequenceCount == 124){
                   Tlayer[3].hide()
                   Blayer[3].hide()
                   IMlayer[4].ShowImage(210,210)
	 Tlayer[4].show()
	 Blayer[4].show()
     }
if (sequenceCount ==160) {
     IMlayer[4].Shrink()
            Tlayer[4].hide()
            Blayer[4].hide()
     Tlayer[5].show()
     Blayer[5].show()
     }
if (sequenceCount ==170) {IMlayer[5].ShowImage(210,210)}
if (sequenceCount == 200) {
     IMlayer[5].Shrink()
            Tlayer[5].hide()
            Blayer[5].hide()
            IMlayer[6].ShowImage(210,210)
    Tlayer[6].show()
    Blayer[6].show()
     }
   if (sequenceCount ==250) {Tlayer[7].show()}
playtimer = setTimeout('Play()', playSpeed);
}
}