/*******************************************************************************
	Filename		: lib.js for www.jerich.at

	Created			: ? (?)
	Created by	: ?

	Last Updated: 25 Apr 2007 (25:60:00)
	Updated by	: Manfred Schneiderbauer, manfred.schneiderbauer@world-direct.at

	Comments		:
*******************************************************************************/
// Version: 1.12

//sfHover = function() {
//	var sfEls = document.getElementById("nav").getElementsByTagName("li");
//	for (var i=0; i<sfEls.length; i++) {
//		sfEls[i].onmouseover=function() {
//			this.className+=" sfhover";
//		}
//		sfEls[i].onmouseout=function() {
//			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
//		}
//	}
//}
///** if (window.attachEvent) window.attachEvent("onload", sfHover);**/
//if (window.addEventListener) {
//    window.addEventListener("onload", sfHover, 0);
//} else if (window.attachEvent) {
//    var retVal = window.attachEvent("onload", sfHover);
//}

// title images slideshow
function titleSlideshow(){
var imgs=d('dvFlashSlideshow');
var allImgsArr=imgs.getElementsByTagName('img');
// define display
var imgContainer='<div style="position:absolute;left:0px;top:0px;background-color:#ffffff;" id="dvSlide_0"><a><img width="450" height="271" src="/fileadmin/dev/img/s.gif"></a></div>';
var ic=1;
// collect relevant images
for(var i=0;i<allImgsArr.length;i++)
  {
   if(allImgsArr[i].src.indexOf('upload')!=-1)
    {
    imgContainer+= '<div id="dvSlide_'+ic+'" style="position:absolute;top:0px;left:0px;">';
    if(allImgsArr[i].parentNode.tagName.toLowerCase()=='a')
      {
       imgContainer+='<a href="'+allImgsArr[i].parentNode.href+'" target="'+allImgsArr[i].parentNode.target+'">';
      }
    imgContainer+='<img ';
    if(allImgsArr[i].title)
      {
       imgContainer+=' title="'+allImgsArr[i].title+'"';
      }
    if(allImgsArr[i].alt)
      {
       imgContainer+=' alt="'+allImgsArr[i].alt+'"';
      }
    imgContainer+=' src="'+allImgsArr[i].src+'" border="0" width="450" height="271">';
    if(allImgsArr[i].parentNode.tagName.toLowerCase()=='a')
      {
       imgContainer+='</a>';
      }
    imgContainer+='</div>';
    ic++;
    }
  }
imgs.innerHTML=imgContainer;
window.slidesLoaded=0;
// attach onload handlers to first 2 slideshow images
imgs.getElementsByTagName('img')[1].onload=function(){window.slidesLoaded++;}
if(imgs.getElementsByTagName('img')[2])
  {
   // attach only if there is a second image; otherwise, mark it as loaded at once
   imgs.getElementsByTagName('img')[2].onload=function(){window.slidesLoaded++;}
  } else {
   window.slidesLoaded++;
  }
titleSlideshow_Wait();
}
// wait for the first two images to be loaded
function titleSlideshow_Wait(){
  if(window.slidesLoaded<2)
    {
     window.setTimeout("titleSlideshow_Wait();",250);
    } else {
     d('dvFlashSlideshow').style.visibility='visible';
     titleSlideshow_Run(0);
    }
}

// start slide show
function titleSlideshow_Run(iterator){
window.outDv=d('dvSlide_'+Number(iterator));
if(d('dvSlide_'+Number(iterator+1)))
  {
  window.inDv=d('dvSlide_'+Number(iterator+1));
  } else {
  window.inDv=d('dvSlide_1');
  }

iterator++;
if(iterator>d('dvFlashSlideshow').getElementsByTagName('img').length-1){iterator=1;}

// execute transition
titleSlideshow_Transit(0);
// re-run
window.inDv.style.zIndex=2; window.inDv.style.visibility='visible';
window.outDv.style.zIndex=1; window.outDv.style.visibility='visible';
if(d('dvFlashSlideshow').getElementsByTagName('img').length>2)
  {
  window.setTimeout("titleSlideshow_Run("+iterator+");",6000);
  }
}
function titleSlideshow_Transit(step){

if(isIE5up)
  {
  window.inDv.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+step+')';
  window.outDv.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+100-step+')';
  } else {
  window.inDv.style.opacity=step/100;
  window.outDv.style.opacity=(100-step)/100;
  }

if(window.CPUSpeed>=2500){step=step+1.5;}
if(window.CPUSpeed<2500&&window.CPUSpeed>=1250){step=step+1;}
if(window.CPUSpeed<1250){step=step+5;}

step=step+2;
// flip z-index in the middle
if(step==50)
  {
   window.inDv.style.zIndex=2;
   window.outDv.style.zIndex=1;
  }
// continue fading
if(step<=100)
  {
   window.setTimeout("titleSlideshow_Transit("+step+");",25);
  } else {
   window.inDv.style.filter=''; window.inDv.style.opacity=''; window.inDv.style.MozOpacity=''; window.inDv.style.KhtmlOpacity='';
   window.outDv.style.filter=''; window.outDv.style.opacity=''; window.outDv.style.MozOpacity=''; window.outDv.style.KhtmlOpacity='';
   window.outDv.style.visibility='hidden';
  }
}

function liftMenu(){
 var menu=d('nav_top'); var i=0;
 try{var allLis=menu.getElementsByTagName('li');}catch(error){}
 try{var allUls=menu.getElementsByTagName('ul');}catch(error){}
 try{var allAs=menu.getElementsByTagName('a');}catch(error){}
 try{var allSpans=menu.getElementsByTagName('span');}catch(error){}
 try{var allDivs=menu.getElementsByTagName('div');}catch(error){}
 try{for(i=0;i<allLis.length;i++){allLis[i].style.zIndex=10;}}catch(error){}
 try{for(i=0;i<allUls.length;i++){allUls[i].style.zIndex=10;}}catch(error){}
 try{for(i=0;i<allAs.length;i++){allAs[i].style.zIndex=10;}}catch(error){}
 try{for(i=0;i<allSpans.length;i++){allSpans[i].style.zIndex=10;}}catch(error){}
 try{for(i=0;i<allDivs.length;i++){allDivs[i].style.zIndex=10;}}catch(error){}
}
if(isIE7up){window.setTimeout('clib_onload("liftMenu()");',2500);}