function setop(pic,op) {
	if (document.all) { //IE
		pic.style.filter = "Alpha(opacity="+(op * 100)+", finishopacity=100, style=0)";
	} else {
		pic.style.opacity = op;
	}
}

function fadestat(stat) {
	// alert("Fade:" + stat);
	var pico = document.getElementById("statpic" + stat); 
	var picu = document.getElementById("u-statpic" + stat); 
	var cur = statfoto[stat].cur;
	var nex = cur + 1;

	if (nex > statfoto[stat].num) nex = 1;
	
	if (statfoto[stat].fade == 0) { // Init Fade
		// Unteres Bild wird nächstes Bild
		picu.src = statfoto[stat][nex].src;
		statfoto[stat].fade = 1;
		statfoto[stat].op = 1.0;
		// Fade alle 100ms 
		setTimeout("fadestat(" + stat + ")", 100);
	}
	else { // Fade aktiv
		if (statfoto[stat].op > 0.2) {
			statfoto[stat].op -= 0.1;
		} else {
			statfoto[stat].op -= 0.035;
		}
		if (statfoto[stat].op < 0) { //Fade end
			statfoto[stat].fade = 0;
			statfoto[stat].cur = nex;
			// Unteres Bild nach oben holen
			pico.src = picu.src;
			setop(pico,1.0);
			// Wartezeit bis zum nächsten Bild
			setTimeout("fadestat(" + stat + ")", statfoto[stat][nex][1]);
		}
		else { // faden
			setop(pico,statfoto[stat].op);
			setTimeout("fadestat(" + stat + ")", 100);
		}
	}
}

function preloadfoto(stat,num,time) {
	
	statfoto[stat][num] = new Image();
	statfoto[stat][num].src = ("../opics/stat" + stat + "-" + num + ".jpg");
	statfoto[stat][num][1] = time;
	statfoto[stat].num = num;
	statfoto[stat].cur = 1;
	statfoto[stat].op = 1.0;
	statfoto[stat].fade = 0;
}


x = 0;
y = 0;
currentid = 0;
currentover = 0;
anzahl = 0;

// document.onmousemove = updatePOPUP;


function move() {
}

function updatePOPUP(e) {
	var popup;
	popup = document.getElementById(currentid);
	xoffset = 20;
	yoffset = 20;
	x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
	return;
	if (popup != null) {
		if ( y > (document.body.scrollHeight - popup.scrollHeight - yoffset)) {
			yoffset = yoffset - popup.scrollHeight;
		}
		popup.style.left = (x + xoffset) + "px";
		popup.style.top  = (y + yoffset) + "px";
	}
}

function showPOPUP(id) {
	if (id < 10 ) {
		if (currentid != 0) {hidePOPUP(currentid);};
		if (currentover != 0) {hidePOPUP(currentover);};
	} else {
		if (currentid != 0) return;
	}
	var popup;
	popup = document.getElementById(id);
	popup.style.display = "block";
	if (nofade == false) {
		popup.style.opacity = 0.0;

		if (id < 10) {
			setPOPin(id,1);
		} else {
			setPOPin(id,0);
		}
	}
	if (id < 10) {
		currentid = id;
	} else {
		currentover = id;
	}
	anzahl += 1;
}

function setPOPin(id,op) {
	var popup;
	popup = document.getElementById(id);
	if (nofade == true) {
		popup.style.display = "block";
		return;
	}
	if (anzahl > 1) { op = 1} 
	popup.style.opacity = op;
	if (document.all) {
		popup.style.filter = "Alpha(opacity="+(op * 100)+", finishopacity=100, style=0)";
	}
	op += 0.2;
	if ( op < 1.2) {
		setTimeout("setPOPin("+id+","+op+")", 50);
	}
}

function setPOPout(id,op) {
	var popup;
	popup = document.getElementById(id);
	if (anzahl > 2) { op = 0} 
	
	if (nofade == true) {
		op = 0;
	} else {
		popup.style.opacity = op;
	}
	if (document.all && nofade == false) {
		popup.style.filter = "Alpha(opacity="+(op * 100)+", finishopacity=0, style=0)";
	}
	op -= 0.2;
	if ( op > 0.0) {
		setTimeout("setPOPout("+id+","+op+")", 50);
	}
	else {
		popup.style.display = "none";
		anzahl -= 1;
		if (anzahl <= 0) {
			anzahl = 0;
			if (id == currentid) {
				currentid = 0;
			}
			if (id == currentover) {
				currentover = 0;
			}
		}
	}
}

function hidePOPUP(id) {
	
	if (id < 10) {
		setPOPout(id,0);
	} else {
		setPOPout(id,1);
	}
}

function closePOPUP() {
	if (currentid < 10) {
		setPOPout(currentid,0);
	} else {
		setPOPout(currentid,1);
	}
}

