
// realised by jeff
// www.huntingground.freeserve.co.uk

spacerWidth=0// space between images
defaultSpeed=7
maxSpeed=20

popupLeft= 100 // pixels
popupTop= 100 // pixels

totalWidth=0
displayWidth=0
displayHeight=0
step=defaultSpeed

function initHDS(){

	displayBox=document.getElementById("container")
	displayWidth=parseInt(displayBox.style.width)
	displayHeight=parseInt(displayBox.style.height)
	scrollBox=document.getElementById("scroller")
	numOfCells=scrollBox.getElementsByTagName("DIV").length

	if(document.getElementById&&document.all){
		ieBorder=parseInt(displayBox.style.borderWidth)*2
	}
	else{
	ieBorder=0
	}

	for(var i=0;i<numOfCells;i++){
		totalWidth+=(document.getElementById("cell"+i).offsetWidth) // get all div widths
		document.getElementById("cell"+i).style.marginRight=spacerWidth+"px" // add spacer

		if(document.getElementById("cell"+i).offsetWidth>displayWidth){ // set to largest width
			displayWidth=document.getElementById("cell"+i).offsetWidth+ieBorder // include border for IE
			displayBox.style.width=displayWidth
		}

		if(document.getElementById("cell"+i).offsetHeight>displayHeight){ // set to largest image height
			displayHeight=document.getElementById("cell"+i).offsetHeight+ieBorder // include border for IE
			displayBox.style.height=displayHeight
		}

	}

	for(var i=0;i<numOfCells;i++){ // vertically center divs
		document.getElementById("cell"+i).style.marginTop=(displayHeight-document.getElementById("cell"+i).offsetHeight)/2+"px"
		document.getElementById("cell"+i).style.marginBottom=(displayHeight-document.getElementById("cell"+i).offsetHeight)/2+"px"
	}

	document.getElementById("cell0").style.height=displayHeight/2
	//document.getElementById("cell0").style.marginRight=0
	totalWidth=totalWidth+(numOfCells*spacerWidth)
	scrollBox.style.width=totalWidth+"px"
	//displayBox.style.clip="rect(0,"+(displayWidth+"px")+","+(displayHeight+"px")+",0)"

	

	if (totalWidth > 960) {document.getElementById('arrow_left').style.display="block"; document.getElementById('arrow_right').style.display="block"; }
	else { document.getElementById('arrow_left').style.display="none"; document.getElementById('arrow_right').style.display="none"; }

}


		
leftTimer=""
function scrollHDS(n){

if (totalWidth > 960) {
	
		clearTimeout(leftTimer)
		scrollBoxPos=parseInt(scrollBox.style.left)
		if(n==1){
			scrollBoxPos-=step
		}
		else{
			scrollBoxPos+=step
		}

		scrollBox.style.left=scrollBoxPos+"px"
		leftTimer=setTimeout("scrollHDS("+n+")",50)

		//document.getElementById("qw").innerHTML=scrollBoxPos+" "+( -(totalWidth-displayWidth)+(spacerWidth)-ieBorder)

		if(n==1&&scrollBoxPos< -(totalWidth-displayWidth)+(spacerWidth)-ieBorder){
		scrollBox.style.left=-(totalWidth-displayWidth)+(spacerWidth)-ieBorder+"px"
		clearTimeout(leftTimer)
		}

		if(n==0&&scrollBoxPos> 0-step){
			scrollBox.style.left=0
			clearTimeout(leftTimer)
		}
	}
}

function fast(){
step=maxSpeed
}

function slow(){
step=defaultSpeed
}

function pause(){
clearTimeout(leftTimer)
}


picWin=null

function getBigPic(p){
if(mypic[p]&&mypic[p]!=""){

bigImg=new Image()
bigImg.src=mypic[p]

data="\n<center>\n<img src='"+bigImg.src+"'>\n</center>\n"

if(picWin){picWin.close()} // if window exists close it

var winProps = "left= "+popupLeft+", top = "+popupTop+", width="+(bigImg.width+20)+", height="+(bigImg.height+20)+", scrollbars=no, toolbar=no, directories=no, menu bar=no, resizable=yes, status=no" 
picWin=window.open("","win1",winProps)
picWin.document.write("<HTML>\n<HEAD>\n<TITLE></TITLE>\n")
picWin.document.write("</HEAD>\n")
picWin.document.write("<BODY bgcolor='black' topmargin=10px leftmargin=10>\n")
picWin.document.write("<div id=\"display\">"+data+"</div>")
picWin.document.write("\n</BODY>\n</HTML>")
}
}

//add onload="initHDS()" to the opening BODY tag

