/*
lib.js for Wildenhofer

Author:			  manfred.schneiderbauer@world-direct.at
Version:      1.011
Last Changed:	2007-06-12
*/

// flip images on start page
function changeImage(obj,mode,url){
  var ti=obj.getElementsByTagName('img')[0]; // menu image
  var bg=d('startpage-right').getElementsByTagName('img')[0]; // big background image

  var container=bg.parentNode.parentNode; // container element for the big background image
  var allBigImgs=''; var thisBigImg='';

  // put big hover images into container, if not already done so

  if(!window.bigImagesPrepared)
    {
    window.bigImagesPrepared=true;
    allBigImgs=getElementsByClass('img','hidden-ro-image');
    var ni='';
    for(var i=0;i<3;i++)
      {
       ni=document.createElement('img');
       ni.src=allBigImgs[i].src;
       ni.id=allBigImgs[i].id.replace('imagebig_','hoverimage_');
       ni.style.position='absolute';
       ni.style.top='0px'; ni.style.left='0px';
       ni.style.height='0px';
       ni.style.width='358px';
       container.appendChild(ni);
      }
    }

  // get the current image
  allBigImgs=container.getElementsByTagName('img');
  for(i=0;i<allBigImgs.length;i++)
    {
     if(allBigImgs[i].id.indexOf(ti.id)!=-1)
      {
       thisBigImg=allBigImgs[i];
      }
    }

  if(mode)
    { // set global trigger for this image to in
     eval("window.transitImage_"+thisBigImg.id+"='in';");
    }else{ // set global trigger for this image to out
     eval("window.transitImage_"+thisBigImg.id+"='out';");
    }

  ti.src=url; // swap menu image

if(!window.transitIsRunning){changeImage_transit();} // init transition

}

// transition
function changeImage_transit(){try{

  window.transitIsRunning=true;
  var container=d('startpage-right').getElementsByTagName('img')[0].parentNode.parentNode;
  var currentlyExecuting=false;

  // attach img refs to window if not yet done
  if(!window.bigImgsArray)
    {
    var allBigImgs=d('startpage-right').getElementsByTagName('img')[0].parentNode.parentNode.getElementsByTagName('img');
    var bigImgs=new Array(); var b=0;
    for(var i=0;i<allBigImgs.length;i++) // collect relevant images
      {
      if(allBigImgs[i].id.indexOf('hoverimage_')!=-1)
        {
          bigImgs[b]=allBigImgs[i];
          b++;
        }
      }
    window.bigImgsArray=bigImgs; // globalize them
    }

  var thisImg=''; var thisOp=0;
  // move each image
  for(var im=0;im<window.bigImgsArray.length;im++)
    {
     // get current states
     thisImg=window.bigImgsArray[im];
     thisImgState=eval("window.transitImage_"+thisImg.id);
     thisImgPos=Number(thisImg.style.height.replace('px',''));

     if(thisImgState=='in') // if in is active...
      {
       thisImg.style.zIndex=2;
       if(thisImgPos<223)
        {
         if(thisImgPos<2){thisImgPos=2;}
         thisOp=thisImgPos/2; if(thisOp>100){thisOp=100;}
         if(isIE5up)
          {
           thisImg.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+thisOp+')';
          }else{
           thisImg.style.opacity=thisOp/100; thisImg.style.MozOpacity=thisOp/100; thisImg.style.KhtmlOpacity=thisOp/100;
          }
         thisImgPos=Math.round(thisImgPos*1.65);
         if(thisImgPos>222){thisImgPos=222;}
         thisImg.style.height=thisImgPos+'px';
         currentlyExecuting=true;
        }else{
         eval("window.transitImage_"+thisImg.id+"=''");
         thisImg.style.zIndex='';
        }
      }
     if(thisImgState=='out') // if out is active...
      {
       window.transitCount=window.transitCount-1;
       thisImg.style.zIndex=1;
       if(thisImgPos>1)
        {
         thisImgPos=Math.round(thisImgPos/1.65);
         if(thisImgPos<=2){thisImgPos=0;}
         thisImg.style.height=thisImgPos+'px';
         currentlyExecuting=true;
        }else{
         eval("window.transitImage_"+thisImg.id+"=''");
         thisImg.style.zIndex='';
        }
      }
    }

if(!currentlyExecuting) // reset position if not running; workaround for IE7 layer model bug
  {
  container.style.position='';
  }else{
  container.style.position='relative';
  }

}catch(error){}
window.setTimeout("changeImage_transit();",20);
}

// deactivate the standard mail form's submit button as soon as it has been clicked
function deactivateStandardformSubmitWhenSent(){
try{
var butt=getElementByClass('input','mf-submit');
butt.onclick=function()
  {
   if(this.parentNode.parentNode.parentNode.parentNode.parentNode.onsubmit())
    {
    this.value='Wird gesendet...';
    this.onclick=function(){return false;}
    }
  }
}catch(error){}}
clib_onload("deactivateStandardformSubmitWhenSent()");

