function changephoto(ref) {

var objimg=document.getElementById('containimg'); 
var objimgdesc=document.getElementById('descImageGallery');

new Effect.Fade ('containimg', { duration:0.2 });
	
	objimgdesc.style.display='none';

var imgPreloader = new Image();
new Effect.Appear ('imgLoading', {duration:0.2}); 
var getsrc = eval("image"+ref);
imgPreloader.onload = (function(){
		    
		    var w=imgPreloader.width;
		    var h=imgPreloader.height;

		    if (w<h) {
		    h=parseInt(h/3*1.5);
		    w=parseInt(w/3*1.5);
		    }
	$('tdContainer').morph('height:'+h+'px;', { duration:0.3}); 
		
	$('contimgGallery').morph('height:'+(h)+'px;width:'+(w)+'px;', { duration:0.5, afterFinish: function (obj) { 
	
	objimg.style.height=h+'px'; objimg.style.width=w+'px';
		    
	objimg.onload = (function(){
	new Effect.Fade ('imgLoading', { duration:0.5, afterFinish: function (obj) {  
	new Effect.Appear ('containimg', {duration:0.3}); 
	var descImg=eval("descfoto"+ref);
	if (descImg.length>0) { objimgdesc.innerHTML=descImg;
	objimgdesc.style.display='inline';
changeOpac(70, "descImageGallery");
	}
	}});
}).bind(this);
	
	objimg.src = getsrc;
	}});
}).bind(this);
imgPreloader.src = getsrc;
}

function moveThumbs(mode,wm) { var add=1; millisec=300; var speed = Math.round(millisec / 100); var timer = 0;
var obj=document.getElementById('container_thumbs'); var aBack=document.getElementById("arrowback").style; var aNext=document.getElementById("arrownext").style;
ow=obj.offsetWidth; maxleft=(parseInt(ow)-wm-10)*-1; var actleft=parseInt(obj.style.left);
if (mode==1) goto=actleft+99;
if (mode==0) goto=actleft-99;
if (goto>0) goto=0;
if (goto<maxleft) goto=maxleft; aNext.display='none';
if (goto>maxleft) new Effect.Appear('arrownext');
if (goto<0) new Effect.Appear('arrowback'); 
if (goto>=0) aBack.display='none'; 
new Effect.Move(obj, { x:goto, y: 0, mode: 'absolute', duration:0.5 });
}

function findPos(obj) {
	var curleft = curtop = 0;
if (obj.offsetParent) {
do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
return curleft;
}
}

function findPosY(obj) {
	var curleft = curtop = 0;
if (obj.offsetParent) {
do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
return curtop;
}
}
