// imagescrolling script 
// Originally developed by Cornish WebServices Ltd
// Used by Canterbury Web Services with permission 
//
// Works as expected in IE5, IE6, NS4, NS6
// does not work in Opera, but just shows the full image which is fine
//

var imagewidth
var imageheight
var imageleft
var imagetop
// below affects how image scrolls open
var pause=8
var step=2
var frameleft,frameright,frametop,framebottom
var scrolltimer
// browser inconsistency checks
var ns4=document.layers?1:0
var ns6=document.getElementById&&!document.all?1:0 
var ie=document.all?1:0

function changePicture(number) {	// added RC 8/2/05 for varying images
		document.movingbike.alt = image_alt[number];
		document.movingbike.src = image_url[number];
}
function init( imagewidth, imageheight, imageleft, imagetop) {

    if (ie) {
		document.all.imageholder.style.posTop=imagetop
	        document.all.imageholder.style.posLeft=imageleft-imagewidth
		frameleft=imagewidth
		frameright=imagewidth
		frametop=imageheight
		framebottom=imageheight
		document.all.imageholder.style.clip ="rect("+frametop+" "+frameright+" "+framebottom+" "+frameleft+")"
		document.all.imageholder.style.visibility="visible"		
    }
    if (ns6) {
		document.getElementById('imageholder').style.visibility="invisible"
		document.getElementById('imageholder').style.top=imagetop
	        document.getElementById('imageholder').style.left=imageleft-imagewidth
		frameleft=imagewidth
		frameright=imagewidth
		frametop=imageheight
		framebottom=imageheight
		document.getElementById('imageholder').style.clip ="rect("+frametop+" "+frameright+" "+framebottom+" "+frameleft+")"
		document.getElementById('imageholder').style.visibility="visible"
    }
    if (ns4) {
		document.imageframe.document.imageholder.visibility="invisible"
		document.imageframe.document.imageholder.top=imagetop
		document.imageframe.document.imageholder.left=imageleft-imagewidth
		document.imageframe.document.imageholder.clip.left=imagewidth
		document.imageframe.document.imageholder.clip.right=imagewidth
		document.imageframe.document.imageholder.clip.top=imageheight
		document.imageframe.document.imageholder.clip.bottom=imageheight
		document.imageframe.document.imageholder.visibility="visible"
    }
    scrollpicture()
}

function scrollpicture() {
	if (ie) {
		if(document.all.imageholder.style.posLeft<=imageleft) {
			document.all.imageholder.style.posLeft+=step
			frameleft-=step	
			frametop-=step
			document.all.imageholder.style.clip ="rect("+frametop+" "+frameright+" "+framebottom+" "+frameleft+")"		
			var scrolltimer=setTimeout("scrollpicture()",pause)
		}
	}
	if (ns6) {
		if (parseInt(document.getElementById('imageholder').style.left)<=imageleft) {
			document.getElementById('imageholder').style.left=parseInt(document.getElementById('imageholder').style.left)+step
			frameleft-=step
			frametop-=step
			document.getElementById('imageholder').style.clip ="rect("+frametop+" "+frameright+" "+framebottom+" "+frameleft+")"		
			var scrolltimer=setTimeout("scrollpicture()",pause)
		}
	}
	if (ns4) {
		if (document.imageframe.document.imageholder.left<=imageleft) {
			document.imageframe.document.imageholder.left+=step
			document.imageframe.document.imageholder.clip.left-=step
			document.imageframe.document.imageholder.clip.top-=step
			var scrolltimer=setTimeout("scrollpicture()",pause)
		}
	}
}

