function $(obj){return document.getElementById(obj);}
//position eines objekts bezogen auf viewport ermitteln
function getPosition(obj) {
var pos = { x:0, y:0 };
do {
pos.x += obj.offsetLeft;
pos.y += obj.offsetTop;
} while (obj = obj.offsetParent);
return pos;
}
//parameter slideshow
sdur=3; //time to show a pic between fades in seconds
fdur=.6; //duration of the complete fade in seconds
steps=20; //steps to fade from on pic to the next
stopit=0;
ftim=fdur*1000/steps;stim=sdur*1000;
//funktionen slideshow
//slideshow stoppen
function stopnow(){
stopit=1;
}
//erststart
function myfade(){
$("slidecontrol").innerHTML="<a href='javascript:stopnow();'>Diaschau stoppen</a>";
emax=parr.length;
stopit=0;u=0;slide (startim);
}
//neustart
function goonfade(){
$("slidecontrol").innerHTML="<a href='javascript:stopnow();'>Diaschau stoppen</a>";
emax=parr.length;
stopit=0;u=0;slide (startim);
}
//bildauswahl und setzen der startparameter
function slide(numa){
if(numa>=1){
ifade = $("sig"+(numa-1));
}
else{
ifade = $("sig"+(emax-1));
}
if(numa<=emax){inext=$("sig"+numa);}
if(numa==emax){inext=$("sig0");}
inext.style.visibility = "visible";
inext.style.filter = "Alpha(Opacity=100)";
inext.style.MozOpacity = 1;
inext.style.opacity = 1;
ifade.style.filter = "Alpha(Opacity=100)";
ifade.style.MozOpacity = 1;
inext.style.opacity = 1;
factor = 100/steps;
if(stopit=="0"){
slidenow();
//thumbtransparenz nachführen
stepone=inext.src.split(".jpg");
steptwo=stepone[0].split("/");
restyle(steptwo[steptwo.length-1]);
}
else{
stopit="0";
$("slidecontrol").innerHTML="<a href='javascript:goonfade();'>Diaschau starten</a>";
}
}
//eigentlicher slide
function slidenow(){
check1=ifade.style.MozOpacity;
maxalpha = (100 - factor*u)/100*105;
if(check1<=maxalpha/100){u=u+1;}
curralpha = 100 - factor*u;
ifade.style.filter = "Alpha(Opacity="+curralpha+")";
ifade.style.MozOpacity = curralpha/100;
ifade.style.opacity = curralpha/100;
if(u<steps){window.setTimeout("slidenow()",ftim);}
if(u>=steps && startim<emax){
ifade.style.visibility = "hidden";
ifade.style.zIndex = 1;
inext.style.zIndex = 2;
startim=startim+1;u=0;
window.setTimeout("slide(startim)",stim);}
if(u>=steps && startim>=emax){
ifade.style.visibility = "hidden";
ifade.style.zIndex = 1;
inext.style.zIndex = 2;
startim=1;u=0;
window.setTimeout("slide(startim)",stim);
}
}
//überprüfen der fenstergrösse
function checkSize(){
if (typeof(window.innerHeight)=='number') {//O721,O751,FF.91
this.x=window.innerWidth;
this.y=window.innerHeight;
}
else {
if (document.documentElement&&document.documentElement.clientHeight) {//IE6
this.x=document.documentElement.offsetWidth;
this.y=document.documentElement.offsetHeight;
}
else {
if (document.body&&document.body.clientHeight) {//IE5,IE5.5
this.x=document.body.offsetWidth-2;
this.y=document.body.clientHeight;
}
}
}
return this;
}
//reload bei änderung der fenstergrösse
function resized(){
pagenew=new checkSize()
if(pagenew.x!=page.x || pagenew.y!=page.y){
if(typeof(parr)!="undefined"){
for(i=0;i<parr.length;i++){
$('sig'+i).style.visibility="hidden";
}
}
window.location.href=self.location.href;
}
}
//vorbereitung slideshow
function myload() {
var pos = getPosition($('bigimg'));
var imwidth=$('bigimg').width;
var imheigh=$('bigimg').height;
for(i=0;i<parr.length;i++){
si=document.createElement('img');
si.id='sig'+i;
si.src = parr[i];
si.style.position = "absolute";
si.style.left = pos.x+"px";
si.style.top = pos.y+"px";
si.style.height = imheigh+"px";
si.style.width = imwidth+"px";
si.style.visibility = 'hidden';
si.style.mozopacity = '1';
si.style.filter = 'Alpha(opacity=100)';
si.style.opacity = '1';
jetztaber=document.getElementsByTagName("body")[0].appendChild(si);
}
$("slidecontrol").innerHTML="<a href='javascript:myfade();'>Diaschau starten</a>";
fillstylearray();
}
//bildwechsel ohne reload
function switchimg(shownow,newstartim) {
if(typeof(ifade)!="undefined"){
stopnow();
ifade.style.visibility = "hidden";
inext.style.visibility = "hidden";
}
$('bigimg').src=shownow;
startim=newstartim;
stepone=shownow.split(".jpg");
steptwo=stepone[0].split("/");
restyle(steptwo[steptwo.length-1]);
}
//transparenz des aktuellen thumbs nachführen
//array der relevanten thumbs bilden
function fillstylearray(){
star=new Array();
for(i=0;i<document.images.length;i++){
if(document.images[i].parentNode.parentNode.className=='simg'){
stepone=document.images[i].src.split(".jpg");
steptwo=stepone[0].split("/");
star[star.length]=new Array(document.images[i],steptwo[steptwo.length-1]);
}
}
}
//alle thumbs zurücksetzen, eins faden
function restyle(thetmb){
theactsrc=thetmb+"t";
for(i=0;i<star.length;i++){
if(star[i][1]==theactsrc){star[i][0].className='inact';}
else{star[i][0].className='act';}
}
}
//initialisierung der grössenüberwachung
page=new checkSize();
window.onresize=resized;