var Zoomfaktor;

function fade(img_id,bild_url,Opac,Richtung){
	Richtung = (Richtung*1);
	Opac = (Opac*1);
	Opac = Opac + Richtung;

	if (Opac > 100) { Opac = 100;}
	if (Opac < 0) { Opac = 0;}

	document.getElementById(img_id).style.opacity = Opac/100;

	if (Richtung < 0) {
		Richtung = -3;
		if (Opac < 40) {
			document.getElementById(img_id).src = bild_url;
			Richtung = 1;
			window.setTimeout(function () { fade(img_id,bild_url,Opac,Richtung); }, 7);
		} else {
			 window.setTimeout(function () { fade(img_id,bild_url,Opac,Richtung); }, 7);
		}
	} else {
		window.setTimeout(function () { fade(img_id,bild_url,Opac,Richtung); }, 10);
	}
}

function Bild(img_id, bild_url){
	try {
		if (document.getElementById(img_id).filters) {
			if (document.getElementById(img_id).filters.blendTrans) {
				document.getElementById(img_id).filters.blendTrans.Apply();
			}
			document.getElementById(img_id).src = bild_url;
		} else {
			// kein IE
			fade(img_id,bild_url,100,-3);
		}
	} catch(e){}

	try{
		if (document.getElementById(img_id).filters) {
			if (document.getElementById(img_id).filters.blendTrans) {
				document.getElementById(img_id).filters.blendTrans.Play();
			}
		}
	} catch (e){}
}


function Zoom(Bild_ID, Groesse){
	//alert(Groesse);
	var Format = "500_500";

	if (Groesse != null){
		Format = Groesse + '_' + Groesse;
	}

	MiniBild = document.getElementById(Bild_ID);
	Zoomfaktor = MiniBild.width / MiniBild.height;

	BildQuelle_klein = document.getElementById(Bild_ID).src;

	BildQuelle_gross = BildQuelle_klein;
	BildQuelle_gross = BildQuelle_gross.replace("75_75"  , Format);
	BildQuelle_gross = BildQuelle_gross.replace("100_100", Format);
	BildQuelle_gross = BildQuelle_gross.replace("150_150", Format);
	BildQuelle_gross = BildQuelle_gross.replace("250_250", Format);

	//alert(BildQuelle_gross);

	ZoomBild =  document.getElementById("Zoombild");
	ZoomBild.src = BildQuelle_gross;

	ZoomBild.width = MiniBild.width;
	ZoomBild.height = MiniBild.height;

	document.getElementById('Bilder_Kasten').style.visibility = "visible";
	document.getElementById('Zoomschliess').style.display = "block";


	window.setTimeout("zoome_bild(1,"+ Groesse + ")", 5);

}

function zoome_bild(Richtung, Groesse){

	//alert(Groesse);

	if (Groesse != null){
		// bekommen wir eine Groesse
		Groesse = Groesse *1;
	} else {
		Groesse = 500;
	}

	ZoomBild =  document.getElementById("Zoombild");

	if (Richtung == 1){
		ZoomBild.width = ( ZoomBild.width + 50);
		if ( ( ZoomBild.width < Groesse) && ( ZoomBild.height < Groesse) ) {
			window.setTimeout('zoome_bild(1,'+ Groesse + ')', 2);
		}
	} else {
		ZoomBild.width = ( ZoomBild.width - 30);
		if ( ZoomBild.width > 30) {
			window.setTimeout('zoome_bild(0)', 1);
		} else {
			document.getElementById('Bilder_Kasten').style.visibility = "hidden";
		}
	}

	ZoomBild.height = Math.round( ZoomBild.width / Zoomfaktor);


}

function Zoom_ausblenden(){

	window.setTimeout("zoome_bild(0)", 3);
}


// Diashow('diashow_01', 0, 'shops/efm/design/' new Array("Krawatten 11.JPG", "Krawattenwand 2.JPG", "Krawatten 10.JPG", "Krawatten 3.JPG", "Krawatten 5.JPG"));
function Diashow(img_id, index_soll, pfad, arr_string_bild_url){

	//alert(arr_string_bild_url);

	arr_bild_url = arr_string_bild_url.split(',');

	//alert(arr_bild_url.length);

	index_soll = (index_soll * 1) + 1;

	if (index_soll >= arr_bild_url.length) {
		index_soll = 0;
	}

	bild_url = pfad + arr_bild_url[index_soll];
	//.replace(/\s+$/,"");

	Bild(img_id, bild_url);

	//alert('Diashow("' + img_id + '", ' + index_soll + ' , "' + pfad + '", "' + arr_string_bild_url + '"))');
	//window.setTimeout('Diashow("diashow_01", 1 , "shops/efm/design/", "hgfhfh,gfhgfhgfhfhf");', 2000);

	window.setTimeout('Diashow("' + img_id + '", ' + index_soll + ' , "' + pfad + '", "' + arr_string_bild_url + '")', 9000);

}



function Flippshow(AnzahlFlipps, aktuelles, Opac, Richtung){
	Richtung = (Richtung*1);
	Opac = (Opac*1);
	Opac = Opac + Richtung;

	if (Opac > 100) { Opac = 100;}
	if (Opac < 0) { Opac = 0;}
	document.getElementById("Flipp_"+aktuelles).style.opacity = Opac/100;

	if (Richtung < 0) {
		Richtung = -3;
		if (Opac < 35) {
			document.getElementById('Flipp_'+aktuelles).style.display = 'none';
			aktuelles++;
			if (aktuelles > AnzahlFlipps) { aktuelles=1; }
			document.getElementById('Flipp_'+aktuelles).style.display = 'block';
			Richtung = 1;
			window.setTimeout(function () { Flippshow(AnzahlFlipps, aktuelles, Opac, Richtung); }, 7);
		} else {
			window.setTimeout(function () { Flippshow(AnzahlFlipps, aktuelles, Opac, Richtung); }, 10);
		}
	} else {
		if (Opac == 100) {
			window.setTimeout(function () { Flippshow(AnzahlFlipps, aktuelles, Opac, -3); }, 6000);
		} else {
			window.setTimeout(function () { Flippshow(AnzahlFlipps, aktuelles, Opac, Richtung); }, 7);
		}

	}
}

