/*
Up down slideshow Script
By Dynamic Drive (www.dynamicdrive.com)
For full source code, terms of use, and 100's more scripts, visit http://www.dynamicdrive.com
*/

if (typeof(ie) == 'undefined') var ie=document.all
if (typeof(dom) == 'undefined') var dom=document.getElementById

function move1(whichlayer){
	var sObject;
	for (sliderId in document.sliderData) {
		sObject = document.sliderData[sliderId];
		tlayer = sObject.first;
		if (tlayer.top>0&&tlayer.top<=sObject.slideSpeed){
			tlayer.top=0
			setTimeout("move1()",sObject.pausebetweenimages)
			setTimeout("move2()",sObject.pausebetweenimages)
			return
		}
		if (tlayer.top>=tlayer.document.height*-1){
			tlayer.top-=sObject.slideSpeed
			setTimeout("move1()",50)
		} else{
			tlayer.top=parseInt(sObject.scrollerheight)
			tlayer.document.write(sObject.slideimages[sObject.i])
			tlayer.document.close()
			if (sObject.i==sObject.slideimages.length-1)
			sObject.i=0
			else
			sObject.i++
		}
	}
}

function move2(whichlayer){
	var sObject;
	for (sliderId in document.sliderData) {
		sObject = document.sliderData[sliderId];
		tlayer2 = sObject.second;
		if (tlayer2.top>0&&tlayer2.top<=sObject.slideSpeed){
			tlayer2.top=0
			setTimeout("move2()",sObject.pausebetweenimages)
			setTimeout("move1()",sObject.pausebetweenimages)
			return
		}
		if (tlayer2.top>=tlayer2.document.height*-1){
			tlayer2.top-=sObject.slideSpeed
			setTimeout("move2()",50)
		} else {
			tlayer2.top=parseInt(sObject.scrollerheight)
			tlayer2.document.write(sObject.slideimages[sObject.i])
			tlayer2.document.close()
			if (sObject.i==sObject.slideimages.length-1)
			this.i=0
			else
			this.i++
		}
	}
}

function move3(){
	var sObject, tdev, second2_obj;
	for (sliderId in document.sliderData) {
		sObject = document.sliderData[sliderId];
		tdiv = sObject.first2_obj;
		second2_obj = sObject.second2_obj;
		if (parseInt(tdiv.style.top)>0&&parseInt(tdiv.style.top)<=sObject.slideSpeed){
			tdiv.style.top=0+"px"
			setTimeout("move3()",sObject.pausebetweenimages)
			setTimeout("move4()",sObject.pausebetweenimages)
			return
		}
		if (parseInt(tdiv.style.top)>=tdiv.offsetHeight*-1){
			tdiv.style.top=parseInt(tdiv.style.top)-sObject.slideSpeed+"px"
			setTimeout("move3()",50)
		} else{
			tdiv.style.top=sObject.scrollerheight
			tdiv.innerHTML=sObject.slideimages[sObject.i]
			if (sObject.i==sObject.slideimages.length-1)
			sObject.i=0
			else
			sObject.i++
		}
	}
}

function move4(whichdiv){
	var sObject, tdev2, second2_obj;;
	for (sliderId in document.sliderData) {
		sObject = document.sliderData[sliderId];
		tdiv2 = sObject.first2_obj;
		second2_obj = sObject.second2_obj;
		if (parseInt(tdiv2.style.top)>0&&parseInt(tdiv2.style.top)<=sObject.slideSpeed){
			tdiv2.style.top=0+"px"
			setTimeout("move4()",sObject.pausebetweenimages)
			setTimeout("move3()",sObject.pausebetweenimages)
			return
		}
		if (parseInt(tdiv2.style.top)>=tdiv2.offsetHeight*-1){
			tdiv2.style.top=parseInt(tdiv2.style.top)-sObject.slideSpeed+"px"
			setTimeout("move4()",50)
		} else{
			tdiv2.style.top=sObject.scrollerheight
			tdiv2.innerHTML=sObject.slideimages[sObject.i]
			if (sObject.i==sObject.slideimages.length-1)
			sObject.i=0
			else
			sObject.i++
		}
	}
}

/* START class defenition */
function GetNewSliderId() {
	if (typeof(document.nextSliderId) == 'undefined') {
		document.nextSliderId = -1;
	}
	document.nextSliderId++;
	return document.nextSliderId;
}

function AddSliderImage(imageSrc, linkUrl) {
	imageSrc = '<img src="'+imageSrc+'" />';
	if (linkUrl) {
		imageSrc = '<a href="'+linkUrl+'">'+imageSrc+'</a>';	
	}
	
	// preload the image
	pic = new Image(); 
	pic.src = imageSrc;
	// add the image to the sliders image array
	this.slideimages.push(imageSrc);
}

function AddSliderContent(divContent, divWidth) {
	if (!divWidth) var divWidth = 100;
	this.contentWidth += divWidth;
	var divSrc = '<div style="float: left; width: '+divWidth+'px; height: '+this.sliderheight+'">'+divContent+'</div>';
	this.slideimages.push(divSrc);
}

