/*
lib.js for Fussl Modestra�e

Author:			  manfred.schneiderbauer@world-direct.at
Version:      1.212
Last Changed:	2007-02-15
*/

// position sub menu
function posSubmenu(){
var offL=326;
if(isGecko){offL=319;}
if(isIE7up){offL=318;}

  d('dvSubnaviTarget').style.left=document.body.offsetWidth/2-offL+'px';
  window.setTimeout("posSubmenu();",250);
}
clib_onload('d("dvSubnaviTarget").style.visibility="visible";posSubmenu()');

// handle the sub navigation
// currentPage=id for the submenu to currently display
function handleSubNavi(currentPage){

// set currently active main menu item
var allLis=d('clib_MenuWrapper').getElementsByTagName('li');
for(var b=0;b<allLis.length;b++)
  {
   if(allLis[b].className.indexOf('menu_button_active')!=-1)
    {
     window.currentMainmenuItem=allLis[b].getElementsByTagName('a')[0].href;
    }
  }

if(!window.disableSubnaviHandler){
var sub=false;
if(!currentPage)
  {
  if(!window.currentSubPage&&!window.currentMainmenuItem)
    {
    currentPage=location.href;
    }
  if(window.currentSubPage)
    {
    currentPage=window.currentSubPage;
    }
  if(window.currentMainmenuItem)
    {
     currentPage=window.currentMainmenuItem
    }

  }
d('dvSubnaviTarget').innerHTML='';
// collect all submenus in allSubDivs[]
var ii=0; var allSubDivs=new Array();
var allDivs=document.getElementsByTagName('div');
for(var i=0;i<allDivs.length;i++)
  {
    if(allDivs[i].className.indexOf('menu_dropdown')!=-1)
      {
       allSubDivs[ii]=allDivs[i];
       if(!isIE5up)
          {
          allSubDivs[ii].title=allSubDivs[ii].previousSibling.getElementsByTagName('a')[0].href;
          }else{
          try{
          allSubDivs[ii].title=allSubDivs[ii].previousSibling.getElementsByTagName('a')[0].href;
          }catch(error){
          allSubDivs[ii].title=allSubDivs[ii].previousSibling.href;
          }
          }
       ii++;
       }
  }
// find the anchor set to currently display
var thisSet=''; var cs=0;
for(var c=0;c<allSubDivs.length;c++)
  {
  if(currentPage.indexOf(allSubDivs[c].title)!=-1)
    {
    thisSet=allSubDivs[c];
    }
  }
// now, fill the links into the target DIV
if(thisSet!='')
  {
  var thisAs=thisSet.getElementsByTagName('a');
  var newA='';
  for(var i=0;i<thisAs.length;i++)
    {
    newA=document.createElement('a');
    newA.href=thisAs[i].href;
    newA.target=thisAs[i].target;
    newA.className='aSubmenu';
    newA.innerHTML=thisAs[i].innerHTML;
    newA.style.paddingLeft='18px';
    newA.onclick=function(){fade('dvSubnaviTarget',false);}
    newA.style.color='#898989';
    newA.onmouseout=function(){this.style.color='#898989';}
    newA.onmouseover=function(){this.style.color='#aeaeae';}
    if(thisAs[i].href.indexOf(location.href)!=-1)
      {
       newA.style.color='#aeaeae';
       newA.onmouseout=function(){this.style.color='#aeaeae';}
      }
    d('dvSubnaviTarget').appendChild(newA);
    }
  }
}
}
clib_onload("handleSubNavi()");

function correctMainmenuOnGecko(){try{
var mLis=d('clib_MenuWrapper').getElementsByTagName('li');
var thisA='';
for(var i=0;i<mLis.length;i++)
  {
   if(mLis[i].className.indexOf('menu_button')!=-1)
    {
     thisA=mLis[i].getElementsByTagName('a')[0];
     thisA.style.position='relative';
     if(!isIE7up){thisA.style.left='4px';}else{thisA.style.left='7px';}
     if(!isIE5up||isIE7up)
      {
      thisA.style.top='7px';
      }
    }
  }
fade('dvMenunav',true);
}catch(error){window.setTimeout("correctMainmenuOnGecko();",250);}}
clib_onload("correctMainmenuOnGecko()");

// set current page to be recognized by the top menu thru the breadcrumbs
function setCurrentSubPage(){
var allSp=document.getElementsByTagName('span');
var bcCount=0;
for(var i=0;i<allSp.length;i++)
  {
  if(allSp[i].className=='breadcrumb'&&bcCount<2)
    {
     if(bcCount==0)
      {
       bcCount++;
      }else{
       try
        {
        window.currentSubPage=allSp[i].getElementsByTagName('a')[0].href;
        }catch(error){
        window.currentSubPage='';
        }
      }
    }
  }
handleSubNavi();
}
clib_onload("setCurrentSubPage()");

