var windWidth;
var windHeight;
var newWidth;
var newHeight;

function writeImage()
{
if(window.innerWidth)
	{
	windWidth=window.innerWidth-570;
	windHeight=window.innerHeight-450;
	}
else
	{
	windWidth=document.getElementById("oost_body").offsetWidth-570;
	windHeight=document.getElementById("oost_body").offsetHeight-480;
	}

Anzahl=frontImages.length;
i=Math.floor (Math.random() * Anzahl);
fileString=frontImages[i];

showPicture(fileString);
}
function showPicture(fileString,ww)
{
a=fileString.indexOf("*");
b=fileString.indexOf("+");

imageString=fileString.substring(b+1);

if(location.href.indexOf("vita")!="-1")
	thePict="images/Portraits/"+fileString.substring(0,a);
else
	thePict="images/Zufallsbilder/"+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);

maxWidth=320;
if(windWidth<380)
	maxWidth=200;/*alert(windWidth);*/

newWidth=imgW;
newHeight=imgH;
if(windHeight>100&&windWidth>50)
	{
	if(newHeight>windHeight) 
		{
		newHeight=windHeight;
		prozent=Math.round(newHeight/(imgH/100));
		newWidth=Math.round((imgW/100)*prozent);
		}
	if(newWidth>maxWidth)
		{
		newWidth=windWidth;
		if(newWidth>maxWidth)newWidth=maxWidth;
		prozent=Math.round(newWidth/(imgW/100));
		newHeight=Math.round((imgH/100)*prozent);
		}
	newHeight=newHeight+"px";
	newWidth=newWidth+"px";

if(thePict.indexOf("eckhart")!="-1"||thePict.indexOf("Samsara")!="-1"||thePict.indexOf("amauto")!="-1")
document.getElementById("frontImage").innerHTML="<img id='frontImg' name='indexImage' style='vertical-align:top;text-align:right;padding-top:0px;cursor:pointer;width:"+newWidth+";height:"+newHeight+"' src='"+thePict+"' alt='' onclick='getRandImage()'><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>";
else
document.getElementById("frontImage").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='"+thePict+"' alt='' onclick='getRandImage()'><img id='sh1' style='vertical-align:top;width:8px;height:"+newHeight+"' src='layout/S1b.gif' alt='Schatten'><\/span><br/><span style='white-space:nowrap'><img id='sh2' style='vertical-align:top;width:"+newWidth+";height:8px' src='layout/S2b.gif' alt='Schatten'><img id='sh3' style='vertical-align:top;width:8px;height:8px' src='layout/S3b.gif' alt='Schatten'><\/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>";
}
}

function getRandImage()
{
Anzahl=frontImages.length;
if(Anzahl>1)
{
i=Math.floor (Math.random() * Anzahl);
fileString=frontImages[i];

a=fileString.indexOf("*");
b=fileString.indexOf("+");
if(location.href.indexOf("vita")!="-1")
	thePict="images/Portraits/"+fileString.substring(0,a);
else
	thePict="images/Zufallsbilder/"+fileString.substring(0,a);
if(document.getElementById("frontImg").src.indexOf(thePict)!="-1")
	getRandImage();
else
	showPicture(fileString);
}
}
function openEditor()
{
WWidth=904;
WHeight=700;
x=Math.round(((screen.availWidth)/2) - (WWidth/2));	
y=Math.round(((screen.availHeight)/2) - (WHeight/2));
window.open('editing/textContent.php',"Bearbeiten",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+WWidth+',height='+WHeight+',left='+x+',top='+y);
}
function imageEditor()
{
WWidth=1102;
WHeight=743;
x=Math.round(((screen.availWidth)/2) - (WWidth/2));	
y=Math.round(((screen.availHeight)/2) - (WHeight/2));
window.open('editing/imageManager.php',"Bearbeiten",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+WWidth+',height='+WHeight+',left='+x+',top='+y);
}
function pdfEditor()
{
WWidth=540;
WHeight=480;
x=Math.round(((screen.availWidth)/2) - (WWidth/2));	
y=Math.round(((screen.availHeight)/2) - (WHeight/2));
window.open('editing/pdfManager.php',"Bearbeiten",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+WWidth+',height='+WHeight+',left='+x+',top='+y);
}
