var einzelbild;
var ebwidth;
var ebheight;
var current=0;
var r=0;
var BilderGesamt;
var ShowNextTime=4

function showbigpic(pic, wi, hi, r)
{

to=window.setTimeout("shownext()",ShowNextTime*1000);

	document.getElementById('PicSrc').style.visibility = 'hidden'
	document.getElementById('PicLayer').style.visibility = 'hidden'
	document.getElementById('swf').style.visibility = 'hidden'

	einzelbild = all_pics_in_folder.split(",");
	ebwidth = all_pics_in_folder_w.split(",");
	ebheight = all_pics_in_folder_h.split(",");
	current=r
	w=ebwidth[current]
	w = w.replace(/\'/, "");
	w = w.replace(/\'/, "");
	h=ebheight[current]
	h = h.replace(/\'/, "");
	h = h.replace(/\'/, "");
	document.getElementById("HiddenPicSrc").src = pic
	showbigpic_r('"+pic+"',w,h)
	BilderGesamt = einzelbild.length - 1
}


function shownext()
{
window.clearTimeout(to)
to=window.setTimeout("shownext()",ShowNextTime*1000);
	//document.getElementById("PicLayer").style.visibility = "hidden"
	if (current >= BilderGesamt)
	{
		current = 0
	}
	//alert(current)
	current+=1
	FadeInFadeOut()
}


function showprev()
{
	//document.getElementById("PicLayer").style.visibility = "hidden"
	if (current == 1)
	{
		current = BilderGesamt + 1
	}
	//alert(current)
	current-=1
	FadeInFadeOut()
}


function FadeInFadeOut()
{
	pic=einzelbild[current]
	pic = pic.replace(/\'/, "");
	pic = pic.replace(/\'/, "");
	//document.getElementById("PicSrc").src = pic
	w=ebwidth[current]
	w = w.replace(/\'/, "");
	w = w.replace(/\'/, "");
	h=ebheight[current]
	h = h.replace(/\'/, "");
	h = h.replace(/\'/, "");
	//window.setTimeout("fadeOutPic('"+pic+"',"+w+","+h+")",700);
	//Preload new Image
	document.getElementById("HiddenPicSrc").src = pic
	fadeOutPic(w, h);
}


function showbigpic_r(pic, w, h)
{
	document.getElementById("PicSrc").src = document.getElementById("HiddenPicSrc").src
	

		// get the path out of the calling function

		winWidth=window.innerWidth
		winHeight=window.innerHeight

		//Internet Explorer
		if (document.body.clientHeight)
		{
			winWidth = document.body.clientWidth
			winHeight = document.body.clientHeight
		}



		//picWidth=document.getElementById("PicSrc").width
		//picHeight=document.getElementById("PicSrc").height

		picWidth=w
		picHeight=h

		posLeft=(winWidth-picWidth)/2
		posTop=(winHeight-picHeight)/2


		document.getElementById("PicLayer").style.width = winWidth // IE
		document.getElementById("PicLayer").style.height = winHeight // IE
		document.getElementById('PicSrc').style.visibility = "visible"
		document.getElementById("PicLayer").style.visibility = "visible"



	  var scrOfX = 0, scrOfY = 0;
	  if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	  }


		document.getElementById("PicLayer").style.top = scrOfY
		document.getElementById("PicSrc").style.left=posLeft
		document.getElementById("PicSrc").style.top=posTop
		//alert("Page-Y-Offset:"+window.pageYOffset)
		
			fadeIn()
}


var oc=0;
function fadeIn()
{
	//Transparenz
	Transparenz = 99;
	if(oc<=Transparenz)
	{
		setTimeout('oc=oc+10;fadeIn()',50);
		document.getElementById("PicLayer").style.opacity = oc/100
		document.getElementById("PicLayer").style.filter = 'Alpha(opacity=' + oc + ')'; // IE
	}
	else
	{
		//volles Alpha
		document.getElementById("PicLayer").style.opacity = Transparenz/100
		document.getElementById("PicLayer").style.filter = 'Alpha(opacity=' + Transparenz + ')'; // IE
		oc=0;
	}
}


var ocp=100;
function fadeOutPic(w, h)
{
	//Transparenz
	Transparenz = 100;
	if(ocp>=0)
	{
		setTimeout('ocp=ocp-10;fadeOutPic(w, h)',50);
		document.getElementById("PicSrc").style.opacity = ocp/100
		document.getElementById("PicSrc").style.filter = 'Alpha(opacity=' + ocp + ')'; // IE
	}
	else
	{
		//volles Alpha
		document.getElementById("PicSrc").style.opacity = Transparenz/100
		document.getElementById("PicSrc").style.filter = 'Alpha(opacity=' + Transparenz + ')'; // IE
		//ocp=100;
		
		document.getElementById("PicSrc").style.visibility = "hidden"
		winWidth=window.innerWidth
		winHeight=window.innerHeight
		//Internet Explorer
		if (document.body.clientHeight)
		{
			winWidth = document.body.clientWidth
			winHeight = document.body.clientHeight
		}
		picWidth=w
		picHeight=h
		posLeft=(winWidth-picWidth)/2
		posTop=(winHeight-picHeight)/2
		document.getElementById("PicSrc").style.left=posLeft
		document.getElementById("PicSrc").style.top=posTop
		//setTimeout('document.getElementById("PicSrc").src = document.getElementById("HiddenPicSrc").src',200);
		document.getElementById("PicSrc").src = document.getElementById("HiddenPicSrc").src
		fadeInPic(w, h)
		document.getElementById("PicSrc").style.visibility = "visible"

	}
}


function fadeInPic(w, h)
{
	//Transparenz
	Transparenz = 100;
	if(ocp<=Transparenz)
	{
		setTimeout('ocp=ocp+10;fadeInPic(w, h)',50);
		document.getElementById("PicSrc").style.opacity = ocp/100
		document.getElementById("PicSrc").style.filter = 'Alpha(opacity=' + ocp + ')'; // IE
	}
	else
	{
		//volles Alpha
		document.getElementById("PicSrc").style.opacity = Transparenz/100
		document.getElementById("PicSrc").style.filter = 'Alpha(opacity=' + Transparenz + ')'; // IE
		ocp=100;
	}
}



function closePicView()
{
	window.clearTimeout(to)
	document.getElementById('PicLayer').style.visibility = 'hidden'
	document.getElementById('PicSrc').style.visibility = 'hidden'
	document.getElementById('swf').style.visibility = 'visible'
}



function createDiv()
{
	YPos=window.pageYOffset
	document.write("<div id=\"PicLayer\" style=\"background-color:#606060; width:100%; height:100%; visibility:hidden; position:absolute; left:0px; top:0px; z-index:99998\">")
	document.write("<img id=\"close\" style=\"position:absolute; right:20; top:20; cursor:pointer; cursor:hand; z-index:99999\" src=\"img/schliessen.gif\" onclick=\"closePicView()\">")
	
	document.write("<img id=\"next\" style=\"position:absolute; right:20; top:50; cursor:pointer; cursor:hand; z-index:99999\" src=\"img/next.gif\" onclick=\"shownext()\">")
	document.write("<img id=\"prev\" style=\"position:absolute; left:20; top:50; cursor:pointer; cursor:hand; z-index:99999\" src=\"img/prev.gif\" onclick=\"showprev()\">")
	
	document.write("<img id=\"PicSrc\" style=\"position:absolute\" src=\"\">")
	document.write("<img id=\"HiddenPicSrc\" style=\"position:absolute; visibility:hidden;\" src=\"\">")
	document.write("<\/div>")
}

