var windWidth;
var windHeight;
var newWidth;
var newHeight;
var randNumber=1000;
var Anzahl;
var thePict;
var theFolder;
var n=1;

function changeLayer()
{
if(n==1)
	{
	document.getElementById('linkImage1').style.display="none";
	document.getElementById('linkImage2').style.display="block";
	n=2;
	}
else
	{
	document.getElementById('linkImage2').style.display="none";
	document.getElementById('linkImage1').style.display="block";
	n=1;
	}
}
var change;
function changeImage(m)
{
changeLayer();
writeImage(theImages[m],thePaths[m]);
/*change=setTimeout("changeImage("+m+")",8000);*/
}

function writeImage(docTitle,folder)
{
thePict=docTitle;
theFolder=folder;
loadImage();
}
function loadImage()
{
Anzahl=thePict.length;

/*erstes Bild Zufallsbild*/
if(randNumber>500)
	{
	i=Math.floor (Math.random() * Anzahl);
	randNumber=Number(i);
	}
else
/*alle anderen nacheinander*/
	{
	randNumber++;
	if(randNumber>Anzahl-1)
		randNumber=0;
	}
fileString="images/"+theFolder+"/"+thePict[randNumber];
	
if(location.href.indexOf("vita")!="-1")
	fileString="images/Portraits/004.jpg*350,250+";

if(window.innerWidth)
	{
	windWidth=window.innerWidth;
	windHeight=window.innerHeight;
	}
else
	{
	windWidth=document.getElementById("scheliga_body").offsetWidth;
	windHeight=document.getElementsByTagName('html')[0].offsetHeight;
	}
a=fileString.indexOf("*");
b=fileString.indexOf("+");

imageString=fileString.substring(b+1);
thePictFile=fileString.substring(0,a);

imgH_W=fileString.substring(a+1,b);
e=imgH_W.indexOf(",");
imgH=imgH_W.substring(0,e);
imgW=imgH_W.substring(e+1);


	newWidth=windWidth-900;
	if(newWidth>300)
		newWidth=300;
	if(newWidth<150)
		newWidth=150;

	prozent=Math.round(newWidth/(imgW/100));
	newHeight=Math.round((imgH/100)*prozent);


if(newHeight>(windHeight-330))
	{
	newHeight=(windHeight-330);
	/*newHeight=Math.round((windHeight/5)*2);*/
	
	prozent=Math.round(newHeight/(imgH/100));
	newWidth=Math.round((imgW/100)*prozent);
	}

document.getElementById("theText").style.right=390-(280-newWidth)+"px";
/*alert(windWidth);*/
if(navigator.appVersion.indexOf("MSIE")!="-1")
	windSize=1163;
else
	windSize=1088;

if(location.href.indexOf("referenzen")!="-1")
	{
	if(navigator.appVersion.indexOf("MSIE")!="-1")
		windSize=855;
	else
		windSize=806;
		}
if(location.href.indexOf("archiv")!="-1")
	{
	if(navigator.appVersion.indexOf("MSIE")!="-1")
		windSize=1048;
	else
		windSize=985;
	}
if(location.href.indexOf("extra")!="-1")
	{
	if(navigator.appVersion.indexOf("MSIE")!="-1")
		windSize=835;
	else
		windSize=786;
	}

if(windWidth<windSize&&document.getElementById("fixBereich"))
	{
	document.getElementById("theText").style.top=262+"px";
	document.getElementById("fixBereich").style.height=262+"px";
	document.getElementById("linkImage1").style.top=270+"px";
	document.getElementById("linkImage2").style.top=270+"px";
	}


newHeight=newHeight+"px";
newWidth=newWidth+"px";



divName="linkImage"+n;

document.getElementById(divName).innerHTML="<span style='white-space:nowrap'><img id='frontImg' name='indexImage' style='vertical-align:top;text-align:right;padding-top:0px;cursor:pointer;width:"+newWidth+";height:"+newHeight+"' src='"+thePictFile+"' alt='' onclick='getRandImage()'><img id='sh1' style='vertical-align:top;width:8px;height:"+newHeight+"' src='layout/S1b.gif' alt=''><\/span><br/><span style='white-space:nowrap'><img id='sh2' style='vertical-align:top;width:"+newWidth+";height:8px' src='layout/S2b.gif' alt=''><img id='sh3' style='vertical-align:top;width:8px;height:8px' src='layout/S3b.gif' alt=''><\/span><div id='imgText' style='font-size:10px;padding-right:8px;padding-bottom:12px;padding-top:0px;vertical-align:bottom;text-align:right;white-space:normal;width:"+newWidth+"'>"+imageString+"<\/div>";

document.getElementById(divName).style.height=newHeight;


}
function getRandImage()
{
changeLayer();
loadImage();
}
var typeArray;

