// horizontal distance from one piture to the the next picture (pixels)
var distancepictopic=0

// distance of the scroller to the left margin of the browser-window (pixels)
var scrollerleft=0

// distance of the scroller to the top margin of the browser-window (pixels)
var scrollertop=0

// height of the scroller (pixels)
var scrollerheight=slideheight+67

// speed 1: lower means faster
var pause=20

// speed 2: higher means faster
var step=2

// do not edit the variables below
var newstep=step
var clipleft,clipright,cliptop,clipbottom
var i_picture=0
var timer
var picturecontent=""

var ns4=document.layers?1:0
var ns6=document.getElementById&&!document.all?1:0 
var ie=document.all?1:0

var preloadedimages=new Array()
for (i=0;i<slideurl.length;i++){
	preloadedimages[i]=new Image()
	preloadedimages[i].src=slideurl[i]
}

function init() {
    if (ie) {
		getpicturecontent()
		picturediv.innerHTML=picturecontent
		document.all.picturediv.style.posTop=scrollertop
        document.all.picturediv.style.posLeft=scrollerleft+scrollerwidth
		clipleft=0
		clipright=0
		cliptop=0
		clipbottom=scrollerheight
		document.all.picturediv.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
		scrollpicture()
		
    }
	if (ns6) {
		getpicturecontent()
		document.getElementById('picturediv').innerHTML=picturecontent 
		document.getElementById('picturediv').style.top=scrollertop
        document.getElementById('picturediv').style.left=scrollerleft+scrollerwidth
		clipleft=0
		clipright=0
		cliptop=0
		clipbottom=scrollerheight
		document.getElementById('picturediv').style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
		scrollpicture()  
    }
	if (ns4) {
		getpicturecontent()
		document.roof.document.picturediv.document.write(picturecontent)
		document.roof.document.picturediv.document.close()
		picturewidth=document.roof.document.picturediv.document.width
		document.roof.document.picturediv.top=scrollertop
		document.roof.document.picturediv.left=scrollerleft+scrollerwidth
		document.roof.document.picturediv.clip.left=0
		document.roof.document.picturediv.clip.right=0
		document.roof.document.picturediv.clip.top=0
		document.roof.document.picturediv.clip.bottom=scrollerheight
        scrollpicture()
    }
}

function scrollpicture() {
    if (ie) {
		if (document.all.picturediv.style.posLeft>=scrollerleft-picturewidth) {
			document.all.picturediv.style.posLeft-=step
			clipright+=step
			if (clipright>scrollerwidth) {
				clipleft+=step
			}
			document.all.picturediv.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"		
			var timer=setTimeout("scrollpicture()",pause)
		}
		else {
			resetposition()
		}
	}
	if (ns6) {
		if (parseInt(document.getElementById('picturediv').style.left)>=scrollerleft-picturewidth) {
	document.getElementById('picturediv').style.left=parseInt(document.getElementById('picturediv').style.left)-step
			clipright+=step
			if (clipright>scrollerwidth) {
				clipleft+=step
			}
			document.getElementById('picturediv').style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"		
			var timer=setTimeout("scrollpicture()",pause)
		}
		else {
			resetposition()
		}
	}
   if (ns4) {
		if (document.roof.document.picturediv.left>=scrollerleft-picturewidth) {
			document.roof.document.picturediv.left-=step
			document.roof.document.picturediv.clip.right+=step
			if (document.roof.document.picturediv.clip.right>scrollerwidth) {
				document.roof.document.picturediv.clip.left+=step
			}
			var timer=setTimeout("scrollpicture()",pause)
		}
		else {
			resetposition()
		}
	}
}

function onmsover() {
	step=0
}
function onmsout() {
	step=newstep
}

function resetposition() {
	if (ie) {
        document.all.picturediv.style.posLeft=scrollerleft+scrollerwidth
		clipleft=0
		clipright=0
		document.all.picturediv.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
        scrollpicture()
	}
	if (ns6) {
        document.getElementById('picturediv').style.left=scrollerleft+scrollerwidth
		clipleft=0
		clipright=0
		document.getElementById('picturediv').style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
        scrollpicture()
	}
	if (ns4) {
		document.roof.document.picturediv.left=scrollerleft+scrollerwidth
		document.roof.document.picturediv.clip.left=0
		document.roof.document.picturediv.clip.right=0
        scrollpicture()
	}
}

function getpicturecontent() {
	picturecontent=""
	picturecontent+="<table cellpadding=2 cellspacing=0>"
	picturecontent+="<tr>"
	for (i=0;i<=slideurl.length-1;i++) {
		picturecontent+="<td>"
		picturecontent+="<a href=\""+slidelink[i]+"\" target=\""+slidetarget[i]+"\" onMouseOver=\"javascript:onmsover()\" onMouseOut=\"javascript:onmsout()\">"
		picturecontent+="<img src=\""+slideurl[i]+"\" border=0></a>"
		picturecontent+="</td>"
	}
	picturecontent+="</tr>"
	picturecontent+="<tr>"
	for (i=0;i<=slideurl.length-1;i++) {
		picturecontent+="<td>"
		picturecontent+="<font face=\""+slidefont+"\" color=\""+slidefontcolor+"\" size="+slidefontsize+">"
		picturecontent+=slidecomment[i]
		picturecontent+="</font>"
		picturecontent+="</td>"
	}
	picturecontent+="</tr>"
	picturecontent+="</tr></table>"
}
if (ie || ns6) {
	document.write('<div style="position:relative;width:'+scrollerwidth+'px;height:'+scrollerheight+'px;overflow:hidden">')
	document.write('<div id="picturediv" style="position:absolute;top:0px;left:0px;width:'+scrollerwidth+'px;height:'+scrollerheight+'px"></div>')
	document.write('</div>')
	window.onload=init
}

if (ns4) {
	document.write('<ilayer name="roof" width='+scrollerwidth+' height='+scrollerheight+'>')
	document.write('<layer name="picturediv" width='+scrollerwidth+' height='+scrollerheight+'></layer>')
	document.write('</ilayer>')
	window.onload=init
}
