//Written by Bogdan Blaszczak/BlaTek

BlaTek={
 mL:0,tI:0,A:0,w:0,k:0,
 D:function(){with(this){if(tI)return;A=1;if(k){w=l1().offsetWidth;this.Ar()}else{w=l2().offsetWidth;gG(0);mL=-w;l1().style.marginLeft=mL+'px';this.Al()}}},
 Ar:function(){
 with(BlaTek){
  mL-=40
  if(-mL<w){
   l1().style.marginLeft=mL+'px'
   tI=setTimeout(BlaTek.Ar,50)
  }else{
   mL=0;tI=0
   l1().style.marginLeft='0'
   gG(1);setTimeout('if(BlaTek.A)BlaTek.D()',1)
  }
 }
 },
 Al:function(){
 with(BlaTek){
  mL+=40
  if(mL<0){
   l1().style.marginLeft=mL+'px'
   tI=setTimeout(BlaTek.Al,50)
  }else{
   mL=0;tI=0
   l1().style.marginLeft='0'
   setTimeout('if(BlaTek.A)BlaTek.D()',1)
  }
 }
 },
 gG:function(m){if(m)this.u().appendChild(this.l1());else this.u().insertBefore(this.l2(),this.l1())},
 u:function(){return document.getElementById('gallery').getElementsByTagName('ul')[0]},
 l1:function(){return this.u().getElementsByTagName('li')[0]},
 l2:function(x){x=this.u().getElementsByTagName('li');return x[x.length-1]},
 s:function(){this.A=0}
}
document.onmouseup=function(){BlaTek.s()}
if(document.getElementById)document.write('<style>#gallery{height:385px;visibility:hidden}#gallery ul{width:1100px}<\/style>')

function initGallery(g,a1,a2,i){
 if(!document.getElementById)return;
 g=document.getElementById('gallery')
 a1=document.getElementById('gallery-left-arrow')
 a2=document.getElementById('gallery-right-arrow')
 g.style.visibility=a1.style.visibility=a2.style.visibility='visible'

 a1.onmousedown=function(){BlaTek.k=0;BlaTek.D()};
 a2.onmousedown=function(){BlaTek.k=1;BlaTek.D()};
 a1=a1.getElementsByTagName('img')[0]
 a2=a2.getElementsByTagName('img')[0]
 a1.onmouseover=a1.onmouseout=a2.onmouseover=a2.onmouseout=rollMeX

 Tmi=[]
 Tmi[0]=new Image();Tmi[0].src='img/arrow_left_on.gif'
 Tmi[1]=new Image();Tmi[1].src='img/arrow_right_on.gif'
}

function rollMeX(e){
 e=e||event;e=e.type=='mouseout'
 this.src=e?this.src.replace(/_on\.gif/i,'.gif'):this.src.replace(/.gif/i,'_on.gif')
 
 if(e){
  BlaTek.s()
 }else{
  BlaTek.k=this.alt=='next'?1:0
  BlaTek.D()
  BlaTek.s()
 }
}
