var fadetime = 0;
var elozo_kep = 0;

function kepCsere(kep,megallitas){
	
	elozo_kep = headkepid;
	
	for (i=1;i<=slide_darab;i++){        
        if(IE) {
        	document.getElementById('anim_kep_bg_'+i).setAttribute('className','');
        }
        else {
        	document.getElementById('anim_kep_bg_'+i).className = '';
        }
    }
	
	if(IE){
    	document.getElementById('anim_kep_bg_'+elozo_kep).setAttribute('className','visible');
    }
    else {
    	document.getElementById('anim_kep_bg_'+elozo_kep).className = 'visible';
    }
	
    if(kep==0){ 
        if(headkepid==1){headkepid=slide_darab}
        else{headkepid--}
    }else{    
        if(kep==slide_darab_next){
            if(headkepid==slide_darab){headkepid=1}
            else{headkepid++}
        }else{headkepid=kep}    
    }
    if(kep>0 && kep<slide_darab && animOn==1) pauseAnim();
    
    for (i=1;i<=slide_darab;i++){        
        if(IE) {
        	document.getElementById('anim_kep_'+i).setAttribute('className','');
        	document.getElementById('anim_szoveg_'+i).setAttribute('className','');
        }
        else {
        	document.getElementById('anim_kep_'+i).className = '';
        	document.getElementById('anim_szoveg_'+i).className = '';
        }
    }
   
    
    if(IE){
    	document.getElementById('anim_kep_'+headkepid).setAttribute('className','visible');
    	document.getElementById('anim_szoveg_'+headkepid).setAttribute('className','visible');
    }
    else {
    	document.getElementById('anim_kep_'+headkepid).className = 'visible';
    	document.getElementById('anim_szoveg_'+headkepid).className = 'visible';
    }
    
    imageId = 'anim_cikk_'+headkepid;
	image = document.getElementById(imageId);
    setOpacity(image, 0);
  	fadeIn(imageId,0);
    
    if (megallitas==1) stopAnim();
    

    
    
    for (i=1;i<=slide_darab;i++){        
        if(IE)document.getElementById('anim_control_'+i).setAttribute('className','');
        else document.getElementById('anim_control_'+i).className = '';
    }
    
    if(IE) document.getElementById('anim_control_'+headkepid).setAttribute('className','selected');
    else document.getElementById('anim_control_'+headkepid).className = 'selected';    
	
    
	//stopAnim();
}


function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  if(IE) {
  	obj.style.filter = "alpha(opacity:"+opacity+")";
  } else {
  	obj.style.opacity = opacity/100;
  }
  
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}


function pauseAnim(){
	
  if(animOn == 1){
	animOn = 0;
	/*document.getElementById("animPauseControl").style.background = 'url(../imgs/bg_sneakpeek_control_play.png) no-repeat';*/
	if(IE) document.getElementById('animPauseControl').setAttribute('className','sp_play');
    else document.getElementById('animPauseControl').className = 'sp_play'; 
	 window.clearInterval(animId);	 
  }else{ 
	animOn =1;
	/*document.getElementById("animPauseControl").style.background = 'url(../imgs/bg_sneakpeek_control_pause.png) no-repeat';*/
	if(IE) document.getElementById('animPauseControl').setAttribute('className','sp_pause');
    else document.getElementById('animPauseControl').className = 'sp_pause'; 
	kepCsere(slide_darab_next,0);
	animId = window.setInterval("kepCsere(slide_darab_next,0)",slide_timing);	 
  }	
}

function stopAnim(){
	animOn = 0;
	//document.getElementById("animPauseControl").style.background = 'url(/data/files/1/anim/anim_control_play.gif) no-repeat';
	window.clearInterval(animId);	 
}
