var selectedFile=0;
var frame_Control;
var auto_Change;
var d_elay;
var info_Control;
var bg_Control;
var start_Number="";
var Anzahl;
/******************************************************************/
var newStatus = new Array("Diaschau",
"Biografische Notiz",
"",
"",
"",
"",
"",
"",
"",
"",
"Diaschau-Einstellungen",
"Navigationsmodus"
);

/****************************************************************/
function setDivBg(n)
{
selectedFile=Number(n)-1;
selectBorder(selectedFile);
}
/****************************************************************/
function showCat(type)
{
numb=selectedFile+1;
if(numb==0)numb=1;
var windPar = "'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,left=0,top=0'";
window.open("p_frame.htm?"+type,"Malerei","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,left=0,top=0,fullscreen=yes,scrollbars=no");
}
/**************************************************************************************/
function showSlide()
{
if(start_Number=="")
	{
	realPictNumb=selectedFile+1;
	if(realPictNumb==0)
		realPictNumb=1;
	}
else
	realPictNumb=start_Number;

WWidth=screen.availWidth;
WHeight=screen.availHeight;
if(navigator.appVersion.indexOf("MSIE")=="-1")
	{
	if(bg_Control=="")
		window.open('p_slidFr.htm','Diaschau',"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+WWidth+",height="+WHeight+",left=0,top=0");
	else
		window.open('p_slidFr_b.htm','Diaschau',"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+WWidth+",height="+WHeight+",left=0,top=0");
	}
else
	window.open('p_slidFr2.htm','Diaschau','fullscreen=yes,resizable=no,left=0,top=0');
}
function setFocus()
{
if(Suchoption.closed == false)
	{
	Suchoption.focus();
	focussierer=window.setTimeout("setFocus()",100);
	}
else
	window.clearTimeout(focussierer);
}	
/******************************************************************/
function loadImgThumbs()
{
switch(docTitle)
	{
	case "WL1":
	Anzahl=WL1.length;
	break;
	case "WL2":
	Anzahl=WL2.length;
	break;
	case "WL3":
	Anzahl=WL3.length;
	}
lineCount=0;
if(window.innerHeight)
	Seitenbreite=Math.round(window.innerWidth-162);
else
	Seitenbreite=document.getElementById("myWindow").offsetWidth-162;
	
Bildbreite=150;
itemNr=Math.round(Seitenbreite/Bildbreite);

imgTable="<table style='padding-top:8px;table-layout:fixed' width='100%' border='0' cellspacing='0' cellpadding='0'><tr>";
textTable="";

for (i=0;i<Anzahl;i++)
	{
	switch(docTitle)
	{
	case "WL1":
	fullSrc=WL1[i];
	txtSrc=WL1[i];
	a=fullSrc.indexOf("*");
	b=fullSrc.indexOf("+");
	imgSrc="WL1/thumbnails/"+fullSrc.substring(0,a);
	imgId="A";
	break;
	case "WL2":
	fullSrc=WL2[i];
	txtSrc=WL2[i];
	a=fullSrc.indexOf("*");
	b=fullSrc.indexOf("+");
	imgSrc="WL2/thumbnails/"+fullSrc.substring(0,a);
	imgId="B";
	break;
	case "WL3":
	fullSrc=WL3[i];
	txtSrc=WL3[i];
	a=fullSrc.indexOf("*");
	b=fullSrc.indexOf("+");
	imgSrc="WL3/thumbnails/"+fullSrc.substring(0,a);
	imgId="C";
	}
	a=fullSrc.indexOf("*");
	b=fullSrc.indexOf("+");

	sizeString=fullSrc;
	c=sizeString.indexOf("*");
	d=sizeString.indexOf("+");
	
	
	imgH_W=sizeString.substring(c+1,d);
	e=imgH_W.indexOf(",");
	imgH=imgH_W.substring(0,e);
	imgW=imgH_W.substring(e+1);

	if(imgH>imgW)
		{
		imgHeight=108
		prozent=Math.round(imgHeight/(imgH/100));
		imgWidth=Math.round((imgW/100)*prozent);
		}
	else
		{
		imgWidth=108;
		prozent=Math.round(imgWidth/(imgW/100));
		imgHeight=Math.round((imgH/100)*prozent);
		}
	
	imgHeight=imgHeight+"px";
	imgWidth=imgWidth+"px";

	lineCount=lineCount+1;
	if(lineCount==itemNr)
		{
		lineCount=1;
		imgTable=imgTable+"<\/tr><tr>"+textTable;
		textTable="";
		breakControl="<\/tr><tr>";
		}
	else
		breakControl="";
	
	
	b=txtSrc.indexOf("+");
	theFileString=txtSrc.substring(b+1);
	c=theFileString.indexOf(" ");	


imgTable=imgTable+breakControl+"<td style='vertical-align:middle;text-align:center;background-color:#FFFFFF;width:114px;white-space:nowrap' id='B"+i+"' bgcolor='#FFFFFF' onClick='start("+i+")'><span style='white-space:nowrap;vertical-align:top'><img id='"+(imgId+i)+"' name='thumb' src="+imgSrc+" style='width:"+imgWidth+";height:"+imgHeight+";cursor:pointer;vertical-align:top;border:1px' alt='"+convertAlternate(theFileString)+"'><img src='../layout/S1b.gif' style='width:6px;height:"+imgHeight+";vertical-align:top' alt=''><\/span><br/><span style='white-space:nowrap'><img src='../layout/S2b.gif' style='width:"+imgWidth+";height:6px;vertical-align:top' alt=''><img src='../layout/S3b.gif' style='width:6px;height:6px;vertical-align:top' alt=''><\/span><\/td>";



	if(lineCount!=itemNr-1)
		imgTable=imgTable+"<td>&nbsp;<\/td>";

	textTable=textTable+"<td width='114' align='center' class='Bildunterschrift'>"+theFileString+"<\/td>";

	if(lineCount!=itemNr-1)
		textTable=textTable+"<td>&nbsp;<\/td>";
	}
img_Layout="<\/tr><tr>"+textTable+"<\/tr><\/table>";
imgTable=imgTable+img_Layout;
document.write(imgTable);
}
var numb;
/****************************************************************/
function showSingleImage(nb)
{
numb=Number(nb);
docTitle="selbst";
if(document.getElementById("text2").style.display=="block")
	docTitle="WL1";
if(document.getElementById("text3").style.display=="block")
	docTitle="WL2";
if(document.getElementById("text4").style.display=="block")
	docTitle="WL3";
	
switch(docTitle)
	{
	case "WL3":
	windName="Fotografie 1932 - 1970";	
	fileString=WL3[numb];
	fullLength=WL3.length;
	break;
	case "WL2":
	windName="Aquarelle 1967 - 1976";	
	fileString=WL2[numb];
	fullLength=WL2.length;
	break;
	case "WL1":
	windName="Aquarelle 1943 - 1966";	
	fileString=WL1[numb];
	fullLength=WL1.length;
	break;
	default:
	windName="Walther Lefeldt";	
	docTitle="WL3";
	
	biogType = new Array ("1","2");
	k=Math.floor (Math.random() *2);
	Pnum=biogType[k];
	if(Pnum==1)
		fileString="selbst.jpg*800,634+<b>Walther Lefeldt<\/b> Foto W. Seeger 1934";
	else
		fileString="selbst2.jpg*800,634+<b>Walther Lefeldt<\/b>";
	
	
	}
a=fileString.indexOf("*");
theFile=docTitle+"/"+fileString.substring(0,a);
b=fileString.indexOf("+");
SizeString=fileString.substring(a+1,b);

c=SizeString.indexOf(",");

origHeight=SizeString.substring(0,c);
origWidth=SizeString.substring(c+1);

theInfoString=fileString.substring(b+1);

newWidth=origWidth;
newHeight=origHeight;

sc_WindoWWidth=screen.availWidth-260;
sc_WindowHeight=screen.availHeight-260;

if(newHeight>sc_WindowHeight) 
	{
	newHeight=sc_WindowHeight;
	prozent=Math.round(newHeight/(origHeight/100));
	newWidth=Math.round((origWidth/100)*prozent);
	}
if(newWidth>sc_WindoWWidth)
	{
	newWidth=sc_WindoWWidth;
	prozent=Math.round(newWidth/(origWidth/100));
	newHeight=Math.round((origHeight/100)*prozent);
	}

WWidth=Number(newWidth)+100;
WHeight=Number(newHeight)+130;

x=Math.round(((screen.availWidth)/2) - (WWidth/2));	
y=Math.round(((screen.availHeight)/2) - (WHeight/2));

WindN="Window"+numb;

window.open('ImgWind.htm',WindN,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+WWidth+',height='+WHeight+',left='+x+',top='+y);
}

/**************************************************************************************/
/*********************** HTML-Code fuer noscript-Bereich erstellen ************************************/
	var imgCode;
function writeCode()
{	
if(location.href.indexOf("TL")!="-1")
	{
	docTitleCheck = prompt("docTitle:", "");
	if (docTitleCheck == "WL1"||docTitleCheck == "WL2"||docTitleCheck == "WL3")
	{

	lineCount=0;
	itemNr=5;

	imageTable="<table><tr><td>\n";

	switch(docTitleCheck)
	{
	case "WL1":
	Anzahl=WL1.length;
	break;
	case "WL2":
	Anzahl=WL2.length;
	break;
	case "WL3":
	Anzahl=WL3.length;
	
	}

	for(i=1;i<Anzahl+1;++i)
		{

		switch(docTitleCheck)
			{
			case "WL1":
			titleString=WL1[i-1];
			break;
			case "WL2":
			titleString=WL2[i-1];
			break;
			case "WL3":
			titleString=WL3[i-1];
			}	

		a=titleString.indexOf("+");	
		titleString="'"+titleString.substring(a+1)+"'";

		for(k=0;k<titleString.length;k++)
		{
		if(titleString.substring(k,k+4) == "<BR>")
        	titleString = titleString.substring(0,k)+", "+titleString.substring(k+4);
		if(titleString.substring(k,k+3) == "<B>")
        	titleString = titleString.substring(0,k)+titleString.substring(k+3);
		if(titleString.substring(k,k+4) == "<\/B>")
        	titleString = titleString.substring(0,k)+titleString.substring(k+4);
		if(titleString.substring(k,k+4) == "<BR>")
        	titleString = titleString.substring(0,k)+", "+titleString.substring(k+4);
		}

		if(i<10)num="00"+i;
		else num="0"+i;
		
		File = "'"+docTitleCheck+"/thumbnails/"+num+".jpg'";
		imgSrc = docTitleCheck+"/"+num+".jpg";

		lineCount=lineCount+1;
		if(lineCount==itemNr)
			{
			lineCount=1;
			imgCode=imgCode+"<\/tr><tr>";
			
			breakControl="<\/tr><tr><td colspan='5'><img class='invisible' src='layout/transp.gif' width='10' height='20' alt='Abstand'><\/td><\/tr><tr>";
			}
		else
			breakControl="";

		
		imageTable=imageTable+"<a href='"+imgSrc+"'><img src="+File + " alt='' title="+titleString+" style='margin-right:20px;margin-bottom:20px;border:0px' /><span style='display:none'>"+titleString+"<\/span><\/a>\n";		
		}
	
	imgCode=imageTable+"<\/td><\/tr><\/table>";
	window.open("noscript.htm","Code");
	}
	}
}
function convertAlternate(text)
{
for(k=0;k<text.length;k++)
		{
		if(text.substring(k,k+4) == "<BR>"||text.substring(k,k+4) == "<br>")
        	text = text.substring(0,k)+" "+text.substring(k+4);
		if(text.substring(k,k+3) == "<B>"||text.substring(k,k+3) == "<b>")
        	text = text.substring(0,k)+text.substring(k+3);
		if(text.substring(k,k+4) == "<\/B>"||text.substring(k,k+4) == "<\/b>")
        	text = text.substring(0,k)+text.substring(k+4);
		if(text.substring(k,k+4) == "<BR>"||text.substring(k,k+4) == "<br>")
        	text = text.substring(0,k)+" "+text.substring(k+4);
		}
	return text;
}
function convertText(text)
{
while(text.indexOf("<BR>")!="-1")
	{
	a=text.indexOf("<BR>");
	text=text.substring(0,a)+", "+text.substring(a+4);
	}
while(text.indexOf("<br>")!="-1")
	{
	a=text.indexOf("<br>");
	text=text.substring(0,a)+", "+text.substring(a+4);
	}
return text;
}
/*********************************************************************************/
var shadows = new Array(3)
shadows[0] = new Image(); shadows[0].src="../layout/S1.gif";
shadows[1] = new Image(); shadows[1].src="../layout/S2.gif";
shadows[2] = new Image(); shadows[2].src="../layout/S3.gif";
/*********************************************************************************/
var theFile;
var newWidth;
var newHeight;
var theScroll;
/****************************************************************/
var n;
function start(nb)
{
n=1;
if(navigator.appVersion.indexOf("MSIE")=="-1")
	{
	fade("singleImage1");
	fade("mainWindow");
	fade("titleMenue");
	fade("horizLine");
	setTimeout("showImage("+nb+")",800);
	}
else
	showImage(nb);
}
function loadImage()
{
window.scrollTo(0,0);
if(navigator.appVersion.indexOf("MSIE")=="-1")
	fade("infoTable");


document.getElementById("singleImage"+n).innerHTML="<span style='white-space:nowrap'><IMG name='fotoimage' ID='theImage' SRC="+theFile+" height="+newHeight+" width="+newWidth+" BORDER='0'  onClick='next()' onLoad='answerLoading()' alt='Abbildung' title='N&auml;chstes Bild' style='vertical-align:top;cursor:pointer'><img id='sh1' style='vertical-align:top' src="+ shadows[0].src+" width='20' height="+newHeight+" alt=''><\/span><br><span style='white-space:nowrap'><img id='sh2' style='vertical-align:top' src="+ shadows[1].src+" width="+newWidth+" height='20' alt=''><img id='sh3' style='vertical-align:top' src="+ shadows[2].src+" width='20' height='20' alt=''><\/span>";

WWidth=Number(newWidth);
WHeight=Number(newHeight);

}
function resetMe()
{	
selectBorder(numb);
if(window.innerHeight)
	document.body.style.overflow='visible';
else
	document.getElementById("mainWindow").style.overflow='auto';

document.getElementById('imageWindow').style.display="none";
document.getElementById("infoTable").style.visibility="hidden";
if(navigator.appVersion.indexOf("MSIE")=="-1")
	{
	fade("mainWindow");
	fade("titleMenue");
	fade("horizLine");

	if(n==1)
		fade("singleImage1");
	else
		fade("singleImage2");
	}
document.getElementById("singleImage1").innerHTML="";
document.getElementById("singleImage2").innerHTML="";
document.getElementById("mainWindow").style.display="block";
document.getElementById("titleMenue").style.display="block";
document.getElementById("horizLine").style.display="block";

if(navigator.appName.indexOf("Explorer")!="-1")
	document.getElementById("Diaschau").style.display="none";

window.scrollTo(0,theScroll);
if(document.getElementById("text1").style.display=="block")
	{
	/*document.getElementById("fadeImage1").style.display="block";
	document.getElementById("fadeImage2").style.display="block";*/
if(z==1)
	fade("fadeImage1");
else
	fade("fadeImage2");
	}
}
/**************************************************************************/
function answerLoading()
{
document.body.style.overflow='hidden';
document.getElementById("mainWindow").style.display="none";
document.getElementById("titleMenue").style.display="none";
document.getElementById("horizLine").style.display="none";

if(navigator.appName.indexOf("Explorer")=="-1")
	document.getElementById("infoString").style.width=newWidth;
if(navigator.appVersion.indexOf("MSIE 7")!="-1")
	document.getElementById("infoString").style.width=newWidth;

document.getElementById("infoString").innerHTML=convertText(theInfoString);
document.getElementById("infoString").style.top=180+newHeight+"px";
document.getElementById("infoTable").style.visibility="visible";
document.getElementById("imageWindow").style.display="block";
document.getElementById("imageWindow").style.visibility="visible";
if(navigator.appVersion.indexOf("MSIE")=="-1")
{
if(n==2)
	{

	fade("singleImage2");
	setTimeout("fade('singleImage1')",0);
	n=1;

	}
else
	{

	fade("singleImage1");
	setTimeout("fade('singleImage2')",0);
	n=2;
	}
fade("infoTable");
}

if(navigator.appName.indexOf("Explorer")!="-1")
	document.getElementById("Diaschau").style.display="none";
if(navigator.appName.indexOf("Explorer")!="-1"&&AnzBer>662)
	{
	document.getElementById("Diaschau").style.display="block";
	document.getElementById("Diaschau").style.position="absolute";
	document.getElementById("Diaschau").style.left=119;
	document.getElementById("Diaschau").style.bottom=50;
	}
preloadNextImage();
}
/****************************************************************/
function preloadNextImage()
{
nb=numb+1;
if(nb>fullLength-1)
	nb=0;

switch(docTitle)
	{
	case "WL0":
	fileString=WL0[nb];
	fullLength=WL0.length;
	break;
	case "WL1":
	fileString=WL1[nb];
	fullLength=WL1.length;
	break;
	case "WL2":
	fileString=WL2[nb];
	fullLength=WL2.length;
	break;
	case "WL3":
	fileString=WL3[nb];
	fullLength=WL3.length;
	}
a=fileString.indexOf("*");
prelFile=docTitle+"/"+fileString.substring(0,a);
document.images[document.images.length-1].src=prelFile;
}
/****************************************************************/
var textTitle;
function showImage(nb)
{
docTitle="WL0";
if(document.getElementById("text2").style.display=="block")
	docTitle="WL1";
if(document.getElementById("text3").style.display=="block")
	docTitle="WL2";
if(document.getElementById("text4").style.display=="block")
	docTitle="WL3";
if(!window.innerHeight)
	scroll_Y=document.body.scrollTop;
else
	scroll_Y=window.pageYOffset;

theScroll=scroll_Y;
/*if(docTitle=="WL0")
numb=0;
else*/
numb=Number(nb);
selectedFile=numb;

switch(docTitle)
	{
	case "WL1":
	fileString=WL1[numb];
	fullLength=WL1.length;
	textTitle="<B class='mainHeader'><a class='A2' href='WL_index.htm?2'>Walther Lefeldt: Aquarelle&nbsp;&nbsp;1946 - 1966<\/a><\/B>";
	break;
	case "WL2":
	fileString=WL2[numb];
	fullLength=WL2.length;
	textTitle="<B class='mainHeader'><a class='A2' href='WL_index.htm?3'>Walther Lefeldt: Aquarelle&nbsp;&nbsp;1967 - 1976<\/a><\/B>";
	break;
	case "WL3":
	fileString=WL3[numb];
	fullLength=WL3.length;
	textTitle="<B class='mainHeader'><a class='A2' href='WL_index.htm?2'>Walther Lefeldt: Fotografien&nbsp;&nbsp;1930 - 1976<\/a><\/B>";
	break;
	case "WL0":
	fileString=WL0[numb];
	fullLength=WL0.length;
	textTitle="";
	}
a=fileString.indexOf("*");
theFile=docTitle+"/"+fileString.substring(0,a);
b=fileString.indexOf("+");
SizeString=fileString.substring(a+1,b);

c=SizeString.indexOf(",");

origHeight=SizeString.substring(0,c);
origWidth=SizeString.substring(c+1);

theInfoString=fileString.substring(b+1);
document.getElementById("textTitle").innerHTML=textTitle;

newWidth=origWidth;
newHeight=origHeight;

WindowWidth=document.body.offsetWidth-350;
WindowHeight=document.body.offsetHeight-300;
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);
	}
loadImage();
}
var fullLength;
/***********************************************/
function next()
{

num=numb;
num++;
if(num>fullLength-1)
	num=0;
showImage(num);
}
/***********************************************/
function prev()
{

num=numb;
num--;
if(num<0)
	num=fullLength-1;
showImage(num);
}
