var neues_bild = new Image();
var txt_neu;
var in_arbeit = false;
var vorlade_bild = new Image();

var altes_bild = new Image();
var neues_bild = new Image();

function rahmen_einblenden() {
	var op = document.getElementById("bilder_box").style.opacity;
	if (op < 1.0) {
		var neu = parseFloat(op) + 0.02;
		document.getElementById("bilder_box").style.opacity = neu.toString();
		window.setTimeout("rahmen_einblenden()",10);
	} else {

	}
};

function ausblendenStart(step) {
	var img = document.getElementById("hauptbild");
	var xop = 1;
	step = step || 0;

	xop = 1 - (step / 100);

	img.style.opacity = xop;
	img.style.filter = "alpha(opacity=" + (100 - step) + ")"; //IE
	step = step + 2;

	if(step <= 100) {
		window.setTimeout( function() {
			ausblendenStart(step);
		}, 10);
	}
	if(step >= 100) {
		//document.getElementById("hauptbild").src = txt_neu;
		img.onload = function() {einblendenStart()};
		img.src = neues_bild.src;
		einblendenStart();
	}
}

function einblendenStart(step) {
	var imgs = document.getElementById("hauptbild");

	step = step || 0;

	imgs.style.opacity = step / 100;
	imgs.style.filter = "alpha(opacity=" + step + ")"; // IE
	step = step + 2;

	if (step <= 100) {
		window.setTimeout( function () {
			einblendenStart(step);
		}, 20);
	}
	if(step >= 100) {
		in_arbeit = false;
	}
}

function start_click(name) {
	// Bild nur wechseln wenn überblenden abgeschlossen ist
	if(in_arbeit == false) {
		in_arbeit = true;
		altes_bild.src = document.getElementById("hauptbild");
		neues_bild.onload = function() {ausblendenStart()};
		neues_bild.src = "../port_bilder/" + name + "gr.jpg";
		txt_neu = "../port_bilder/" + name + "gr.jpg";
	}
}

function bilder_anzeigen() {
	var imgs = document.getElementById("hauptbild");
	document.getElementById("bilder_box").style.opacity = 0;
	document.getElementById("bilder_box").style.visibility = "visible";
	rahmen_einblenden();
}

function bilder_ausblenden() {
	document.getElementById("bilder_box").style.visibility = "hidden";
}
