var numfoot=5;
var numsel=3;
var picbase="";
var preload;
function glinit(){
	showfoot(1);
	showsel(1);
	document.onmousedown=downHandler;
	document.onmousemove=moveHandler;
	target=document.getElementById("mainpic");
	pos=target.src.toString().indexOf('.jpg');
	if(pos>=0){
		picbase=target.src.toString().substring(0,pos);
	}
	preload=new Image;
	preload.src=picbase + "_big.jpg";
}
function showfoot(i){
	hidefoot();
	document.getElementById("foot"+i).style.display="block";
	return(false);
}
function hidefoot(){
	for(i=1;i<=numfoot;i++){
		document.getElementById("foot"+i).style.display="none";
	}
}
function showsel(i){
	hidesel();
	document.getElementById("sel"+i).style.display="block";
}
function hidesel(){
	for(i=1;i<=numsel;i++){
		document.getElementById("sel"+i).style.display="none";
	}
}
function downHandler(e){
     if (e == null) { e = window.event; } 
     var target = e.target != null ? e.target : e.srcElement;
    if (target.className=="glthumb") {
		pos=target.src.toString().indexOf('_th.jpg');
		if(pos>=0){
			picbase=target.src.toString().substring(0,pos);
			document.getElementById("mainpic").src=picbase + ".jpg";
			preload.src=picbase + "_big.jpg";
            return false;
 		}
 	}
}
function moveHandler(e){
     if (e == null) { e = window.event } 
     var target = e.target != null ? e.target : e.srcElement;
	thepic=document.getElementById("mainpic");
	themover=document.getElementById("bildinner");
	//dbg(target.className);
    if(target.className=="zoomframe"){
		thepic.src=preload.src;
		ox=e.clientX + getScrollWidth();
		oy=e.clientY + getScrollHeight();
		oy-=100;
		ox-=342;
		//dbg("x:" + ox +" y:" +oy);
		//dbg(document.documentElement.scrollLeft);
		themover.style.left=(ox*-1)+"px";	
		themover.style.top=(oy*-1)+"px";
	}else{
		thepic.src=picbase + ".jpg";
		themover.style.top="0px";
		themover.style.left="0px";	
	}
} 
function getScrollWidth()
{
   var w = window.pageXOffset ||
           document.body.scrollLeft ||
           document.documentElement.scrollLeft;
           
   return w ? w : 0;
}

function getScrollHeight()
{
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
           
   return h ? h : 0;
}
function dbg(strtxt){
	document.getElementById("header").innerHTML="<p>" + strtxt + "</p>"
}
