//Jeff
// www.huntingground.freeserve.co.uk
var dir=0; // 0 = left 1 = right
var speed=2;
var imageSize=0;  // % set to zero to use fixedWidth and fixedHeight values
var fixedWidth=170; // set a fixed width
var fixedHeight=150; // set a fixed height
var spacerWidth=0; // space between images
var dualFade=0; // 0 = fades in, 1 = fades out then in

var biggest=0;
var ieBorder=0;
var totalWidth=0;
var hs5Timer=null;

var lastN=0;
var count=0;
var fading=0;
var fadeStep = 2;
var fadespeed=10;
var minFadeValue=0;

function initHS5(){
	
	preload=new Array();
	
	for(var i=0;i<hs5Arr.length;i++){
		preload[i]=[];

		for(var j=0;j<2;j++){
			preload[i][j]=new Image();
			preload[i][j].src=hs5Arr[i][j];
		}
	}

	scroll_Box=document.getElementById("scroll_box");
	scroll_1=document.getElementById("scroller1");
	
	for(var k=0;k<hs5Arr.length;k++){

		scroll_1.innerHTML+='<a href="'+hs5Arr[k][1]+'" target="_blank" title="'+hs5Arr[k][2]+'">'+
									'<img id="pic'+k+'" src="'+preload[k][0].src+'" alt="'+hs5Arr[k][2]+'"">'+
								'</a>';

		if(imageSize!=0){ // use percentage size
			newWidth=preload[k][0].width/100*imageSize;
			newHeight=preload[k][0].height/100*imageSize;
		}
		else{ // use fixed size
			newWidth=fixedWidth;
			newHeight=fixedHeight;
		}

		//document.getElementById("pic"+k).style.width=newWidth+"px";
		document.getElementById("pic"+k).style.height=newHeight+"px";

		if(document.getElementById("pic"+k).offsetHeight>biggest){
			biggest=document.getElementById("pic"+k).offsetHeight;
		}

		document.getElementById("pic"+k).style.marginLeft=spacerWidth+"px";
		totalWidth+=document.getElementById("pic"+k).offsetWidth+spacerWidth;
	}

	totalWidth+=1

	for(var l=0;l<hs5Arr.length;l++){ // vertically center images
		document.getElementById("pic"+l).style.marginBottom = (biggest-document.getElementById("pic"+l).offsetHeight)/2+"px";
	}

	if(scroll_Box.currentStyle&&!window.opera&&document.compatMode!="CSS1Compat"){
		ieBorder=parseInt(scroll_Box.currentStyle.borderWidth)*2;
	}

	//scroll_Box.style.height=biggest+ieBorder+"px";
	//scroll_1.style.width=totalWidth+"px";
	scroll_2=document.getElementById("scroller2");
	scroll_2.innerHTML=scroll_1.innerHTML;
	scroll_2.style.left= scroll_1.offsetWidth+"px";
	scroll_2.style.top= 0+"px" //-scroll_1.offsetHeight+"px";
	scroll_2.style.width=totalWidth+"px";

	if(dir==1){
		speed= -speed;
	}

	scrollHS5();
}

function scrollHS5(){
	clearTimeout(hs5Timer);
	scroll_1Pos=parseInt(scroll_1.style.left);
	scroll_2Pos=parseInt(scroll_2.style.left);
	scroll_1Pos-=speed;
	scroll_2Pos-=speed;
	scroll_1.style.left=scroll_1Pos+"px";
	scroll_2.style.left=scroll_2Pos+"px";
	hs5Timer=setTimeout("scrollHS5()",50);

	if(dir==0){
		if(scroll_1Pos< -scroll_1.offsetWidth){
			scroll_1.style.left=scroll_1.offsetWidth+"px";
		}

		if(scroll_2Pos< -scroll_1.offsetWidth){
			scroll_2.style.left=scroll_1.offsetWidth+"px";
		}
	}

	if(dir==1){
		if(scroll_1Pos>parseInt(scroll_Box.style.width)){
			scroll_1.style.left=scroll_2Pos+ (-scroll_1.offsetWidth)+"px";
		}

		if(scroll_2Pos>parseInt(scroll_Box.style.width)){
			scroll_2.style.left=scroll_1Pos+ (-scroll_2.offsetWidth)+"px";
		}
	}

}

st=null;
function pause(){
	clearTimeout(hs5Timer);
	clearTimeout(st);
}

function reStartHS5(){
	clearTimeout(st);
	st=setTimeout("scrollHS5()",100);
}