function writeThumbnails(docTitle,folder)
{
typeArray=docTitle;
theFolder=folder;

if(window.innerWidth)
	{
	itemNr=Math.round((window.innerWidth-340)/130);
	AnzBer=window.innerHeight;
	Seitenbreite=window.innerWidth;
	}
else
	{	
	itemNr=Math.round((document.getElementById("scheliga_body").offsetWidth-340)/130);
	AnzBer=document.getElementById("scheliga_body").offsetHeight;
	Seitenbreite=document.getElementById("scheliga_body").offsetWidth;
	}
	
lineCount=0;

if(itemNr==2)
imgTable="<table id='thumbnails' border='0' cellspacing='0' cellpadding='0'><tr>";
else
imgTable="<table align='right' width='100%' border='0' cellspacing='0' cellpadding='0'><tr>";

textTable="";



for (i=0;i<typeArray.length;i++)
	{
	imgSrc=typeArray[i];
	
	a=imgSrc.indexOf("*");
	b=imgSrc.indexOf("+");

	sizeString=imgSrc;
	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(Number(imgH)>Number(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);
		
		}
	
	imgHW="height="+imgHeight+" width="+imgWidth;

	shadH=(imgHeight+2)+"px";
	shadW=(imgWidth+2)+"px";

	imgWidth=imgWidth+"px";
	imgHeight=imgHeight+"px";

	

	imgSrc="images/"+folder+"/thumbnails/"+imgSrc.substring(0,a);
	lineCount=lineCount+1;
	
	
	
	if(lineCount==itemNr)
		{
		lineCount=1;
		imgTable=imgTable+"<\/tr><tr>"+textTable;
		textTable="";
		breakControl="<\/tr><tr>";
		}
	else
		breakControl="";

	
	txtSrc=typeArray[i];
	b=txtSrc.indexOf("+");
	theFileString=txtSrc.substring(b+1);
	
	
	if(lineCount==1)
		t_align="left";
	else
		{
		if(lineCount==itemNr-1)
			t_align="right";
		else
			t_align="center";
		}
	
imgTable=imgTable+breakControl+"<td id='B"+i+"' style='cursor:pointer;text-align:"+t_align+";vertical-align:middle;padding-top:0px;padding-left:0px:padding-right:0px;padding-bottom:10px' onClick='start("+i+")'><span style='white-space:nowrap;vertical-align:top'><img id='I"+i+"' name='thumb' src="+imgSrc+" style='width:"+imgWidth+";height:"+imgHeight+";cursor:pointer;vertical-align:top;border:solid 1px;border-color:#B1B1B1;border-left-color:#ddd;border-top-color:#ddd' alt=''><img src='layout/S1b.gif' style='width:6px;height:"+shadH+";vertical-align:top' alt=''><\/span><br/><span style='white-space:nowrap'><img src='layout/S2b.gif' style='width:"+shadW+";height:6px;vertical-align:top' alt=''><img src='layout/S3b.gif' style='width:6px;height:6px;vertical-align:top' alt=''><\/span><\/td>";

if(lineCount==1)
	imgTable=imgTable+"<td style='padding-right:15px;width:120px'>&nbsp;<\/td>";
else
	{
	if(lineCount!=itemNr-1)
		{
		if(lineCount==itemNr-2)
			imgTable=imgTable+"<td style='padding-right:15px;width:120px'>&nbsp;<\/td>";
		else
			imgTable=imgTable+"<td style='padding-right:25px;width:150px'>&nbsp;<\/td>";
		}
	}
}
img_Layout="<\/tr><tr>"+textTable+"<\/tr><\/table>";
imgTable=imgTable+img_Layout;

document.write(imgTable);
}


