	/************************************************************************************************************
	(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 arrowImageHeight = 35;	// Height of arrow image in pixels;
	var displayWaitMessage=true;	// Display a please wait message while images are loading?
	
	var previewImage = false;
	var previewImageParent = false;
	var slideSpeed = 0;
	var previewImagePane = false;
	var slideEndMarker = false;
	var galleryContainer = false;
	var imageGalleryCaptions = new Array();
	function getTopPos(inputObj)
	{		
	
	  var returnValue = inputObj.offsetTop;
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;
	  return returnValue;
	}
	
	function getLeftPos(inputObj)
	{

	  var returnValue = inputObj.offsetLeft;
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
	  return returnValue;
	}
		
	function showPreview(newSrc,imageIndex, id)
	{
		var idImage = id + '_img';
		var slide = document.getElementById(id + '_div');
                var idCap = id + '_cap'; 
                
                if(displayWaitMessage){
		     document.getElementById('waitMessage').style.display='inline';
		}
                
		document.getElementById(idCap).style.display='none';
		document.getElementById(idImage).onload = function() { hideWaitMessageAndShowCaption(imageIndex, idCap); };				
		document.getElementById(idImage).src = newSrc;
		slide.altUrl = slide.images[imageIndex].altUrl;
		
	}


	function hideWaitMessageAndShowCaption(imageIndex, idCap)
	{
		document.getElementById('waitMessage').style.display='none';	
		document.getElementById(idCap).innerHTML = imageGalleryCaptions[imageIndex];
		document.getElementById(idCap).style.display='block';
	}	
	function initSlide(e)
	{
		if(document.all)e = event;
		
		if(this.src.indexOf('over')<0)this.src = this.src.replace('.gif','-over.gif');
		
		slideSpeed = e.clientY + Math.max(document.body.scrollTop,document.documentElement.scrollTop) - getTopPos(this);
		if(this.src.indexOf('down')>=0){
			slideSpeed = (slideSpeed)*-1;	
		}else{
			slideSpeed = arrowImageHeight - slideSpeed;
		}
		slideSpeed = Math.round(slideSpeed * 10 / arrowImageHeight);
	}
	
	function stopSlide()
	{		
		slideSpeed = 0;
		this.src = this.src.replace('-over','');
	}
	
	function slidePreviewPane()
	{
		if(slideSpeed!=0){
			var topPos = previewImagePane.style.top.replace(/[^\-0-9]/g,'')/1;	
		
			if(slideSpeed<0 && slideEndMarker.offsetTop<(previewImageParent.offsetHeight - topPos)){
				slideSpeed=0;
			
			}
			topPos = topPos + slideSpeed;
			if(topPos>0)topPos=0;

		 	previewImagePane.style.top = topPos + 'px';
	 	
		}
	 	setTimeout('slidePreviewPane()',30);		
	}
	
	function revealThumbnail()
	{
		this.style.filter = 'alpha(opacity=100)';
		this.style.opacity = 1;
	}
	
	function hideThumbnail()
	{
		this.style.filter = 'alpha(opacity=50)';
		this.style.opacity = 0.5;
	}
	
	function initGalleryScript()
	{
		previewImageParent = document.getElementById('theImages');
		previewImagePane = document.getElementById('theImages').getElementsByTagName('DIV')[0];
		previewImagePane.style.top = '0px';
		galleryContainer  = document.getElementById('galleryContainer');
		var images = previewImagePane.getElementsByTagName('IMG');
		for(var no=0;no<images.length;no++){
			images[no].onmouseover = revealThumbnail;
			images[no].onmouseout = hideThumbnail;
		}	
		slideEndMarker = document.getElementById('slideEnd');
		
		document.getElementById('arrow_up_image').onmousemove = initSlide;
		document.getElementById('arrow_up_image').onmouseout = stopSlide;
		
		document.getElementById('arrow_down_image').onmousemove = initSlide;
		document.getElementById('arrow_down_image').onmouseout = stopSlide;
		var divs = previewImageParent.getElementsByTagName('DIV');
		for(var no=0;no<divs.length;no++){
			if(divs[no].className=='imageCaption')imageGalleryCaptions[imageGalleryCaptions.length] = divs[no].innerHTML;
		}		
		slidePreviewPane();
		
	}

	window.onload = initGalleryScript;
         
         
/*
function qmimageslide_showAlt() {
var slide = document.getElementById(<?=$this->id ?>_id);
var arrParam = slide.altUrl.split(',');


var contentImage = document.getElementById('image_content_div');
var overlay = document.getElementById('overlay');

var arrayPageSize = getPageSize();

overlay.style.width='100%';
overlay.style.height=(arrayPageSize[1] + 'px');
overlay.style.display='block';
overlay.style.top='0px';
overlay.style.left='0px';


var hMaximum=300;
var wMaximum=450;


var wParam = arrParam[1];
var hParam = arrParam[2];

if(wParam > hParam){
if(wParam > wMaximum){
wParam = wMaximum;
hParam = wMaximum*arrParam[2]/arrParam[1];
}
}else{
if(hParam > hMaximum){
hParam = hMaximum;
wParam = hMaximum*arrParam[1]/arrParam[2];
}
}

var wParam2 = '-' + (wParam/2)  + 'px';
var hParam2 = '-' + (hParam/2)  + 'px';

contentImage.style.position='absolute';
contentImage.style.top='50%';
contentImage.style.left='50%';
contentImage.style.width=wParam+'px';
contentImage.style.marginLeft=wParam2;
contentImage.style.height=(parseInt(hParam)+25)+'px';
contentImage.style.marginTop=hParam2;
contentImage.style.display='block';

var imgClose=document.createElement('img');
imgClose.style.cssFloat="right";
imgClose.style.marginBottom="4px";
imgClose.setAttribute('src','');
imgClose.setAttribute('onclick','hideOverlay()');
contentImage.appendChild(imgClose);

var img1=document.createElement('img');
img1.style.cssFloat="left";
img1.style.width=wParam+'px';
img1.style.height=hParam+'px';
img1.setAttribute('src',arrParam[0]);
contentImage.appendChild(img1);
}



function hideOverlay (){
// get objects

var overlay = document.getElementById('overlay');
var contentImage = document.getElementById('image_content_div');

for (j=contentImage.childNodes.length-1; j>=0; --j) {
contentImage.removeChild(contentImage.childNodes[j]);
}

contentImage.style.display = 'none';
overlay.style.display = 'none';

// make select boxes visible
selects = document.getElementsByTagName("select");
for (i = 0; i != selects.length; i++) {
selects[i].style.visibility = "visible";
}

}		



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){

var xScroll, yScroll;

if (window.innerHeight && window.scrollMaxY) {	
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}

var windowWidth, windowHeight;
if (self.innerHeight) {	// all except Explorer
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}	

// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else { 
pageHeight = yScroll;
}

// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){	
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}


arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
return arrayPageSize;
}	
                                
                                
*/                                 
