function start(p)
{
if(p)
	{
	slidePict="images/Plakat_Ausstellung"+p+".jpg";
	imageString="";
	if(window.innerWidth)
		{
		windWidth=window.innerWidth-580;
		windHeight=window.innerHeight-450;
		}
	else
		{
		windWidth=document.getElementById("depot_body").offsetWidth-580;
		windHeight=document.getElementById("depot_body").offsetHeight-450;
		}
	imgH=900;
	imgW=637;
	theClick="showPicture("+p+")";
	newWidth=imgW;
	newHeight=imgH;
	
if(newHeight>windHeight) 
	{
	newHeight=windHeight;
	prozent=Math.round(newHeight/(imgH/100));
	newWidth=Math.round((imgW/100)*prozent);
	}
if(newWidth>windWidth)
	{
	newWidth=windWidth;
	prozent=Math.round(newWidth/(imgW/100));
	newHeight=Math.round((imgH/100)*prozent);
	}
	
	newHeight=newHeight+"px";
	newWidth=newWidth+"px";
	}
else
	{
	
	getRandImage();
	theClick="next()";
	}
var avWidth;
var anzBer;
if(window.innerWidth)
	{
	avWidth=window.innerWidth;
	anzBer=window.innerHeight;
	}
else
	{
	avWidth=document.getElementById("depot_body").offsetWidth;
	anzBer=document.getElementById("depot_body").offsetHeight;
	}
if(avWidth>1360)
	window.resizeTo(1360,950);
if(location.href.indexOf("anprall")!="-1")
		imageString="";

if(avWidth>900)
	{
	if(location.href.indexOf("anprall")=="-1")
		document.getElementById("fadeImage"+n).innerHTML="<span style='white-space:nowrap'><img id='frontImg' name='indexImage' style='vertical-align:top;text-align:right;padding-top:0px;visibility:hidden' src="+slidePict+" width="+newWidth+" height="+newHeight+" onClick="+theClick+" alt='' onLoad='showAllImages()'><img id='sh1' style='visibility:hidden;vertical-align:top' src='layout/S1b.gif' width='8' height="+newHeight+" alt='Schatten' onLoad='showAllImages()'><\/span><br/><span style='white-space:nowrap'><img id='sh2' style='visibility:hidden;vertical-align:top' src='layout/S2b.gif' width="+newWidth+" height='8' alt='Schatten' onLoad='showAllImages()'><img id='sh3' style='visibility:hidden;vertical-align:top' src='layout/S3b.gif' width='8' height='8' alt='Schatten' onLoad='showAllImages()'><\/span><div id='imgText' style='letter-spacing:0px;font-size:10px;padding-right:8px;padding-bottom:12px;padding-top:4px;vertical-align:bottom;text-align:right;white-space:normal;width:"+newWidth+"'>"+imageString+"<\/div><\/div>";
	else
		{
		document.getElementById('fadeImage'+n).innerHTML="<span style='white-space:nowrap'><img ID='frontImg' name='indexImage' src="+slidePict+" style='vertical-align:top' width="+newWidth+" height="+newHeight+" alt=''><img id='sh1' src="+shadows[0].src+" style='vertical-align:top' width='8' height="+newHeight+" alt='Schatten'><\/span><br><span style='white-space:nowrap'><img id='sh2' src="+shadows[1].src+" style='vertical-align:top' width="+newWidth+" height='8' alt='Schatten'><img id='sh3' src="+shadows[2].src+" style='vertical-align:top' width='8' height='8' alt='Schatten'><\/span><div id='imgText' style='letter-spacing:0px;font-size:10px;padding-right:8px;padding-bottom:12px;padding-top:4px;vertical-align:bottom;text-align:right;white-space:normal;width:"+newWidth+"'>"+imageString+"<\/div>";
		nh=Number(newHeight.substring(0,newHeight.length-2));
		document.getElementById("frontImage").style.height=(nh+20)+"px";
		}
	if(!p)autoPlay=setTimeout("nextImage()",10000);
	}
else
	document.getElementById("frontImage").style.display="none";
	
}
function next()
{
if(playCtrl==1)
	{
	clearTimeout(autoPlay);
	playCtrl=0;
	nextImage();
	}
else
	nextImage();
}
var newWidth;
var newHeight;
var autoPlay;
var playCtrl=1;
var n=1;

var shadows = new Array(3)
shadows[0] = new Image(); shadows[0].src="layout/S1b.gif";
shadows[1] = new Image(); shadows[1].src="layout/S2b.gif";
shadows[2] = new Image(); shadows[2].src="layout/S3b.gif";