// fade element
function fade(id,mode,count){
if(!count&&mode){count=0;}
if(!count&&!mode){count=100;}
if(isIE55up)
  {
   //d(id).style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+count+')';
   if(count==100){d(id).style.filter='';}

  }else{
   d(id).style.opacity=count/100;
   d(id).style.MozOpacity=count/100;
   d(id).style.khtmlOpacity=count/100;
  }
if(count==0&&mode){d(id).style.visibility='visible';}
if(count<11&&!mode){d(id).style.visibility='hidden';}
if(mode){count=count+10;}
if(!mode){count=count=count-10;}
if((mode&&count<101)||(!mode&&count>0)){window.setTimeout("fade('"+id+"',"+mode+","+count+");",15);}
}

// init the popslider
function popslider_Init(){
try{

// get refs
var ss=d('startsite');
var bgimage=ss.getElementsByTagName('img')[0];
var small_1=ss.getElementsByTagName('img')[1];
var big_1=ss.getElementsByTagName('img')[2];
var small_2=ss.getElementsByTagName('img')[3];
var big_2=ss.getElementsByTagName('img')[4];
var small_3=ss.getElementsByTagName('img')[5];
var big_3=ss.getElementsByTagName('img')[6];

// style background image
bgimage.style.width='636px'; bgimage.style.height='300px';
bgimage.style.position='absolute'; bgimage.style.top='1px';
bgimage.style.zIndex=9;
bgimage.style.visibility='visible';

// correctly resize all images
big_1.style.width='636px'; big_1.style.height='300px';
small_1.style.width='175px'; small_1.style.height='80px';
big_2.style.width='636px'; big_2.style.height='300px';
small_2.style.width='175px'; small_2.style.height='80px';
big_3.style.width='636px'; big_3.style.height='300px';
small_3.style.width='175px'; small_3.style.height='80px';

// position thumbs
small_1.style.top='210px'; small_1.style.left='35px';
small_2.style.top='210px'; small_2.style.left='230px';
small_3.style.top='210px'; small_3.style.left='425px';
if(isIE7up)
  {
  small_1.style.left='65px';
  small_2.style.left='260px';
  small_3.style.left='455px';
  }

// init position big images
big_1.style.top='301px'; big_2.style.top='301px'; big_3.style.top='301px';

// set z-indizes and opacity
small_1.style.zIndex=20; small_2.style.zIndex=20; small_3.style.zIndex=20;
small_1.className='transThumb'; small_2.className='transThumb'; small_3.className='transThumb';
big_1.style.zIndex=10; big_1.style.zIndex=10; big_1.style.zIndex=10;

// make initial images visible
small_1.style.visibility='visible'; big_1.style.visibility='visible';
small_2.style.visibility='visible'; big_2.style.visibility='visible';
small_3.style.visibility='visible'; big_3.style.visibility='visible';

// set cursors and handlers
if(isIE5up){small_1.style.cursor='hand';}else{small_1.style.cursor='pointer';}
small_1.onmouseover=function(){popslider(true,1);this.className='fullThumb';}
small_1.onmouseout=function(){popslider(false,1);this.className='transThumb';}
if(isIE5up){small_2.style.cursor='hand';}else{small_2.style.cursor='pointer';}
small_2.onmouseover=function(){popslider(true,2);this.className='fullThumb';}
small_2.onmouseout=function(){popslider(false,2);this.className='transThumb';}
if(isIE5up){small_3.style.cursor='hand';}else{small_3.style.cursor='pointer';}
small_3.onmouseover=function(){popslider(true,3);this.className='fullThumb';}
small_3.onmouseout=function(){popslider(false,3);this.className='transThumb';}

window.slide_1_mode=0; window.slide_2_mode=0; window.slide_3_mode=0;
window.pos_1=301; window.pos_2=301; window.pos_3=301;

popslider_Move(); // stop existing and start moving
}catch(error){popslider_showerror(error.description);}
}

// change popping mode for a slide
// mode=true||false=in our out, obj=number of object to move (1-3)
function popslider(mode,obj){

// get refs
var ss=d('startsite');
var small_1=ss.getElementsByTagName('img')[1];
var big_1=ss.getElementsByTagName('img')[2];
var small_2=ss.getElementsByTagName('img')[3];
var big_2=ss.getElementsByTagName('img')[4];
var small_3=ss.getElementsByTagName('img')[5];
var big_3=ss.getElementsByTagName('img')[6];

var thisImg=eval("big_"+obj);

if(mode)
  {
  eval("window.slide_"+obj+"_mode=1;");
  }else{
  eval("window.slide_"+obj+"_mode=2;");
  }
}

