/* AUTO-SCROLL BEGIN */
var browserName = getBrowsname();
var eleres = eleres_korrigalas;
var kep_height = 0;
var aktual = 0;
var max_height = 0;
var irany = -1;
var megy;
var opacity_ertek = 100;
var merre = -1;
var atlatszo;
var kep_szama = 0;
var aktual_kepek=new Array();
aktual_kepek[0]  = eleres+'images/slide_01.jpg';
aktual_kepek[1]  = eleres+'images/slide_02.jpg';
aktual_kepek[2]  = eleres+'images/slide_03.jpg';
aktual_kepek[3]  = eleres+'images/slide_04.jpg';
aktual_kepek[4]  = eleres+'images/slide_05.jpg';
var aktual_kep = aktual_kepek[0];
var max_kepszam = aktual_kepek.length-1;
function preloader(aktual_kepek) 
{
  var i = 0;
  imageObj = new Image();
  for(i=0; i<=3; i++) 
  { imageObj.src=aktual_kepek[i]; }
}
function kep_valt()
{ if (kep_szama < max_kepszam)
  { kep_szama = kep_szama+1;
    aktual_kep = aktual_kepek[kep_szama];
  }
  else
  { kep_szama = 0;
    aktual_kep = aktual_kepek[0];
  }
}
function getImgSize(image)
{ var imgSrc = image;                          //kép-méret: 940*380px
  var newImg = new Image();
  newImg.src = imgSrc;
  kep_height = newImg.height;
  max_height=-(kep_height-120);                //DIV magasság kell: 120px
}
function indul()
{ scroll_vertical(); }
function megall()
{ clearTimeout(megy); }
function startpozicio()
{ getImgSize(aktual_kep);
  document.getElementById("scrolldiv").style.background = "#394712 url('"+aktual_kep+"') no-repeat center 0px ";
  document.getElementById("scrolldiv").title = 'Automatikusan fel-le mozgó banner-képek('+(kep_szama+1)+')';
  document.getElementById("scrolldiv").style.backgroundPosition = "0px 0px";
  scroll_vertical();
}
function set_opacity_ertek(ertek,toDiv)
{ var csstul = '';
  var hova = document.getElementById(toDiv);
  var cssert = ertek;
  if (browserName == 'MSIE')
  { csstul = 'filter';
    cssert = "alpha(opacity="+cssert+")";
  }
  else
  { csstul = 'opacity';
    cssert = cssert/100;
  }
  hova.style[csstul] = cssert;
}
function megall_opacity()
{ clearTimeout(atlatszo); }
function halvanyit()
{ set_opacity_ertek(opacity_ertek,"scrolldiv");
  opacity_ertek = opacity_ertek+merre;
  if (opacity_ertek == 1)
  { merre=-merre;
    kep_valt();
    getImgSize(aktual_kep);
    document.getElementById("scrolldiv").style.background = "#394712 url('"+aktual_kep+"') no-repeat center 0px";
  }
  if (opacity_ertek == 100)
  { megall_opacity();
    aktual = 0;
    irany = -1;
    setTimeout("startpozicio();",100);
  }
  else
  { atlatszo = setTimeout("halvanyit()",30); }
}
function scroll_vertical()
{ var div = document.getElementById("scrolldiv");
  div.style.backgroundPosition = "center "+aktual+"px";
  aktual = aktual+irany;
  if(aktual==max_height)
  { irany=-irany;
    max_height=-max_height;
  }
  if (aktual==0)
  { megall();
    opacity_ertek = 100;
    merre = -1;
    halvanyit(opacity_ertek);
  }
  else  
    megy=setTimeout("scroll_vertical()",15);
}