var L_ctrl=1;

/*******************************************************************************/
function updateImage()
{
nh=Number(newHeight.substring(0,newHeight.length-2));

document.getElementById("frontImage").style.height=(nh+50)+"px";

getRandImage();
/*document.images[document.images.length-1].src=slidePict;*/
document.getElementById("preload").src=slidePict;
}

function nextImage()
{
fade('fadeImage'+n);
if(n==1)
	n=2;
else
	n=1;
fade('fadeImage'+n);


document.getElementById('fadeImage'+n).innerHTML="<span style='white-space:nowrap'><img ID='frontImg' name='indexImage' src="+slidePict+" style='vertical-align:top' width="+newWidth+" height="+newHeight+" onClick='next()' alt=''><img id='sh1' src="+shadows[0].src+" style='vertical-align:top' width='8' height="+newHeight+" alt='Schatten'><\/span><br><span style='white-space:nowrap'><img id='sh2' src="+shadows[1].src+" style='vertical-align:top' width="+newWidth+" height='8' alt='Schatten'><img id='sh3' src="+shadows[2].src+" style='vertical-align:top' width='8' height='8' alt='Schatten'><\/span><div id='imgText' style='letter-spacing:0px;font-size:10px;padding-right:8px;padding-bottom:12px;padding-top:4px;vertical-align:bottom;text-align:right;white-space:normal;width:"+newWidth+"'>"+imageString+"<\/div>";



/*document.getElementById("imgText").style.visibility="visible";*/
updateImage();
if(playCtrl==1)
	autoPlay=setTimeout("nextImage()",10000);
}
var pctNumber=0;
var WindowHeight;
var randNumber;
/*******************************************************************************/
function getRandImage()
{

Anzahl=file.length;
i=Math.floor (Math.random() * Anzahl);

theExhibition=file[i];

Anzahl=theExhibition.length;
k=Math.floor (Math.random() * Anzahl);

if(k==randNumber)
	getRandImage();
else
	{
	randNumber=k;
filestring=theExhibition[k];


a=filestring.indexOf("*");
b=filestring.indexOf("+");
slidePict=path[i]+"/"+filestring.substring(0,a);

c=filestring.indexOf("]");
imageString=filestring.substring(c+2);

imgH_W=filestring.substring(a+1,b);
e=imgH_W.indexOf(",");
origHeight=imgH_W.substring(0,e);
origWidth=imgH_W.substring(e+1);

newWidth=origWidth;
newHeight=origHeight;

if(Number(newHeight)>=Number(newWidth))
	getRandImage();

if((Number(newWidth)-Number(newHeight))<200)
	getRandImage();

WindowWidth=350;
WindowHeight=250;

if(location.href.indexOf("anprall")=="-1")
	{
	WindowWidth=(Math.round(document.body.offsetWidth/4));
	document.getElementById("frontImage").style.width=(WindowWidth+20)+"px";
	}
else
	{
	WindowWidth=(Math.round(document.body.offsetWidth/5))*2;
	document.getElementById("frontImage").style.width=(WindowWidth+30)+"px";
	}
if(navigator.appVersion.indexOf("MSIE 6")!="-1")
	document.getElementById("frontImage").style.height=document.getElementById("theText").offsetHeight;

	
newWidth=WindowWidth;
newHeight=WindowHeight;

prozent=Math.round(newWidth/(origWidth/100));
newHeight=Math.round((origHeight/100)*prozent);

/*if(document.body.offsetWidth<1000)*/
	

/*if(newHeight>WindowHeight) 
	{
	newHeight=WindowHeight;
	prozent=Math.round(newHeight/(origHeight/100));
	newWidth=Math.round((origWidth/100)*prozent);
	}
if(newWidth>WindowWidth)
	{
	newWidth=WindowWidth;
	prozent=Math.round(newWidth/(origWidth/100));
	newHeight=Math.round((origHeight/100)*prozent);
	}*/
newHeight=newHeight+"px";
newWidth=newWidth+"px";
}
}
function showAllImages()
{
L_ctrl++;
if(L_ctrl==5)
	{
	document.getElementById("sh1").style.visibility="visible";
	document.getElementById("sh2").style.visibility="visible";
	document.getElementById("sh3").style.visibility="visible";
	document.getElementById("frontImage").style.visibility="visible";
	document.getElementById("frontImg").style.visibility="visible";
	document.getElementById("imgText").style.visibility="visible";
	updateImage();
	}
}