// execute popping
function popslider_Move(){

// get refs
var ss=d('startsite');
var small_1=ss.getElementsByTagName('img')[1];
var big_1=ss.getElementsByTagName('img')[2];
var small_2=ss.getElementsByTagName('img')[3];
var big_2=ss.getElementsByTagName('img')[4];
var small_3=ss.getElementsByTagName('img')[5];
var big_3=ss.getElementsByTagName('img')[6];

var pos_1=window.pos_1; if(window.slide1_mode==1&&pos_1<1){pos_1=0;}
var pos_2=window.pos_2; if(window.slide2_mode==1&&pos_2<1){pos_2=0;}
var pos_3=window.pos_3; if(window.slide3_mode==1&&pos_3<1){pos_3=0;}

var multi=1.15; var divi=1.1;
if(isGecko){multi=1.2; var divi=1.15;}

// handle image 1
if(window.slide_1_mode==1)
  {
   if(pos_1>-1)
    {
    pos_1=pos_1/divi;
    if(pos_1<1){pos_1=1;}
    big_1.style.top=pos_1+'px';
    big_1.style.zIndex=11;
    window.pos_1=pos_1;
    }else{
    window.slide_1_mode=0;
    }
  }
if(window.slide_1_mode==2)
  {
   if(pos_1<400)
    {
    pos_1=pos_1*multi;
    big_1.style.top=pos_1+'px';
    big_1.style.zIndex=10;
    window.pos_1=pos_1;
    }else{
    window.slide_1_mode=0;
    }
  }

// handle image 2
if(window.slide_2_mode==1)
  {
   if(pos_2>-1)
    {
    pos_2=pos_2/divi;
    if(pos_2<1){pos_2=1;}
    big_2.style.top=pos_2+'px';
    big_2.style.zIndex=11;
    window.pos_2=pos_2;
    }else{
    window.slide_2_mode=0;
    }
  }
if(window.slide_2_mode==2)
  {
   if(pos_2<400)
    {
    pos_2=pos_2*multi;
    big_2.style.top=pos_2+'px';
    big_2.style.zIndex=10;
    window.pos_2=pos_2;
    }else{
    window.slide_2_mode=0;
    }
  }

// handle image 3
if(window.slide_3_mode==1)
  {
   if(pos_3>-1)
    {
    pos_3=pos_3/divi;
    if(pos_3<1){pos_3=1;}
    big_3.style.top=pos_3+'px';
    big_3.style.zIndex=11;
    window.pos_3=pos_3;
    }else{
    window.slide_3_mode=0;
    }
  }
if(window.slide_3_mode==2)
  {
   if(pos_3<400)
    {
    pos_3=pos_3*multi;
    big_3.style.top=pos_3+'px';
    big_3.style.zIndex=10;
    window.pos_3=pos_3;
    }else{
    window.slide_3_mode=0;
    }
  }

window.setTimeout("popslider_Move();",15);
}

// show error alert if content is incomplete
function popslider_showerror(msg){
var errortext='Der Popslider kann nicht angezeigt werden, da die notwendigen Inhalte im Typo3-Backend nicht korrekt eingepflegt sind.\n\nEs muessen in der Spalte NORMAL insgesamt sieben Bilder in vier Inhaltselementen enthalten sein, und zwar in dieser Reihenfolge:\n1. Inhaltselement Typ Bild mit 1 Hintergrundbild\n2.Inhaltselement Typ Bild mit 1 Vorschaubild und 1 grossen Bild\n3.Inhaltselement Typ Bild mit 1 Vorschaubild und 1 grossen Bild\n4.Inhaltselement Typ Bild mit 1 Vorschaubild und 1 grossen Bild\n\nDas Hintergrundbild und die grossen Bilder muessen 636x300 Pixel, die Vorschaubilder 175x80 Pixel messen. Position muss auf Oben mittig, 1 Spalte, eingestellt sein.';
alert(errortext);
}

// fit main table height on non-IE and IE7
function fitMainTableHeight(){try{
var mt=d('tbContainer'); var h=0;
if(isIE7up){h=document.documentElement.offsetHeight-5;}else{h=window.innerHeight;}
if(h>mt.offsetHeight)
  {
  mt.style.height=h+'px';
  }
window.setTimeout("fitMainTableHeight();",250);
}catch(error){}}
if(!isIE5up||isIE7up){clib_onload("fitMainTableHeight()");}
