var tempX = 0
var tempY = 0
var posLtmp = 0
var posL = "125px"
var posH = "25px"

var Breite = 300;
var aktuelleBreite = 0;
var Schrittweite = 6;
var Schrittverzoegerung = 1;
var showidx = 0;
var Bilder = new Array();



function showImage(imgSrc){
	var bild = document.createElement("img");
	bild.src = "bilder\/" + String(imgSrc);
	bild.alt = String(imgSrc);
	bild.style.height = "380px";
	bild.style.width = "auto";
	bild.style.border = "solid 1px #999"
	
	posH = "25px";
	if (tempX < 650) {
		posLtmp = tempX + 25;
		posL = posLtmp + "px";
	} else {
		posL = "125px";
	}
	var tt = document.getElementById("tooltip");
	

	tt.style.visibility = "visible";
	tt.style.top = posH;
	tt.style.left = posL;
	tt.appendChild(bild);
}

function hideImage(){
	var tt = document.getElementById("tooltip");
	tt.style.visibility = "hidden";
	tt.style.width = "auto";
	tt.style.height = "auto";
	do {
		var removeImg = tt.firstChild;
		tt.removeChild(removeImg);
	} while (tt.hasChildNodes);
	
}

function showDiv(){	
	var tt = document.getElementById("tooltip");
	tt.style.visibility = "visible";
}

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0} 
  return true
}



//****************************************************
//** ALBUM
//****************************************************

function showAlbum(files, index, title){
	Bilder.length = 0;
	showidx = 0;
	var tt3 = document.getElementById("tooltip3");
	var tt2 = document.getElementById("tooltip2");
	var bb = document.getElementById("bildbereich");
	var ba = document.getElementById("bildanzeige");
	var tt = document.getElementById("tooltip");
	tt.style.visibility = "hidden";

	tt2.style.visibility = "visible";
	
	
	var tmp = files.split(",");

	for (var i = 0; i < tmp.length; i++){
		Bilder[i] = new Image();
		Bilder[i].src = "bilder\/" + String(tmp[i]);

		if (String(tmp[i])==index){
			showidx = i;
		}
	}
	
	//showidx = tmp.IndexOf(index);
	//alert("Index: " + showidx);
	document.getElementById("album_title").innerHTML = title;
	document.getElementById("album_bild").innerHTML = "Bild " + (showidx + 1) + "/" + Bilder.length;
	ba.height = "420";
	ba.src = Bilder[showidx].src;
	
	//alert("JS: " + ba.src);
	
	tt3.style.visibility = "visible";
	bb.style.visibility = "visible";
	
	
	
}

function nextPic(direction){
	var bb = document.getElementById("bildbereich");
	var ba = document.getElementById("bildanzeige");
	ba.src = "";
	
	showidx = showidx + direction;
	if (showidx > Bilder.length - 1) {
		showidx = 0;
	} else if (showidx < 0) {
		showidx = Bilder.length - 1;
	}
	
	document.getElementById("album_bild").innerHTML = "Bild " + (showidx + 1) + "/" + Bilder.length;
	ba.src = Bilder[showidx].src;
}

function closeAlbum(){
	var tt3 = document.getElementById("tooltip3");
	var tt2 = document.getElementById("tooltip2");
	var bb = document.getElementById("bildbereich");
	var ba = document.getElementById("bildanzeige");
	var tt = document.getElementById("tooltip");
	tt.style.visibility = "hidden";

	ba.src = "";
	tt3.style.visibility = "hidden";
	tt2.style.visibility = "hidden";
	bb.style.visibility = "hidden";
	
	//alert("JS: " + Bilder.length + " Index: " + startidx);
	
}