function CreateUpDownSlider() {
	if (this.slideimages.length>2)
	this.i=2
	else
	this.i=0

	document.writeln('<ilayer id="main'+this.sliderId+'" width="'+this.scrollerwidth+'" height="'+this.scrollerheight+'" visibility=hide>');
	document.writeln('<layer id="first'+this.sliderId+'" left=0 top=1 width="'+this.scrollerwidth+'">');
	if (document.layers) document.write(this.slideimages[0])
	document.writeln('</layer>');
	document.writeln('<layer id="second'+this.sliderId+'" left=0 top=0 width="'+this.scrollerwidth+'" visibility=hide>');
	if (document.layers) document.write(this.slideimages[dyndetermine=(this.slideimages.length==1)? 0 : 1])
	document.writeln('</layer>');
	document.writeln('</ilayer>');
	
	if (ie||dom){
		document.writeln('<div id="main2'+this.sliderId+'" style="position:relative;width:'+this.scrollerwidth+';height:'+this.scrollerheight+';overflow:hidden;">')
		document.writeln('<div style="position:absolute;width:'+this.scrollerwidth+';height:'+this.scrollerheight+';clip:rect(0 '+this.scrollerwidth+' '+this.scrollerheight+' 0);left:0px;top:0px">')
		document.writeln('<div id="first2'+this.sliderId+'" style="position:absolute;width:'+this.scrollerwidth+';left:0px;top:1px;">')
		document.write(this.slideimages[0])
		document.writeln('</div>')
		document.writeln('<div id="second2'+this.sliderId+'" style="position:absolute;width:'+this.scrollerwidth+';left:0px;top:0px;visibility:hidden">')
		document.write(this.slideimages[dyndetermine=(this.slideimages.length==1)? 0 : 1])
		document.writeln('</div>')
		document.writeln('</div>')
		document.writeln('</div>')
	}

	if (ie||dom) {
		this.first2_obj=ie? document.all["first2"+this.sliderId] : document.getElementById("first2"+this.sliderId)
		this.second2_obj=ie? document.all["second2"+this.sliderId] : document.getElementById("second2"+this.sliderId)
		
		this.second2_obj.style.top=this.scrollerheight
		this.second2_obj.style.visibility='visible'
		
		if (typeof(document.sliderLoad) == 'undefined') {
			if(typeof window.addEventListener != 'undefined') {
				window.addEventListener('load', move3, false);
			} else if(typeof document.addEventListener != 'undefined') {
				document.addEventListener('load', move3, false);
			} else if(typeof window.attachEvent != 'undefined') {
				window.attachEvent('onload', move3);
			}
			document.sliderLoad = true;
		}
	} else if (document.layers){
		document.main.visibility='show'
		this.first = document.main.document["first"+this.sliderId];
		this.second = document.main.document["second"+this.sliderId];
		document.main.document.second.top=parseInt(this.scrollerheight)+sObject.slideSpeed
		document.main.document.second.visibility='show'
		
		if (typeof(document.sliderLoad) == 'undefined') {
			if(typeof window.addEventListener != 'undefined') {
				window.addEventListener('load', move1, false);
			} else if(typeof document.addEventListener != 'undefined') {
				document.addEventListener('load', move1, false);
			} else if(typeof window.attachEvent != 'undefined') {
				window.attachEvent('onload', move1);
			}
			document.sliderLoad = true;
		}
	}
}

function SetScrollerWidth(scrollerWidth) {
	this.scrollerwidth = scrollerWidth+'px';
}

function SetScrollerHeight(scrollerHeight) {
	this.scrollerheight = scrollerHeight+'px';
}

function SetPauseBetweenImages(pauseSeconds) {
	this.pausebetweenimages = (pauseSeconds * 1000);
}

function SetSliderSpeed(speed) {
	this.slideSpeed = speed;
}

function UpDownSlider(sliderId) {
	this.GetNewSliderId = GetNewSliderId;
	this.AddSliderImage = AddSliderImage;
	this.AddSliderContent = AddSliderContent;
	this.CreateUpDownSlider = CreateUpDownSlider;
	this.SetScrollerWidth = SetScrollerWidth;
	this.SetScrollerHeight = SetScrollerHeight;
	this.SetPauseBetweenImages = SetPauseBetweenImages;
	this.SetSliderSpeed = SetSliderSpeed;
	
	if (!sliderId) sliderId = this.GetNewSliderId();
	if (typeof(document.sliderData) == 'undefined') document.sliderData = new Array();
	document.sliderData[sliderId] = this;
	this.sliderId = sliderId;
	
	//set the scrollerwidth and scrollerheight to the width/height of the LARGEST image in your slideshow!
	this.scrollerwidth='294px'
	this.scrollerheight='90px'
	//3000 miliseconds=3 seconds
	this.pausebetweenimages=3000
	this.slideSpeed = 5;
	
	//configure the below variable to change the images used in the slideshow. If you wish the images to be clickable, simply wrap the images with the appropriate <a> tag
	this.slideimages=new Array();
}

/* END class defenition */
