	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, November 2005
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/
	var arrowHeight = 35;	// Height of arrow image in pixels;
	var displayMessage=true;	// Display a please wait message while images are loading?
	
	var viewImage = false;
	var viewImageParent = false;
	var scrollSpeed = 0;
	var viewImagePane = false;
	var scrollEndMarker = false;
	var artContainer = false;
	var imageDisplayCaptions = new Array();
	function getTop(inputObj)
	{		
	
	  var returnResult = inputObj.offsetTop;
	  while((inputObj = inputObj.offsetParent) != null)returnResult += inputObj.offsetTop;
	  return returnResult;
	}
	
	function getLeft(inputObj)
	{

	  var returnResult = inputObj.offsetLeft;
	  while((inputObj = inputObj.offsetParent) != null)returnResult += inputObj.offsetLeft;
	  return returnResult;
	}
		
	function showPreview(newSrc,imageIndex)
	{
		if(!viewImage){
			var images = document.getElementById('previewPane').getElementsByTagName('IMG');
			if(images.length>0){
				viewImage = images[0];
			}else{
				viewImage = document.createElement('IMG');
				document.getElementById('previewPane').appendChild(viewImage);	
			}
			
			
		}
		if(displayMessage){
			document.getElementById('waitMessage').style.display='inline';
		}
		document.getElementById('largeImageCaption').style.display='none';
		viewImage.onload = function() { hideWaitMessageAndShowCaption(imageIndex-1); };				
		viewImage.src = newSrc;
		
	}
	function hideWaitMessageAndShowCaption(imageIndex)
	{
		document.getElementById('waitMessage').style.display='none';	
		document.getElementById('largeImageCaption').innerHTML = imageDisplayCaptions[imageIndex];
		document.getElementById('largeImageCaption').style.display='block';
		
	}	
	function initScroll(e)
	{
		if(document.all)e = event;
		
		if(this.src.indexOf('over')<0)this.src = this.src.replace('.gif','-over.gif');
		
		scrollSpeed = e.clientY + Math.max(document.body.scrollTop,document.documentElement.scrollTop) - getTop(this);
		if(this.src.indexOf('down')>=0){
			scrollSpeed = (scrollSpeed)*-1;	
		}else{
			scrollSpeed = arrowHeight - scrollSpeed;
		}
		scrollSpeed = Math.round(scrollSpeed * 10 / arrowHeight);
	}
	
	function stopScroll()
	{		
		scrollSpeed = 0;
		this.src = this.src.replace('-over','');
	}
	
	function scrollPreviewPane()
	{
		if(scrollSpeed!=0){
			var topPos = viewImagePane.style.top.replace(/[^\-0-9]/g,'')/1;	
		
			if(scrollSpeed<0 && scrollEndMarker.offsetTop<(viewImageParent.offsetHeight - topPos)){
				scrollSpeed=0;
			
			}
			topPos = topPos + scrollSpeed;
			if(topPos>0)topPos=0;

		 	viewImagePane.style.top = topPos + 'px';
	 	
		}
	 	setTimeout('scrollPreviewPane()',30);		
	}
	
	function revealThumbnail()
	{
		this.style.filter = 'alpha(opacity=100)';
		this.style.opacity = 1;
	}
	
	function hideThumbnail()
	{
		this.style.filter = 'alpha(opacity=100)';
		this.style.opacity = 1;
	}
	
	function initDisplayScript()
	{
		viewImageParent = document.getElementById('rightImages');
		viewImagePane = document.getElementById('rightImages').getElementsByTagName('DIV')[0];
		viewImagePane.style.top = '-600px';
		artContainer  = document.getElementById('artContainer');
		var images = viewImagePane.getElementsByTagName('IMG');
		for(var no=0;no<images.length;no++){
			images[no].onmouseover = revealThumbnail;
			images[no].onmouseout = hideThumbnail;
		}	
		scrollEndMarker = document.getElementById('scrollEnd');
		
		document.getElementById('arrowupimage').onmousemove = initScroll;
		document.getElementById('arrowupimage').onmouseout = stopScroll;
		
		document.getElementById('arrowdownimage').onmousemove = initScroll;
		document.getElementById('arrowdownimage').onmouseout = stopScroll;
		var divs = viewImageParent.getElementsByTagName('DIV');
		for(var no=0;no<divs.length;no++){
			if(divs[no].className=='imageCaption')imageDisplayCaptions[imageDisplayCaptions.length] = divs[no].innerHTML;
		}		
		scrollPreviewPane();
		
	}
	
	
	window.onload = initDisplayScript;
	